@@ -43,6 +43,7 @@ private constructor(
4343 private val outputTokens: JsonField <Long >,
4444 private val serverToolUse: JsonField <BetaServerToolUsage >,
4545 private val serviceTier: JsonField <ServiceTier >,
46+ private val speed: JsonField <Speed >,
4647 private val additionalProperties: MutableMap <String , JsonValue >,
4748) {
4849
@@ -75,6 +76,7 @@ private constructor(
7576 @JsonProperty(" service_tier" )
7677 @ExcludeMissing
7778 serviceTier: JsonField <ServiceTier > = JsonMissing .of(),
79+ @JsonProperty(" speed" ) @ExcludeMissing speed: JsonField <Speed > = JsonMissing .of(),
7880 ) : this (
7981 cacheCreation,
8082 cacheCreationInputTokens,
@@ -85,6 +87,7 @@ private constructor(
8587 outputTokens,
8688 serverToolUse,
8789 serviceTier,
90+ speed,
8891 mutableMapOf (),
8992 )
9093
@@ -170,6 +173,14 @@ private constructor(
170173 */
171174 fun serviceTier (): Optional <ServiceTier > = serviceTier.getOptional(" service_tier" )
172175
176+ /* *
177+ * The inference speed mode used for this request.
178+ *
179+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the
180+ * server responded with an unexpected value).
181+ */
182+ fun speed (): Optional <Speed > = speed.getOptional(" speed" )
183+
173184 /* *
174185 * Returns the raw JSON value of [cacheCreation].
175186 *
@@ -251,6 +262,13 @@ private constructor(
251262 @ExcludeMissing
252263 fun _serviceTier (): JsonField <ServiceTier > = serviceTier
253264
265+ /* *
266+ * Returns the raw JSON value of [speed].
267+ *
268+ * Unlike [speed], this method doesn't throw if the JSON field has an unexpected type.
269+ */
270+ @JsonProperty(" speed" ) @ExcludeMissing fun _speed (): JsonField <Speed > = speed
271+
254272 @JsonAnySetter
255273 private fun putAdditionalProperty (key : String , value : JsonValue ) {
256274 additionalProperties.put(key, value)
@@ -279,6 +297,7 @@ private constructor(
279297 * .outputTokens()
280298 * .serverToolUse()
281299 * .serviceTier()
300+ * .speed()
282301 * ```
283302 */
284303 @JvmStatic fun builder () = Builder ()
@@ -296,6 +315,7 @@ private constructor(
296315 private var outputTokens: JsonField <Long >? = null
297316 private var serverToolUse: JsonField <BetaServerToolUsage >? = null
298317 private var serviceTier: JsonField <ServiceTier >? = null
318+ private var speed: JsonField <Speed >? = null
299319 private var additionalProperties: MutableMap <String , JsonValue > = mutableMapOf ()
300320
301321 @JvmSynthetic
@@ -309,6 +329,7 @@ private constructor(
309329 outputTokens = betaUsage.outputTokens
310330 serverToolUse = betaUsage.serverToolUse
311331 serviceTier = betaUsage.serviceTier
332+ speed = betaUsage.speed
312333 additionalProperties = betaUsage.additionalProperties.toMutableMap()
313334 }
314335
@@ -523,6 +544,20 @@ private constructor(
523544 this .serviceTier = serviceTier
524545 }
525546
547+ /* * The inference speed mode used for this request. */
548+ fun speed (speed : Speed ? ) = speed(JsonField .ofNullable(speed))
549+
550+ /* * Alias for calling [Builder.speed] with `speed.orElse(null)`. */
551+ fun speed (speed : Optional <Speed >) = speed(speed.getOrNull())
552+
553+ /* *
554+ * Sets [Builder.speed] to an arbitrary JSON value.
555+ *
556+ * You should usually call [Builder.speed] with a well-typed [Speed] value instead. This
557+ * method is primarily for setting the field to an undocumented or not yet supported value.
558+ */
559+ fun speed (speed : JsonField <Speed >) = apply { this .speed = speed }
560+
526561 fun additionalProperties (additionalProperties : Map <String , JsonValue >) = apply {
527562 this .additionalProperties.clear()
528563 putAllAdditionalProperties(additionalProperties)
@@ -558,6 +593,7 @@ private constructor(
558593 * .outputTokens()
559594 * .serverToolUse()
560595 * .serviceTier()
596+ * .speed()
561597 * ```
562598 *
563599 * @throws IllegalStateException if any required field is unset.
@@ -573,6 +609,7 @@ private constructor(
573609 checkRequired(" outputTokens" , outputTokens),
574610 checkRequired(" serverToolUse" , serverToolUse),
575611 checkRequired(" serviceTier" , serviceTier),
612+ checkRequired(" speed" , speed),
576613 additionalProperties.toMutableMap(),
577614 )
578615 }
@@ -593,6 +630,7 @@ private constructor(
593630 outputTokens()
594631 serverToolUse().ifPresent { it.validate() }
595632 serviceTier().ifPresent { it.validate() }
633+ speed().ifPresent { it.validate() }
596634 validated = true
597635 }
598636
@@ -619,7 +657,8 @@ private constructor(
619657 (iterations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ? : 0 ) +
620658 (if (outputTokens.asKnown().isPresent) 1 else 0 ) +
621659 (serverToolUse.asKnown().getOrNull()?.validity() ? : 0 ) +
622- (serviceTier.asKnown().getOrNull()?.validity() ? : 0 )
660+ (serviceTier.asKnown().getOrNull()?.validity() ? : 0 ) +
661+ (speed.asKnown().getOrNull()?.validity() ? : 0 )
623662
624663 /* * Token usage for a sampling iteration. */
625664 @JsonDeserialize(using = BetaIterationsUsageItems .Deserializer ::class )
@@ -973,6 +1012,134 @@ private constructor(
9731012 override fun toString () = value.toString()
9741013 }
9751014
1015+ /* * The inference speed mode used for this request. */
1016+ class Speed @JsonCreator private constructor(private val value : JsonField <String >) : Enum {
1017+
1018+ /* *
1019+ * Returns this class instance's raw value.
1020+ *
1021+ * This is usually only useful if this instance was deserialized from data that doesn't
1022+ * match any known member, and you want to know that value. For example, if the SDK is on an
1023+ * older version than the API, then the API may respond with new members that the SDK is
1024+ * unaware of.
1025+ */
1026+ @com.fasterxml.jackson.annotation.JsonValue fun _value (): JsonField <String > = value
1027+
1028+ companion object {
1029+
1030+ @JvmField val STANDARD = of(" standard" )
1031+
1032+ @JvmField val FAST = of(" fast" )
1033+
1034+ @JvmStatic fun of (value : String ) = Speed (JsonField .of(value))
1035+ }
1036+
1037+ /* * An enum containing [Speed]'s known values. */
1038+ enum class Known {
1039+ STANDARD ,
1040+ FAST ,
1041+ }
1042+
1043+ /* *
1044+ * An enum containing [Speed]'s known values, as well as an [_UNKNOWN] member.
1045+ *
1046+ * An instance of [Speed] can contain an unknown value in a couple of cases:
1047+ * - It was deserialized from data that doesn't match any known member. For example, if the
1048+ * SDK is on an older version than the API, then the API may respond with new members that
1049+ * the SDK is unaware of.
1050+ * - It was constructed with an arbitrary value using the [of] method.
1051+ */
1052+ enum class Value {
1053+ STANDARD ,
1054+ FAST ,
1055+ /* * An enum member indicating that [Speed] was instantiated with an unknown value. */
1056+ _UNKNOWN ,
1057+ }
1058+
1059+ /* *
1060+ * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN]
1061+ * if the class was instantiated with an unknown value.
1062+ *
1063+ * Use the [known] method instead if you're certain the value is always known or if you want
1064+ * to throw for the unknown case.
1065+ */
1066+ fun value (): Value =
1067+ when (this ) {
1068+ STANDARD -> Value .STANDARD
1069+ FAST -> Value .FAST
1070+ else -> Value ._UNKNOWN
1071+ }
1072+
1073+ /* *
1074+ * Returns an enum member corresponding to this class instance's value.
1075+ *
1076+ * Use the [value] method instead if you're uncertain the value is always known and don't
1077+ * want to throw for the unknown case.
1078+ *
1079+ * @throws AnthropicInvalidDataException if this class instance's value is a not a known
1080+ * member.
1081+ */
1082+ fun known (): Known =
1083+ when (this ) {
1084+ STANDARD -> Known .STANDARD
1085+ FAST -> Known .FAST
1086+ else -> throw AnthropicInvalidDataException (" Unknown Speed: $value " )
1087+ }
1088+
1089+ /* *
1090+ * Returns this class instance's primitive wire representation.
1091+ *
1092+ * This differs from the [toString] method because that method is primarily for debugging
1093+ * and generally doesn't throw.
1094+ *
1095+ * @throws AnthropicInvalidDataException if this class instance's value does not have the
1096+ * expected primitive type.
1097+ */
1098+ fun asString (): String =
1099+ _value ().asString().orElseThrow {
1100+ AnthropicInvalidDataException (" Value is not a String" )
1101+ }
1102+
1103+ private var validated: Boolean = false
1104+
1105+ fun validate (): Speed = apply {
1106+ if (validated) {
1107+ return @apply
1108+ }
1109+
1110+ known()
1111+ validated = true
1112+ }
1113+
1114+ fun isValid (): Boolean =
1115+ try {
1116+ validate()
1117+ true
1118+ } catch (e: AnthropicInvalidDataException ) {
1119+ false
1120+ }
1121+
1122+ /* *
1123+ * Returns a score indicating how many valid values are contained in this object
1124+ * recursively.
1125+ *
1126+ * Used for best match union deserialization.
1127+ */
1128+ @JvmSynthetic internal fun validity (): Int = if (value() == Value ._UNKNOWN ) 0 else 1
1129+
1130+ override fun equals (other : Any? ): Boolean {
1131+ if (this == = other) {
1132+ return true
1133+ }
1134+
1135+ return other is Speed && value == other.value
1136+ }
1137+
1138+ override fun hashCode () = value.hashCode()
1139+
1140+ override fun toString () = value.toString()
1141+ }
1142+
9761143 override fun equals (other : Any? ): Boolean {
9771144 if (this == = other) {
9781145 return true
@@ -988,6 +1155,7 @@ private constructor(
9881155 outputTokens == other.outputTokens &&
9891156 serverToolUse == other.serverToolUse &&
9901157 serviceTier == other.serviceTier &&
1158+ speed == other.speed &&
9911159 additionalProperties == other.additionalProperties
9921160 }
9931161
@@ -1002,12 +1170,13 @@ private constructor(
10021170 outputTokens,
10031171 serverToolUse,
10041172 serviceTier,
1173+ speed,
10051174 additionalProperties,
10061175 )
10071176 }
10081177
10091178 override fun hashCode (): Int = hashCode
10101179
10111180 override fun toString () =
1012- " BetaUsage{cacheCreation=$cacheCreation , cacheCreationInputTokens=$cacheCreationInputTokens , cacheReadInputTokens=$cacheReadInputTokens , inferenceGeo=$inferenceGeo , inputTokens=$inputTokens , iterations=$iterations , outputTokens=$outputTokens , serverToolUse=$serverToolUse , serviceTier=$serviceTier , additionalProperties=$additionalProperties }"
1181+ " BetaUsage{cacheCreation=$cacheCreation , cacheCreationInputTokens=$cacheCreationInputTokens , cacheReadInputTokens=$cacheReadInputTokens , inferenceGeo=$inferenceGeo , inputTokens=$inputTokens , iterations=$iterations , outputTokens=$outputTokens , serverToolUse=$serverToolUse , serviceTier=$serviceTier , speed= $speed , additionalProperties=$additionalProperties }"
10131182}
0 commit comments