Package org.machanism.machai.ai.manager
Class Usage
java.lang.Object
org.machanism.machai.ai.manager.Usage
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
ConstructorsConstructorDescriptionUsage(long inputTokens, long inputCachedTokens, long outputTokens) Creates a usage record. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the number of cached input tokens reported by the provider.longReturns the number of input tokens consumed by the request.longReturns the number of output tokens generated by the response.
-
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 requestinputCachedTokens- the number of cached input tokens reused by the provideroutputTokens- 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
-