Package com.azure.ai.openai.models
Class CompletionsUsage
java.lang.Object
com.azure.ai.openai.models.CompletionsUsage
- All Implemented Interfaces:
com.azure.json.JsonSerializable<CompletionsUsage>
public final class CompletionsUsage
extends Object
implements com.azure.json.JsonSerializable<CompletionsUsage>
Representation of the token counts processed for a completions request.
Counts consider all tokens across prompts, choices, choice alternates, best_of generations, and
other consumers.
-
Method Summary
Modifier and TypeMethodDescriptionstatic CompletionsUsagefromJson(com.azure.json.JsonReader jsonReader) Reads an instance of CompletionsUsage from the JsonReader.intGet the completionTokens property: The number of tokens generated across all completions emissions.Get the completionTokensDetails property: Breakdown of tokens used in a completion.intGet the promptTokens property: The number of tokens in the provided prompts for the completions request.Get the promptTokensDetails property: Details of the prompt tokens.intGet the totalTokens property: The total number of tokens processed for the completions request and response.com.azure.json.JsonWritertoJson(com.azure.json.JsonWriter jsonWriter) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.azure.json.JsonSerializable
toJson, toJson, toJsonBytes, toJsonString
-
Method Details
-
getCompletionTokens
public int getCompletionTokens()Get the completionTokens property: The number of tokens generated across all completions emissions.- Returns:
- the completionTokens value.
-
getPromptTokens
public int getPromptTokens()Get the promptTokens property: The number of tokens in the provided prompts for the completions request.- Returns:
- the promptTokens value.
-
getTotalTokens
public int getTotalTokens()Get the totalTokens property: The total number of tokens processed for the completions request and response.- Returns:
- the totalTokens value.
-
toJson
- Specified by:
toJsonin interfacecom.azure.json.JsonSerializable<CompletionsUsage>- Throws:
IOException
-
fromJson
Reads an instance of CompletionsUsage from the JsonReader.- Parameters:
jsonReader- The JsonReader being read.- Returns:
- An instance of CompletionsUsage if the JsonReader was pointing to an instance of it, or null if it was pointing to JSON null.
- Throws:
IllegalStateException- If the deserialized JSON object was missing any required properties.IOException- If an error occurs while reading the CompletionsUsage.
-
getPromptTokensDetails
Get the promptTokensDetails property: Details of the prompt tokens.- Returns:
- the promptTokensDetails value.
-
getCompletionTokensDetails
Get the completionTokensDetails property: Breakdown of tokens used in a completion.- Returns:
- the completionTokensDetails value.
-