Record Class OpenAiApi.Usage
java.lang.Object
java.lang.Record
org.springframework.ai.openai.api.OpenAiApi.Usage
- Record Components:
completionTokens
- Number of tokens in the generated completion. Only applicable for completion requests.promptTokens
- Number of tokens in the prompt.totalTokens
- Total number of tokens used in the request (prompt + completion).promptTokensDetails
- Breakdown of tokens used in the prompt.completionTokenDetails
- Breakdown of tokens used in a completion.promptCacheHitTokens
- Number of tokens in the prompt that were served from (util for DeepSeek support).promptCacheMissTokens
- Number of tokens in the prompt that were not served (util for DeepSeek support).
- Enclosing class:
- OpenAiApi
public static record OpenAiApi.Usage(Integer completionTokens, Integer promptTokens, Integer totalTokens, OpenAiApi.Usage.PromptTokensDetails promptTokensDetails, OpenAiApi.Usage.CompletionTokenDetails completionTokenDetails, Integer promptCacheHitTokens, Integer promptCacheMissTokens)
extends Record
Usage statistics for the completion request.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
Breakdown of tokens used in a completion.static final record
Breakdown of tokens used in the prompt -
Constructor Summary
ConstructorsConstructorDescriptionUsage
(Integer completionTokens, Integer promptTokens, Integer totalTokens, OpenAiApi.Usage.PromptTokensDetails promptTokensDetails, OpenAiApi.Usage.CompletionTokenDetails completionTokenDetails, Integer promptCacheHitTokens, Integer promptCacheMissTokens) Creates an instance of aUsage
record class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecompletionTokenDetails
record component.Returns the value of thecompletionTokens
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.Returns the value of thepromptCacheHitTokens
record component.Returns the value of thepromptCacheMissTokens
record component.Returns the value of thepromptTokens
record component.Returns the value of thepromptTokensDetails
record component.final String
toString()
Returns a string representation of this record class.Returns the value of thetotalTokens
record component.
-
Constructor Details
-
Usage
-
Usage
public Usage(Integer completionTokens, Integer promptTokens, Integer totalTokens, OpenAiApi.Usage.PromptTokensDetails promptTokensDetails, OpenAiApi.Usage.CompletionTokenDetails completionTokenDetails, Integer promptCacheHitTokens, Integer promptCacheMissTokens) Creates an instance of aUsage
record class.- Parameters:
completionTokens
- the value for thecompletionTokens
record componentpromptTokens
- the value for thepromptTokens
record componenttotalTokens
- the value for thetotalTokens
record componentpromptTokensDetails
- the value for thepromptTokensDetails
record componentcompletionTokenDetails
- the value for thecompletionTokenDetails
record componentpromptCacheHitTokens
- the value for thepromptCacheHitTokens
record componentpromptCacheMissTokens
- the value for thepromptCacheMissTokens
record 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)
. -
completionTokens
Returns the value of thecompletionTokens
record component.- Returns:
- the value of the
completionTokens
record component
-
promptTokens
Returns the value of thepromptTokens
record component.- Returns:
- the value of the
promptTokens
record component
-
totalTokens
Returns the value of thetotalTokens
record component.- Returns:
- the value of the
totalTokens
record component
-
promptTokensDetails
Returns the value of thepromptTokensDetails
record component.- Returns:
- the value of the
promptTokensDetails
record component
-
completionTokenDetails
Returns the value of thecompletionTokenDetails
record component.- Returns:
- the value of the
completionTokenDetails
record component
-
promptCacheHitTokens
Returns the value of thepromptCacheHitTokens
record component.- Returns:
- the value of the
promptCacheHitTokens
record component
-
promptCacheMissTokens
Returns the value of thepromptCacheMissTokens
record component.- Returns:
- the value of the
promptCacheMissTokens
record component
-