java.lang.Object
java.lang.Record
com.agentforge4j.llm.api.TokenUsageReport
- Record Components:
inputTokens- non-cached input tokens when reported;nullif absentoutputTokens- generated output tokens when reported;nullif absentcachedInputTokens- tokens served from a provider prompt cache when reported; populated only by providers that expose prompt-cache accounting (for example Anthropic Claude, Bedrock InvokeModel Anthropic, and sometimes OpenAI);nullif the provider did not report it for this callcacheWriteTokens- tokens written into a provider prompt cache when reported; same provider scope ascachedInputTokens;nullif the provider did not report it for this call
public record TokenUsageReport(Integer inputTokens, Integer outputTokens, Integer cachedInputTokens, Integer cacheWriteTokens)
extends Record
Token usage reported by an LLM provider for a single invocation.
A null reference to this record on LlmExecutionResponse.tokenUsage() means the
provider returned no usage block at all for this call. Individual fields may be null
when the usage block is present but the provider omitted that count.
-
Constructor Summary
ConstructorsConstructorDescriptionTokenUsageReport(Integer inputTokens, Integer outputTokens, Integer cachedInputTokens, Integer cacheWriteTokens) Creates an instance of aTokenUsageReportrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecachedInputTokensrecord component.Returns the value of thecacheWriteTokensrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of theinputTokensrecord component.Returns the value of theoutputTokensrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
TokenUsageReport
public TokenUsageReport(Integer inputTokens, Integer outputTokens, Integer cachedInputTokens, Integer cacheWriteTokens) Creates an instance of aTokenUsageReportrecord class.- Parameters:
inputTokens- the value for theinputTokensrecord componentoutputTokens- the value for theoutputTokensrecord componentcachedInputTokens- the value for thecachedInputTokensrecord componentcacheWriteTokens- the value for thecacheWriteTokensrecord component
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
inputTokens
Returns the value of theinputTokensrecord component.- Returns:
- the value of the
inputTokensrecord component
-
outputTokens
Returns the value of theoutputTokensrecord component.- Returns:
- the value of the
outputTokensrecord component
-
cachedInputTokens
Returns the value of thecachedInputTokensrecord component.- Returns:
- the value of the
cachedInputTokensrecord component
-
cacheWriteTokens
Returns the value of thecacheWriteTokensrecord component.- Returns:
- the value of the
cacheWriteTokensrecord component
-