Class BetaUsage.Iteration
-
- All Implemented Interfaces:
public final class BetaUsage.Iteration
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceBetaUsage.Iteration.VisitorAn interface that defines how to map each variant of Iteration to a value of type T.
public final classBetaUsage.Iteration.Type
-
Method Summary
Modifier and Type Method Description final Optional<BetaMessageIterationUsage>message()Token usage for a sampling iteration. final Optional<BetaCompactionIterationUsage>compaction()Token usage for a compaction iteration. final Optional<BetaAdvisorMessageIterationUsage>advisorMessage()Token usage for an advisor sub-inference iteration. final Optional<BetaFallbackMessageIterationUsage>fallbackMessage()Token usage for the fallback-model attempt of a server-side fallback request. final Optional<JsonValue>_json()final BetaUsage.Iteration.Typetype()final Optional<BetaCacheCreation>cacheCreation()final LongcacheCreationInputTokens()final LongcacheReadInputTokens()final LonginputTokens()final Optional<Model>model()final LongoutputTokens()final BooleanisMessage()final BooleanisCompaction()final BooleanisAdvisorMessage()final BooleanisFallbackMessage()final BetaMessageIterationUsageasMessage()Token usage for a sampling iteration. final BetaCompactionIterationUsageasCompaction()Token usage for a compaction iteration. final BetaAdvisorMessageIterationUsageasAdvisorMessage()Token usage for an advisor sub-inference iteration. final BetaFallbackMessageIterationUsageasFallbackMessage()Token usage for the fallback-model attempt of a server-side fallback request. final <T extends Any> Taccept(BetaUsage.Iteration.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final BetaUsage.Iterationvalidate()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.IterationofMessage(BetaMessageIterationUsage message)Token usage for a sampling iteration. final static BetaUsage.IterationofCompaction(BetaCompactionIterationUsage compaction)Token usage for a compaction iteration. final static BetaUsage.IterationofAdvisorMessage(BetaAdvisorMessageIterationUsage advisorMessage)Token usage for an advisor sub-inference iteration. final static BetaUsage.IterationofFallbackMessage(BetaFallbackMessageIterationUsage fallbackMessage)Token usage for the fallback-model attempt of a server-side fallback request. -
-
Method Detail
-
message
final Optional<BetaMessageIterationUsage> message()
Token usage for a sampling iteration.
-
compaction
final Optional<BetaCompactionIterationUsage> compaction()
Token usage for a compaction iteration.
-
advisorMessage
final Optional<BetaAdvisorMessageIterationUsage> advisorMessage()
Token usage for an advisor sub-inference iteration.
-
fallbackMessage
final Optional<BetaFallbackMessageIterationUsage> fallbackMessage()
Token usage for the fallback-model attempt of a server-side fallback request.
The terminal entry of a fallback-served turn: when a fallback hop's output is the returned message, the entry for the iteration that completed it carries this type in place of
message. A declined hop and the serving hop's earlier tool-loop iterations producemessageentries. Whether a fallback model served the response is signalled by the presence of this entry inusage.iterations.
-
type
final BetaUsage.Iteration.Type type()
-
cacheCreation
final Optional<BetaCacheCreation> cacheCreation()
-
cacheCreationInputTokens
final Long cacheCreationInputTokens()
-
cacheReadInputTokens
final Long cacheReadInputTokens()
-
inputTokens
final Long inputTokens()
-
outputTokens
final Long outputTokens()
-
isCompaction
final Boolean isCompaction()
-
isAdvisorMessage
final Boolean isAdvisorMessage()
-
isFallbackMessage
final Boolean isFallbackMessage()
-
asMessage
final BetaMessageIterationUsage asMessage()
Token usage for a sampling iteration.
-
asCompaction
final BetaCompactionIterationUsage asCompaction()
Token usage for a compaction iteration.
-
asAdvisorMessage
final BetaAdvisorMessageIterationUsage asAdvisorMessage()
Token usage for an advisor sub-inference iteration.
-
asFallbackMessage
final BetaFallbackMessageIterationUsage asFallbackMessage()
Token usage for the fallback-model attempt of a server-side fallback request.
The terminal entry of a fallback-served turn: when a fallback hop's output is the returned message, the entry for the iteration that completed it carries this type in place of
message. A declined hop and the serving hop's earlier tool-loop iterations producemessageentries. Whether a fallback model served the response is signalled by the presence of this entry inusage.iterations.
-
accept
final <T extends Any> T accept(BetaUsage.Iteration.Visitor<T> visitor)
Maps this instance's current variant to a value of type T using the given visitor.
Note that this method is not forwards compatible with new variants from the API, unless visitor overrides Visitor.unknown. To handle variants not known to this version of the SDK gracefully, consider overriding Visitor.unknown:
import com.anthropic.core.JsonValue; import java.util.Optional; Optional<String> result = iteration.accept(new Iteration.Visitor<Optional<String>>() { @Override public Optional<String> visitMessage(BetaMessageIterationUsage message) { return Optional.of(message.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final BetaUsage.Iteration 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.
-
ofMessage
final static BetaUsage.Iteration ofMessage(BetaMessageIterationUsage message)
Token usage for a sampling iteration.
-
ofCompaction
final static BetaUsage.Iteration ofCompaction(BetaCompactionIterationUsage compaction)
Token usage for a compaction iteration.
-
ofAdvisorMessage
final static BetaUsage.Iteration ofAdvisorMessage(BetaAdvisorMessageIterationUsage advisorMessage)
Token usage for an advisor sub-inference iteration.
-
ofFallbackMessage
final static BetaUsage.Iteration ofFallbackMessage(BetaFallbackMessageIterationUsage fallbackMessage)
Token usage for the fallback-model attempt of a server-side fallback request.
The terminal entry of a fallback-served turn: when a fallback hop's output is the returned message, the entry for the iteration that completed it carries this type in place of
message. A declined hop and the serving hop's earlier tool-loop iterations producemessageentries. Whether a fallback model served the response is signalled by the presence of this entry inusage.iterations.
-
-
-
-