Class OpenAiUsage
java.lang.Object
org.springframework.ai.openai.metadata.OpenAiUsage
- All Implemented Interfaces:
Usage
Usage
implementation for OpenAI.- Since:
- 0.7.0
- Author:
- John Blum, Thomas Vitale, David Frizelle, Christian Tzolov
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
static final record
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic OpenAiUsage
from
(OpenAiApi.Usage usage) Deprecated.Deprecated.UsegetCompletionTokenDetails()
instead.Returns the number of tokens returned in the generation (aka completion) of the AI's response.Returns the number of tokens used in the prompt of the AI request.Deprecated.UsegetPromptTokensDetails()
instead.Deprecated.UsegetCompletionTokenDetails()
instead.Deprecated.UsegetCompletionTokenDetails()
instead.Return the total number of tokens from both the prompt of an AI request and generation of the AI's response.protected OpenAiApi.Usage
getUsage()
toString()
-
Constructor Details
-
OpenAiUsage
-
-
Method Details
-
from
-
getUsage
-
getPromptTokens
Description copied from interface:Usage
Returns the number of tokens used in the prompt of the AI request.- Specified by:
getPromptTokens
in interfaceUsage
- Returns:
- an
Long
with the number of tokens used in the prompt of the AI request. - See Also:
-
getGenerationTokens
Description copied from interface:Usage
Returns the number of tokens returned in the generation (aka completion) of the AI's response.- Specified by:
getGenerationTokens
in interfaceUsage
- Returns:
- an
Long
with the number of tokens returned in the generation (aka completion) of the AI's response. - See Also:
-
getTotalTokens
Description copied from interface:Usage
Return the total number of tokens from both the prompt of an AI request and generation of the AI's response.- Specified by:
getTotalTokens
in interfaceUsage
- Returns:
- the total number of tokens from both the prompt of an AI request and generation of the AI's response.
- See Also:
-
getPromptTokensDetailsCachedTokens
Deprecated.UsegetPromptTokensDetails()
instead. -
getPromptTokensDetails
-
getReasoningTokens
Deprecated.UsegetCompletionTokenDetails()
instead. -
getAcceptedPredictionTokens
Deprecated.UsegetCompletionTokenDetails()
instead. -
getAudioTokens
Deprecated.UsegetCompletionTokenDetails()
instead. -
getRejectedPredictionTokens
Deprecated.UsegetCompletionTokenDetails()
instead. -
getCompletionTokenDetails
-
toString
-
getCompletionTokenDetails()
instead.