Record Class TokenUsageReport

java.lang.Object
java.lang.Record
com.agentforge4j.llm.api.TokenUsageReport
Record Components:
inputTokens - non-cached input tokens when reported; null if absent
outputTokens - generated output tokens when reported; null if absent
cachedInputTokens - 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); null if the provider did not report it for this call
cacheWriteTokens - tokens written into a provider prompt cache when reported; same provider scope as cachedInputTokens; null if 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 Details

    • TokenUsageReport

      public TokenUsageReport(Integer inputTokens, Integer outputTokens, Integer cachedInputTokens, Integer cacheWriteTokens)
      Creates an instance of a TokenUsageReport record class.
      Parameters:
      inputTokens - the value for the inputTokens record component
      outputTokens - the value for the outputTokens record component
      cachedInputTokens - the value for the cachedInputTokens record component
      cacheWriteTokens - the value for the cacheWriteTokens record component
  • Method Details

    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • inputTokens

      public Integer inputTokens()
      Returns the value of the inputTokens record component.
      Returns:
      the value of the inputTokens record component
    • outputTokens

      public Integer outputTokens()
      Returns the value of the outputTokens record component.
      Returns:
      the value of the outputTokens record component
    • cachedInputTokens

      public Integer cachedInputTokens()
      Returns the value of the cachedInputTokens record component.
      Returns:
      the value of the cachedInputTokens record component
    • cacheWriteTokens

      public Integer cacheWriteTokens()
      Returns the value of the cacheWriteTokens record component.
      Returns:
      the value of the cacheWriteTokens record component