Package org.mockserver.model
Class Usage
java.lang.Object
org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
org.mockserver.model.ObjectWithJsonToString
org.mockserver.model.Usage
Token usage for an LLM completion.
inputTokens and outputTokens are the baseline counts every
provider reports. The remaining fields are optional — when a
provider does not report them they stay null and behaviour is
unchanged (back-compatible):
cachedInputTokens— input tokens served from a prompt cache at a reduced rate. Maps to OpenAIprompt_tokens_details.cached_tokensand Anthropiccache_read_input_tokens. These are a subset ofinputTokens(not additive) for both providers.cacheCreationTokens— input tokens written to a prompt cache at a premium rate. Maps to Anthropiccache_creation_input_tokens.reasoningTokens— "thinking"/reasoning tokens that are billed as output but not part of the visible completion. Maps to OpenAIcompletion_tokens_details.reasoning_tokens. These are a subset ofoutputTokens(not additive).
Cost dashboards that ignore these fields mis-bill cached and reasoning-heavy workloads; surfacing them lets a downstream consumer apply the provider's cache-read discount or attribute reasoning spend.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleaninthashCode()static UsageinputTokens(int inputTokens) static UsageoutputTokens(int outputTokens) static Usageusage()withCacheCreationTokens(Integer cacheCreationTokens) Input tokens written to a prompt cache (Anthropiccache_creation_input_tokens).withCachedInputTokens(Integer cachedInputTokens) Input tokens served from a prompt cache (OpenAIprompt_tokens_details.cached_tokens/ Anthropiccache_read_input_tokens).withInputTokens(Integer inputTokens) withOutputTokens(Integer outputTokens) withReasoningTokens(Integer reasoningTokens) Reasoning/thinking tokens billed as output but not part of the visible completion (OpenAIcompletion_tokens_details.reasoning_tokens).Methods inherited from class org.mockserver.model.ObjectWithJsonToString
toStringMethods inherited from class org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
fieldsExcludedFromEqualsAndHashCode
-
Constructor Details
-
Usage
public Usage()
-
-
Method Details
-
usage
-
inputTokens
-
outputTokens
-
withInputTokens
-
getInputTokens
-
withOutputTokens
-
getOutputTokens
-
withCachedInputTokens
Input tokens served from a prompt cache (OpenAIprompt_tokens_details.cached_tokens/ Anthropiccache_read_input_tokens). A subset ofgetInputTokens(). -
getCachedInputTokens
-
withCacheCreationTokens
Input tokens written to a prompt cache (Anthropiccache_creation_input_tokens). -
getCacheCreationTokens
-
withReasoningTokens
Reasoning/thinking tokens billed as output but not part of the visible completion (OpenAIcompletion_tokens_details.reasoning_tokens). A subset ofgetOutputTokens(). -
getReasoningTokens
-
equals
- Overrides:
equalsin classObjectWithReflectiveEqualsHashCodeToString
-
hashCode
public int hashCode()- Overrides:
hashCodein classObjectWithReflectiveEqualsHashCodeToString
-