Class BetaMessageDeltaUsage.Builder
-
- All Implemented Interfaces:
public final class BetaMessageDeltaUsage.BuilderA builder for BetaMessageDeltaUsage.
-
-
Method Summary
-
-
Method Detail
-
cacheCreationInputTokens
final BetaMessageDeltaUsage.Builder cacheCreationInputTokens(Long cacheCreationInputTokens)
The cumulative number of input tokens used to create the cache entry.
-
cacheCreationInputTokens
final BetaMessageDeltaUsage.Builder cacheCreationInputTokens(Long cacheCreationInputTokens)
Alias for Builder.cacheCreationInputTokens.
This unboxed primitive overload exists for backwards compatibility.
-
cacheCreationInputTokens
final BetaMessageDeltaUsage.Builder cacheCreationInputTokens(Optional<Long> cacheCreationInputTokens)
Alias for calling Builder.cacheCreationInputTokens with
cacheCreationInputTokens.orElse(null).
-
cacheCreationInputTokens
final BetaMessageDeltaUsage.Builder cacheCreationInputTokens(JsonField<Long> cacheCreationInputTokens)
Sets Builder.cacheCreationInputTokens to an arbitrary JSON value.
You should usually call Builder.cacheCreationInputTokens with a well-typed Long value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
cacheReadInputTokens
final BetaMessageDeltaUsage.Builder cacheReadInputTokens(Long cacheReadInputTokens)
The cumulative number of input tokens read from the cache.
-
cacheReadInputTokens
final BetaMessageDeltaUsage.Builder cacheReadInputTokens(Long cacheReadInputTokens)
Alias for Builder.cacheReadInputTokens.
This unboxed primitive overload exists for backwards compatibility.
-
cacheReadInputTokens
final BetaMessageDeltaUsage.Builder cacheReadInputTokens(Optional<Long> cacheReadInputTokens)
Alias for calling Builder.cacheReadInputTokens with
cacheReadInputTokens.orElse(null).
-
cacheReadInputTokens
final BetaMessageDeltaUsage.Builder cacheReadInputTokens(JsonField<Long> cacheReadInputTokens)
Sets Builder.cacheReadInputTokens to an arbitrary JSON value.
You should usually call Builder.cacheReadInputTokens with a well-typed Long value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
fallbackCredit
final BetaMessageDeltaUsage.Builder fallbackCredit(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).
-
fallbackCredit
final BetaMessageDeltaUsage.Builder fallbackCredit(Optional<BetaFallbackCreditUsage> fallbackCredit)
Alias for calling Builder.fallbackCredit with
fallbackCredit.orElse(null).
-
fallbackCredit
final BetaMessageDeltaUsage.Builder fallbackCredit(JsonField<BetaFallbackCreditUsage> fallbackCredit)
Sets Builder.fallbackCredit to an arbitrary JSON value.
You should usually call Builder.fallbackCredit with a well-typed BetaFallbackCreditUsage value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
inputTokens
final BetaMessageDeltaUsage.Builder inputTokens(Long inputTokens)
The cumulative number of input tokens which were used.
-
inputTokens
final BetaMessageDeltaUsage.Builder inputTokens(Long inputTokens)
Alias for Builder.inputTokens.
This unboxed primitive overload exists for backwards compatibility.
-
inputTokens
final BetaMessageDeltaUsage.Builder inputTokens(Optional<Long> inputTokens)
Alias for calling Builder.inputTokens with
inputTokens.orElse(null).
-
inputTokens
final BetaMessageDeltaUsage.Builder inputTokens(JsonField<Long> inputTokens)
Sets Builder.inputTokens to an arbitrary JSON value.
You should usually call Builder.inputTokens with a well-typed Long value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
iterations
final BetaMessageDeltaUsage.Builder iterations(List<BetaMessageDeltaUsage.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.
-
iterations
final BetaMessageDeltaUsage.Builder iterations(Optional<List<BetaMessageDeltaUsage.Iteration>> iterations)
Alias for calling Builder.iterations with
iterations.orElse(null).
-
iterations
final BetaMessageDeltaUsage.Builder iterations(JsonField<List<BetaMessageDeltaUsage.Iteration>> iterations)
Sets Builder.iterations to an arbitrary JSON value.
You should usually call Builder.iterations with a well-typed
List<Iteration>value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
outputTokens
final BetaMessageDeltaUsage.Builder outputTokens(Long outputTokens)
The cumulative number of output tokens which were used.
-
outputTokens
final BetaMessageDeltaUsage.Builder outputTokens(JsonField<Long> outputTokens)
Sets Builder.outputTokens to an arbitrary JSON value.
You should usually call Builder.outputTokens with a well-typed Long value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
outputTokensDetails
final BetaMessageDeltaUsage.Builder outputTokensDetails(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.
-
outputTokensDetails
final BetaMessageDeltaUsage.Builder outputTokensDetails(Optional<BetaOutputTokensDetails> outputTokensDetails)
Alias for calling Builder.outputTokensDetails with
outputTokensDetails.orElse(null).
-
outputTokensDetails
final BetaMessageDeltaUsage.Builder outputTokensDetails(JsonField<BetaOutputTokensDetails> outputTokensDetails)
Sets Builder.outputTokensDetails to an arbitrary JSON value.
You should usually call Builder.outputTokensDetails with a well-typed BetaOutputTokensDetails value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
serverToolUse
final BetaMessageDeltaUsage.Builder serverToolUse(BetaServerToolUsage serverToolUse)
The number of server tool requests.
-
serverToolUse
final BetaMessageDeltaUsage.Builder serverToolUse(Optional<BetaServerToolUsage> serverToolUse)
Alias for calling Builder.serverToolUse with
serverToolUse.orElse(null).
-
serverToolUse
final BetaMessageDeltaUsage.Builder serverToolUse(JsonField<BetaServerToolUsage> serverToolUse)
Sets Builder.serverToolUse to an arbitrary JSON value.
You should usually call Builder.serverToolUse with a well-typed BetaServerToolUsage value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
additionalProperties
final BetaMessageDeltaUsage.Builder additionalProperties(Map<String, JsonValue> additionalProperties)
-
addIteration
final BetaMessageDeltaUsage.Builder addIteration(BetaMessageDeltaUsage.Iteration iteration)
Adds a single Iteration to iterations.
-
addIteration
final BetaMessageDeltaUsage.Builder addIteration(BetaMessageIterationUsage message)
Alias for calling addIteration with
Iteration.ofMessage(message).
-
addIteration
final BetaMessageDeltaUsage.Builder addIteration(BetaCompactionIterationUsage compaction)
Alias for calling addIteration with
Iteration.ofCompaction(compaction).
-
addIteration
final BetaMessageDeltaUsage.Builder addIteration(BetaAdvisorMessageIterationUsage advisorMessage)
Alias for calling addIteration with
Iteration.ofAdvisorMessage(advisorMessage).
-
addIteration
final BetaMessageDeltaUsage.Builder addIteration(BetaFallbackMessageIterationUsage fallbackMessage)
Alias for calling addIteration with
Iteration.ofFallbackMessage(fallbackMessage).
-
putAdditionalProperty
final BetaMessageDeltaUsage.Builder putAdditionalProperty(String key, JsonValue value)
-
putAllAdditionalProperties
final BetaMessageDeltaUsage.Builder putAllAdditionalProperties(Map<String, JsonValue> additionalProperties)
-
removeAdditionalProperty
final BetaMessageDeltaUsage.Builder removeAdditionalProperty(String key)
-
removeAllAdditionalProperties
final BetaMessageDeltaUsage.Builder removeAllAdditionalProperties(Set<String> keys)
-
build
final BetaMessageDeltaUsage build()
Returns an immutable instance of BetaMessageDeltaUsage.
Further updates to this Builder will not mutate the returned instance.
The following fields are required:
.cacheCreationInputTokens() .cacheReadInputTokens() .fallbackCredit() .inputTokens() .iterations() .outputTokens() .outputTokensDetails() .serverToolUse()
-
-
-
-