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 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

      public com.azure.json.JsonWriter toJson(com.azure.json.JsonWriter jsonWriter) throws IOException
      Specified by:
      toJson in interface com.azure.json.JsonSerializable<CompletionsUsage>
      Throws:
      IOException
    • fromJson

      public static CompletionsUsage fromJson(com.azure.json.JsonReader jsonReader) throws IOException
      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

      public CompletionsUsagePromptTokensDetails getPromptTokensDetails()
      Get the promptTokensDetails property: Details of the prompt tokens.
      Returns:
      the promptTokensDetails value.
    • getCompletionTokensDetails

      public CompletionsUsageCompletionTokensDetails getCompletionTokensDetails()
      Get the completionTokensDetails property: Breakdown of tokens used in a completion.
      Returns:
      the completionTokensDetails value.