Compartilhar via


CompletionsUsage Class

  • java.lang.Object
    • com.azure.ai.openai.models.CompletionsUsage

Implements

public final class CompletionsUsage
implements 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 Type Method and Description
static CompletionsUsage fromJson(JsonReader jsonReader)

Reads an instance of CompletionsUsage from the JsonReader.

int getCompletionTokens()

Get the completionTokens property: The number of tokens generated across all completions emissions.

CompletionsUsageCompletionTokensDetails getCompletionTokensDetails()

Get the completionTokensDetails property: Breakdown of tokens used in a completion.

int getPromptTokens()

Get the promptTokens property: The number of tokens in the provided prompts for the completions request.

CompletionsUsagePromptTokensDetails getPromptTokensDetails()

Get the promptTokensDetails property: Details of the prompt tokens.

int getTotalTokens()

Get the totalTokens property: The total number of tokens processed for the completions request and response.

JsonWriter toJson(JsonWriter jsonWriter)

Methods inherited from java.lang.Object

Method Details

fromJson

public static CompletionsUsage fromJson(JsonReader jsonReader)

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:

IOException

- If the deserialized JSON object was missing any required properties.

getCompletionTokens

public int getCompletionTokens()

Get the completionTokens property: The number of tokens generated across all completions emissions.

Returns:

the completionTokens value.

getCompletionTokensDetails

public CompletionsUsageCompletionTokensDetails getCompletionTokensDetails()

Get the completionTokensDetails property: Breakdown of tokens used in a completion.

Returns:

the completionTokensDetails 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.

getPromptTokensDetails

public CompletionsUsagePromptTokensDetails getPromptTokensDetails()

Get the promptTokensDetails property: Details of the prompt tokens.

Returns:

the promptTokensDetails 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 JsonWriter toJson(JsonWriter jsonWriter)

Parameters:

jsonWriter

Throws:

Applies to