Class BetaUsage
-
- All Implemented Interfaces:
public final class BetaUsage
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classBetaUsage.BuilderA builder for BetaUsage.
public final classBetaUsage.Iterationpublic final classBetaUsage.ServiceTierIf the request used the priority, standard, or batch tier.
public final classBetaUsage.SpeedThe inference speed mode used for this request.
-
Method Summary
Modifier and Type Method Description final Optional<BetaCacheCreation>cacheCreation()Breakdown of cached tokens by TTL final Optional<Long>cacheCreationInputTokens()The number of input tokens used to create the cache entry. final Optional<Long>cacheReadInputTokens()The number of input tokens read from the cache. final Optional<BetaFallbackCreditUsage>fallbackCredit()Outcome of the fallback_credit_tokenpresented on this request.final Optional<String>inferenceGeo()The geographic region where inference was performed for this request. final LonginputTokens()The number of input tokens which were used. final Optional<List<BetaUsage.Iteration>>iterations()Per-iteration token usage breakdown. final LongoutputTokens()The number of output tokens which were used. final Optional<BetaOutputTokensDetails>outputTokensDetails()Breakdown of output tokens by category. final Optional<BetaServerToolUsage>serverToolUse()The number of server tool requests. final Optional<BetaUsage.ServiceTier>serviceTier()If the request used the priority, standard, or batch tier. final Optional<BetaUsage.Speed>speed()The inference speed mode used for this request. final JsonField<BetaCacheCreation>_cacheCreation()Returns the raw JSON value of cacheCreation. final JsonField<Long>_cacheCreationInputTokens()Returns the raw JSON value of cacheCreationInputTokens. final JsonField<Long>_cacheReadInputTokens()Returns the raw JSON value of cacheReadInputTokens. final JsonField<BetaFallbackCreditUsage>_fallbackCredit()Returns the raw JSON value of fallbackCredit. final JsonField<String>_inferenceGeo()Returns the raw JSON value of inferenceGeo. final JsonField<Long>_inputTokens()Returns the raw JSON value of inputTokens. final JsonField<List<BetaUsage.Iteration>>_iterations()Returns the raw JSON value of iterations. final JsonField<Long>_outputTokens()Returns the raw JSON value of outputTokens. final JsonField<BetaOutputTokensDetails>_outputTokensDetails()Returns the raw JSON value of outputTokensDetails. final JsonField<BetaServerToolUsage>_serverToolUse()Returns the raw JSON value of serverToolUse. final JsonField<BetaUsage.ServiceTier>_serviceTier()Returns the raw JSON value of serviceTier. final JsonField<BetaUsage.Speed>_speed()Returns the raw JSON value of speed. final Map<String, JsonValue>_additionalProperties()final BetaUsage.BuildertoBuilder()final BetaUsagevalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static BetaUsage.Builderbuilder()Returns a mutable builder for constructing an instance of BetaUsage. -
-
Method Detail
-
cacheCreation
final Optional<BetaCacheCreation> cacheCreation()
Breakdown of cached tokens by TTL
-
cacheCreationInputTokens
final Optional<Long> cacheCreationInputTokens()
The number of input tokens used to create the cache entry.
-
cacheReadInputTokens
final Optional<Long> cacheReadInputTokens()
The number of input tokens read from the cache.
-
fallbackCredit
final Optional<BetaFallbackCreditUsage> fallbackCredit()
Outcome of the
fallback_credit_tokenpresented on this request.Present on every response to a non-batch request that carried a
fallback_credit_token, in either redemption mode; absent otherwise (batch items accept and ignore the token and carry no outcome object).
-
inferenceGeo
final Optional<String> inferenceGeo()
The geographic region where inference was performed for this request.
-
inputTokens
final Long inputTokens()
The number of input tokens which were used.
-
iterations
final Optional<List<BetaUsage.Iteration>> iterations()
Per-iteration token usage breakdown.
Each entry represents one sampling iteration, with its own input/output token counts and cache statistics, discriminated by
type. Formessageentries (model sampling iterations, such as the turns of a server-side tool use loop), this allows you to:Calculate the context window size from the last
messageentryUnderstand token accumulation across server-side tool use loops
A
compactionentry reports the token usage of the compaction operation itself — the server-side request that summarizes the context being closed — NOT the size of the context that was compacted away, and its token counts can be much smaller than that closed context (for example, a compaction that closes a ~200k-token context can report only a few thousand tokens). Do not derive the context window size from acompactionentry, even when it is the last entry. Acompactionentry's tokens are not included in the top-levelusagefields. When an input-token trigger is in effect (the default — 150,000 tokens unless configured otherwise), eachcompactionentry closes a context that had reached at least that threshold, though the context can exceed it by the final iteration's output and tool results.
-
outputTokens
final Long outputTokens()
The number of output tokens which were used.
-
outputTokensDetails
final Optional<BetaOutputTokensDetails> outputTokensDetails()
Breakdown of output tokens by category.
output_tokensremains the inclusive, authoritative total used for billing. This object provides a read-only decomposition for observability — for example, how many of the billed output tokens were spent on internal reasoning that may have been summarized before being returned to you.
-
serverToolUse
final Optional<BetaServerToolUsage> serverToolUse()
The number of server tool requests.
-
serviceTier
final Optional<BetaUsage.ServiceTier> serviceTier()
If the request used the priority, standard, or batch tier.
-
speed
final Optional<BetaUsage.Speed> speed()
The inference speed mode used for this request.
-
_cacheCreation
final JsonField<BetaCacheCreation> _cacheCreation()
Returns the raw JSON value of cacheCreation.
Unlike cacheCreation, this method doesn't throw if the JSON field has an unexpected type.
-
_cacheCreationInputTokens
final JsonField<Long> _cacheCreationInputTokens()
Returns the raw JSON value of cacheCreationInputTokens.
Unlike cacheCreationInputTokens, this method doesn't throw if the JSON field has an unexpected type.
-
_cacheReadInputTokens
final JsonField<Long> _cacheReadInputTokens()
Returns the raw JSON value of cacheReadInputTokens.
Unlike cacheReadInputTokens, this method doesn't throw if the JSON field has an unexpected type.
-
_fallbackCredit
final JsonField<BetaFallbackCreditUsage> _fallbackCredit()
Returns the raw JSON value of fallbackCredit.
Unlike fallbackCredit, this method doesn't throw if the JSON field has an unexpected type.
-
_inferenceGeo
final JsonField<String> _inferenceGeo()
Returns the raw JSON value of inferenceGeo.
Unlike inferenceGeo, this method doesn't throw if the JSON field has an unexpected type.
-
_inputTokens
final JsonField<Long> _inputTokens()
Returns the raw JSON value of inputTokens.
Unlike inputTokens, this method doesn't throw if the JSON field has an unexpected type.
-
_iterations
final JsonField<List<BetaUsage.Iteration>> _iterations()
Returns the raw JSON value of iterations.
Unlike iterations, this method doesn't throw if the JSON field has an unexpected type.
-
_outputTokens
final JsonField<Long> _outputTokens()
Returns the raw JSON value of outputTokens.
Unlike outputTokens, this method doesn't throw if the JSON field has an unexpected type.
-
_outputTokensDetails
final JsonField<BetaOutputTokensDetails> _outputTokensDetails()
Returns the raw JSON value of outputTokensDetails.
Unlike outputTokensDetails, this method doesn't throw if the JSON field has an unexpected type.
-
_serverToolUse
final JsonField<BetaServerToolUsage> _serverToolUse()
Returns the raw JSON value of serverToolUse.
Unlike serverToolUse, this method doesn't throw if the JSON field has an unexpected type.
-
_serviceTier
final JsonField<BetaUsage.ServiceTier> _serviceTier()
Returns the raw JSON value of serviceTier.
Unlike serviceTier, this method doesn't throw if the JSON field has an unexpected type.
-
_speed
final JsonField<BetaUsage.Speed> _speed()
Returns the raw JSON value of speed.
Unlike speed, this method doesn't throw if the JSON field has an unexpected type.
-
_additionalProperties
final Map<String, JsonValue> _additionalProperties()
-
toBuilder
final BetaUsage.Builder toBuilder()
-
validate
final BetaUsage validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
builder
final static BetaUsage.Builder builder()
Returns a mutable builder for constructing an instance of BetaUsage.
The following fields are required:
.cacheCreation() .cacheCreationInputTokens() .cacheReadInputTokens() .fallbackCredit() .inferenceGeo() .inputTokens() .iterations() .outputTokens() .outputTokensDetails() .serverToolUse() .serviceTier() .speed()
-
-
-
-