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.

int getPromptTokens()

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

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.

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

Parameters:

jsonWriter

Throws:

Applies to