finish_reason: "stop" | "length" | "tool_calls" | 2 more

The reason the model stopped generating tokens. This will be stop if the model hit a natural stop point or a provided stop sequence, length if the maximum number of tokens specified in the request was reached, content_filter if content was omitted due to a flag from our content filters, tool_calls if the model called a tool, or function_call (deprecated) if the model called a function. Read the Model Spec for more.

One of the following:
"stop"
"length"
"tool_calls"
"content_filter"
"function_call"
index: number

The index of the choice in the list of choices.

logprobs: Logprobs | null

Log probability information for the choice.

content: Array<ChatCompletionTokenLogprob { token, bytes, logprob, top_logprobs } > | null

A list of message content tokens with log probability information.

token: string

The token.

bytes: Array<number> | null

A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token.

logprob: number

The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value -9999.0 is used to signify that the token is very unlikely.

top_logprobs: Array<TopLogprob>

List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested top_logprobs.

token: string

The token.

bytes: Array<number> | null

A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token.

logprob: number

The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value -9999.0 is used to signify that the token is very unlikely.

refusal: Array<ChatCompletionTokenLogprob { token, bytes, logprob, top_logprobs } > | null

A list of message refusal tokens with log probability information.

token: string

The token.

bytes: Array<number> | null

A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token.

logprob: number

The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value -9999.0 is used to signify that the token is very unlikely.

top_logprobs: Array<TopLogprob>

List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested top_logprobs.

token: string

The token.

bytes: Array<number> | null

A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token.

logprob: number

The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value -9999.0 is used to signify that the token is very unlikely.

message: ChatCompletionMessage { content, refusal, role, 4 more }

A chat completion message generated by the model.

content: string | null

The contents of the message.

refusal: string | null

The refusal message generated by the model.

role: "assistant"

The role of the author of this message.

annotations?: Array<Annotation>

Annotations for the message, when applicable, as when using the web search tool.

type: "url_citation"

The type of the URL citation. Always url_citation.

url_citation: URLCitation { end_index, start_index, title, url }

A URL citation when using web search.

end_index: number

The index of the last character of the URL citation in the message.

start_index: number

The index of the first character of the URL citation in the message.

title: string

The title of the web resource.

url: string

The URL of the web resource.

formaturi
audio?: ChatCompletionAudio { id, data, expires_at, transcript } | null

If the audio output modality is requested, this object contains data about the audio response from the model. Learn more.

id: string

Unique identifier for this audio response.

data: string

Base64 encoded audio bytes generated by the model, in the format specified in the request.

expires_at: number

The Unix timestamp (in seconds) for when this audio response will no longer be accessible on the server for use in multi-turn conversations.

formatunixtime
transcript: string

Transcript of the audio generated by the model.

function_call?: FunctionCall { arguments, name }

Deprecated.

Deprecated and replaced by tool_calls. The name and arguments of a function that should be called, as generated by the model.

arguments: string

The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.

name: string

The name of the function to call.

tool_calls?: Array<ChatCompletionMessageToolCall>

The tool calls generated by the model, such as function calls.

One of the following:
ChatCompletionMessageFunctionToolCall { id, function, type }

A call to a function tool created by the model.

id: string

The ID of the tool call.

function: Function { arguments, name }

The function that the model called.

arguments: string

The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.

name: string

The name of the function to call.

type: "function"

The type of the tool. Currently, only function is supported.

ChatCompletionMessageCustomToolCall { id, custom, type }

A call to a custom tool created by the model.

id: string

The ID of the tool call.

custom: Custom { input, name }

The custom tool that the model called.

input: string

The input for the custom tool call generated by the model.

name: string

The name of the custom tool to call.

type: "custom"

The type of the tool. Always custom.