Chat (original) (raw)

ModelsExpand Collapse

ChatCompletion = object { id, choices, created, 5 more }

Represents a chat completion response returned by model, based on the provided input.

id: string

A unique identifier for the chat completion.

choices: array of object { finish_reason, index, logprobs, message }

A list of chat completion choices. Can be more than one if n is greater than 1.

finish_reason: "stop" or "length" or "tool_calls" or 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.

index: number

The index of the choice in the list of choices.

logprobs: object { content, refusal }

Log probability information for the choice.

A list of message content tokens with log probability information.

bytes: array of number

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 of object { token, bytes, logprob }

List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested top_logprobs returned.

bytes: array of number

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.

A list of message refusal tokens with log probability information.

bytes: array of number

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 of object { token, bytes, logprob }

List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested top_logprobs returned.

bytes: array of number

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.

A chat completion message generated by the model.

created: number

The Unix timestamp (in seconds) of when the chat completion was created.

model: string

The model used for the chat completion.

object: "chat.completion"

The object type, which is always chat.completion.

service_tier: optional "auto" or "default" or "flex" or 2 more

Specifies the processing type used for serving the request.

When the service_tier parameter is set, the response body will include the service_tier value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.

Deprecatedsystem_fingerprint: optional string

This fingerprint represents the backend configuration that the model runs with.

Can be used in conjunction with the seed request parameter to understand when backend changes have been made that might impact determinism.

usage: optional CompletionUsage { completion_tokens, prompt_tokens, total_tokens, 2 more }

Usage statistics for the completion request.

ChatCompletionAssistantMessageParam = object { role, audio, content, 4 more }

Messages sent by the model in response to user messages.

role: "assistant"

The role of the messages author, in this case assistant.

audio: optional object { id }

Data about a previous audio response from the model.Learn more.

id: string

Unique identifier for a previous audio response from the model.

The contents of the assistant message. Required unless tool_calls or function_call is specified.

One of the following:

TextContent = string

The contents of the assistant message.

An array of content parts with a defined type. Can be one or more of type text, or exactly one of type refusal.

One of the following:

ChatCompletionContentPartText = object { text, type }

type: "text"

The type of the content part.

ChatCompletionContentPartRefusal = object { refusal, type }

refusal: string

The refusal message generated by the model.

type: "refusal"

The type of the content part.

Deprecatedfunction_call: optional object { arguments, name }

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.

name: optional string

An optional name for the participant. Provides the model information to differentiate between participants of the same role.

refusal: optional string

The refusal message by the assistant.

ChatCompletionAudio = object { id, data, expires_at, transcript }

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.

transcript: string

Transcript of the audio generated by the model.

ChatCompletionAudioParam = object { format, voice }

Parameters for audio output. Required when audio output is requested withmodalities: ["audio"]. Learn more.

format: "wav" or "aac" or "mp3" or 3 more

Specifies the output audio format. Must be one of wav, mp3, flac,opus, or pcm16.

voice: string or "alloy" or "ash" or "ballad" or 7 more or object { id }

The voice the model uses to respond. Supported built-in voices arealloy, ash, ballad, coral, echo, fable, nova, onyx,sage, shimmer, marin, and cedar. You may also provide a custom voice object with an id, for example { "id": "voice_1234" }.

One of the following:

"alloy" or "ash" or "ballad" or 7 more

id: string

The custom voice ID, e.g. voice_1234.

ChatCompletionChunk = object { id, choices, created, 5 more }

Represents a streamed chunk of a chat completion response returned by the model, based on the provided input. Learn more.

id: string

A unique identifier for the chat completion. Each chunk has the same ID.

choices: array of object { delta, finish_reason, index, logprobs }

A list of chat completion choices. Can contain more than one elements if n is greater than 1. Can also be empty for the last chunk if you set stream_options: {"include_usage": true}.

delta: object { content, function_call, refusal, 2 more }

A chat completion delta generated by streamed model responses.

content: optional string

The contents of the chunk message.

Deprecatedfunction_call: optional object { arguments, name }

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

arguments: optional 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: optional string

The name of the function to call.

refusal: optional string

The refusal message generated by the model.

role: optional "developer" or "system" or "user" or 2 more

The role of the author of this message.

finish_reason: "stop" or "length" or "tool_calls" or 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.

index: number

The index of the choice in the list of choices.

logprobs: optional object { content, refusal }

Log probability information for the choice.

A list of message content tokens with log probability information.

bytes: array of number

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 of object { token, bytes, logprob }

List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested top_logprobs returned.

bytes: array of number

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.

A list of message refusal tokens with log probability information.

bytes: array of number

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 of object { token, bytes, logprob }

List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested top_logprobs returned.

bytes: array of number

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.

created: number

The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp.

model: string

The model to generate the completion.

object: "chat.completion.chunk"

The object type, which is always chat.completion.chunk.

service_tier: optional "auto" or "default" or "flex" or 2 more

Specifies the processing type used for serving the request.

When the service_tier parameter is set, the response body will include the service_tier value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.

Deprecatedsystem_fingerprint: optional string

This fingerprint represents the backend configuration that the model runs with. Can be used in conjunction with the seed request parameter to understand when backend changes have been made that might impact determinism.

usage: optional CompletionUsage { completion_tokens, prompt_tokens, total_tokens, 2 more }

An optional field that will only be present when you setstream_options: {"include_usage": true} in your request. When present, it contains a null value except for the last chunk which contains the token usage statistics for the entire request.

NOTE: If the stream is interrupted or cancelled, you may not receive the final usage chunk which contains the total token usage for the request.

One of the following:

ChatCompletionContentPartText = object { text, type }

type: "text"

The type of the content part.

ChatCompletionContentPartImage = object { image_url, type }

image_url: object { url, detail }

url: string

Either a URL of the image or the base64 encoded image data.

detail: optional "auto" or "low" or "high"

Specifies the detail level of the image. Learn more in the Vision guide.

type: "image_url"

The type of the content part.

ChatCompletionContentPartInputAudio = object { input_audio, type }

input_audio: object { data, format }

data: string

Base64 encoded audio data.

format: "wav" or "mp3"

The format of the encoded audio data. Currently supports "wav" and "mp3".

type: "input_audio"

The type of the content part. Always input_audio.

FileContentPart = object { file, type }

file: object { file_data, file_id, filename }

file_data: optional string

The base64 encoded file data, used when passing the file to the model as a string.

file_id: optional string

The ID of an uploaded file to use as input.

filename: optional string

The name of the file, used when passing the file to the model as a string.

type: "file"

The type of the content part. Always file.

ChatCompletionContentPartImage = object { image_url, type }

image_url: object { url, detail }

url: string

Either a URL of the image or the base64 encoded image data.

detail: optional "auto" or "low" or "high"

Specifies the detail level of the image. Learn more in the Vision guide.

type: "image_url"

The type of the content part.

ChatCompletionContentPartInputAudio = object { input_audio, type }

input_audio: object { data, format }

data: string

Base64 encoded audio data.

format: "wav" or "mp3"

The format of the encoded audio data. Currently supports "wav" and "mp3".

type: "input_audio"

The type of the content part. Always input_audio.

ChatCompletionContentPartRefusal = object { refusal, type }

refusal: string

The refusal message generated by the model.

type: "refusal"

The type of the content part.

ChatCompletionContentPartText = object { text, type }

type: "text"

The type of the content part.

ChatCompletionDeleted = object { id, deleted, object }

id: string

The ID of the chat completion that was deleted.

deleted: boolean

Whether the chat completion was deleted.

object: "chat.completion.deleted"

The type of object being deleted.

ChatCompletionDeveloperMessageParam = object { content, role, name }

Developer-provided instructions that the model should follow, regardless of messages sent by the user. With o1 models and newer, developer messages replace the previous system messages.

The contents of the developer message.

One of the following:

TextContent = string

The contents of the developer message.

An array of content parts with a defined type. For developer messages, only type text is supported.

type: "text"

The type of the content part.

role: "developer"

The role of the messages author, in this case developer.

name: optional string

An optional name for the participant. Provides the model information to differentiate between participants of the same role.

ChatCompletionFunctionCallOption = object { name }

Specifying a particular function via {"name": "my_function"} forces the model to call that function.

name: string

The name of the function to call.

ChatCompletionFunctionMessageParam = object { content, name, role }

content: string

The contents of the function message.

name: string

The name of the function to call.

role: "function"

The role of the messages author, in this case function.

ChatCompletionMessage = object { content, refusal, role, 4 more }

A chat completion message generated by the model.

content: string

The contents of the message.

refusal: string

The refusal message generated by the model.

role: "assistant"

The role of the author of this message.

annotations: optional array of object { type, url_citation }

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

type: "url_citation"

The type of the URL citation. Always url_citation.

url_citation: object { 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.

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

Deprecatedfunction_call: optional object { arguments, name }

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.

Developer-provided instructions that the model should follow, regardless of messages sent by the user. With o1 models and newer, developer messages replace the previous system messages.

One of the following:

ChatCompletionDeveloperMessageParam = object { content, role, name }

Developer-provided instructions that the model should follow, regardless of messages sent by the user. With o1 models and newer, developer messages replace the previous system messages.

The contents of the developer message.

One of the following:

TextContent = string

The contents of the developer message.

An array of content parts with a defined type. For developer messages, only type text is supported.

type: "text"

The type of the content part.

role: "developer"

The role of the messages author, in this case developer.

name: optional string

An optional name for the participant. Provides the model information to differentiate between participants of the same role.

ChatCompletionSystemMessageParam = object { content, role, name }

Developer-provided instructions that the model should follow, regardless of messages sent by the user. With o1 models and newer, use developer messages for this purpose instead.

The contents of the system message.

One of the following:

TextContent = string

The contents of the system message.

An array of content parts with a defined type. For system messages, only type text is supported.

type: "text"

The type of the content part.

role: "system"

The role of the messages author, in this case system.

name: optional string

An optional name for the participant. Provides the model information to differentiate between participants of the same role.

ChatCompletionUserMessageParam = object { content, role, name }

Messages sent by an end user, containing prompts or additional context information.

The contents of the user message.

One of the following:

TextContent = string

The text contents of the message.

An array of content parts with a defined type. Supported options differ based on the model being used to generate the response. Can contain text, image, or audio inputs.

One of the following:

ChatCompletionContentPartText = object { text, type }

type: "text"

The type of the content part.

ChatCompletionContentPartImage = object { image_url, type }

image_url: object { url, detail }

url: string

Either a URL of the image or the base64 encoded image data.

detail: optional "auto" or "low" or "high"

Specifies the detail level of the image. Learn more in the Vision guide.

type: "image_url"

The type of the content part.

ChatCompletionContentPartInputAudio = object { input_audio, type }

input_audio: object { data, format }

data: string

Base64 encoded audio data.

format: "wav" or "mp3"

The format of the encoded audio data. Currently supports "wav" and "mp3".

type: "input_audio"

The type of the content part. Always input_audio.

FileContentPart = object { file, type }

file: object { file_data, file_id, filename }

file_data: optional string

The base64 encoded file data, used when passing the file to the model as a string.

file_id: optional string

The ID of an uploaded file to use as input.

filename: optional string

The name of the file, used when passing the file to the model as a string.

type: "file"

The type of the content part. Always file.

role: "user"

The role of the messages author, in this case user.

name: optional string

An optional name for the participant. Provides the model information to differentiate between participants of the same role.

ChatCompletionAssistantMessageParam = object { role, audio, content, 4 more }

Messages sent by the model in response to user messages.

role: "assistant"

The role of the messages author, in this case assistant.

audio: optional object { id }

Data about a previous audio response from the model.Learn more.

id: string

Unique identifier for a previous audio response from the model.

The contents of the assistant message. Required unless tool_calls or function_call is specified.

One of the following:

TextContent = string

The contents of the assistant message.

An array of content parts with a defined type. Can be one or more of type text, or exactly one of type refusal.

One of the following:

ChatCompletionContentPartText = object { text, type }

type: "text"

The type of the content part.

ChatCompletionContentPartRefusal = object { refusal, type }

refusal: string

The refusal message generated by the model.

type: "refusal"

The type of the content part.

Deprecatedfunction_call: optional object { arguments, name }

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.

name: optional string

An optional name for the participant. Provides the model information to differentiate between participants of the same role.

refusal: optional string

The refusal message by the assistant.

The contents of the tool message.

One of the following:

TextContent = string

The contents of the tool message.

An array of content parts with a defined type. For tool messages, only type text is supported.

type: "text"

The type of the content part.

ChatCompletionFunctionMessageParam = object { content, name, role }

content: string

The contents of the function message.

name: string

The name of the function to call.

role: "function"

The role of the messages author, in this case function.

ChatCompletionModality = "text" or "audio"

ChatCompletionPredictionContent = object { content, type }

Static predicted output content, such as the content of a text file that is being regenerated.

The content that should be matched when generating a model response. If generated tokens would match this content, the entire model response can be returned much more quickly.

One of the following:

TextContent = string

The content used for a Predicted Output. This is often the text of a file you are regenerating with minor changes.

An array of content parts with a defined type. Supported options differ based on the model being used to generate the response. Can contain text inputs.

type: "text"

The type of the content part.

type: "content"

The type of the predicted content you want to provide. This type is currently always content.

ChatCompletionRole = "developer" or "system" or "user" or 3 more

The role of the author of a message

ChatCompletionStoreMessage = ChatCompletionMessage { content, refusal, role, 4 more }

A chat completion message generated by the model.

id: string

The identifier of the chat message.

If a content parts array was provided, this is an array of text and image_url parts. Otherwise, null.

One of the following:

ChatCompletionContentPartText = object { text, type }

type: "text"

The type of the content part.

ChatCompletionContentPartImage = object { image_url, type }

image_url: object { url, detail }

url: string

Either a URL of the image or the base64 encoded image data.

detail: optional "auto" or "low" or "high"

Specifies the detail level of the image. Learn more in the Vision guide.

type: "image_url"

The type of the content part.

ChatCompletionStreamOptions = object { include_obfuscation, include_usage }

Options for streaming response. Only set this when you set stream: true.

include_obfuscation: optional boolean

When true, stream obfuscation will be enabled. Stream obfuscation adds random characters to an obfuscation field on streaming delta events to normalize payload sizes as a mitigation to certain side-channel attacks. These obfuscation fields are included by default, but add a small amount of overhead to the data stream. You can set include_obfuscation to false to optimize for bandwidth if you trust the network links between your application and the OpenAI API.

include_usage: optional boolean

If set, an additional chunk will be streamed before the data: [DONE]message. The usage field on this chunk shows the token usage statistics for the entire request, and the choices field will always be an empty array.

All other chunks will also include a usage field, but with a null value. NOTE: If the stream is interrupted, you may not receive the final usage chunk which contains the total token usage for the request.

ChatCompletionSystemMessageParam = object { content, role, name }

Developer-provided instructions that the model should follow, regardless of messages sent by the user. With o1 models and newer, use developer messages for this purpose instead.

The contents of the system message.

One of the following:

TextContent = string

The contents of the system message.

An array of content parts with a defined type. For system messages, only type text is supported.

type: "text"

The type of the content part.

role: "system"

The role of the messages author, in this case system.

name: optional string

An optional name for the participant. Provides the model information to differentiate between participants of the same role.

ChatCompletionTokenLogprob = object { token, bytes, logprob, top_logprobs }

bytes: array of number

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 of object { token, bytes, logprob }

List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested top_logprobs returned.

bytes: array of number

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.

The contents of the tool message.

One of the following:

TextContent = string

The contents of the tool message.

An array of content parts with a defined type. For tool messages, only type text is supported.

type: "text"

The type of the content part.

ChatCompletionUserMessageParam = object { content, role, name }

Messages sent by an end user, containing prompts or additional context information.

The contents of the user message.

One of the following:

TextContent = string

The text contents of the message.

An array of content parts with a defined type. Supported options differ based on the model being used to generate the response. Can contain text, image, or audio inputs.

One of the following:

ChatCompletionContentPartText = object { text, type }

type: "text"

The type of the content part.

ChatCompletionContentPartImage = object { image_url, type }

image_url: object { url, detail }

url: string

Either a URL of the image or the base64 encoded image data.

detail: optional "auto" or "low" or "high"

Specifies the detail level of the image. Learn more in the Vision guide.

type: "image_url"

The type of the content part.

ChatCompletionContentPartInputAudio = object { input_audio, type }

input_audio: object { data, format }

data: string

Base64 encoded audio data.

format: "wav" or "mp3"

The format of the encoded audio data. Currently supports "wav" and "mp3".

type: "input_audio"

The type of the content part. Always input_audio.

FileContentPart = object { file, type }

file: object { file_data, file_id, filename }

file_data: optional string

The base64 encoded file data, used when passing the file to the model as a string.

file_id: optional string

The ID of an uploaded file to use as input.

filename: optional string

The name of the file, used when passing the file to the model as a string.

type: "file"

The type of the content part. Always file.

role: "user"

The role of the messages author, in this case user.

name: optional string

An optional name for the participant. Provides the model information to differentiate between participants of the same role.