Class Usage

java.lang.Object
org.machanism.machai.ai.manager.Usage

public class Usage extends Object
Immutable token-usage metrics for a single generative AI interaction.

A usage instance captures the number of prompt tokens, cached prompt tokens, and completion tokens reported by a provider for one request-response cycle. These values can be collected by UsageStatistics to produce aggregated reporting per model.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Usage(long inputTokens, long inputCachedTokens, long outputTokens)
    Creates a usage record.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the number of cached input tokens reported by the provider.
    long
    Returns the number of input tokens consumed by the request.
    long
    Returns the number of output tokens generated by the response.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Usage

      public Usage(long inputTokens, long inputCachedTokens, long outputTokens)
      Creates a usage record.
      Parameters:
      inputTokens - the number of input tokens consumed by the request
      inputCachedTokens - the number of cached input tokens reused by the provider
      outputTokens - the number of output tokens generated in the response
  • Method Details

    • getInputTokens

      public long getInputTokens()
      Returns the number of input tokens consumed by the request.
      Returns:
      the input token count
    • getInputCachedTokens

      public long getInputCachedTokens()
      Returns the number of cached input tokens reported by the provider.
      Returns:
      the cached input token count
    • getOutputTokens

      public long getOutputTokens()
      Returns the number of output tokens generated by the response.
      Returns:
      the output token count