Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation
Theme

Chat

ChatCompletions

Given a list of messages comprising a conversation, the model will return a response.

Create chat completion
POST
/chat/completions
Delete chat completion
DELETE
/chat/completions/{completion_id}
List Chat Completions
GET
/chat/completions
Get chat completion
GET
/chat/completions/{completion_id}
Update chat completion
POST
/chat/completions/{completion_id}
Models
ChatCompletionAllowedTools object { mode, tools }

Constrains the tools available to the model to a pre-defined set.

ChatCompletion object { id, choices, created, 7 more }

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

ChatCompletionAllowedToolChoice object { allowed_tools, type }

Constrains the tools available to the model to a pre-defined set.

allowed_tools: ChatCompletionAllowedTools { mode, tools }

Constrains the tools available to the model to a pre-defined set.

type: "allowed_tools"

Allowed tool configuration type. Always allowed_tools.

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

Messages sent by the model in response to user messages.

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.

ChatCompletionAudioParam object { format, voice }

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

ChatCompletionChunk object { id, choices, created, 7 more }

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

ChatCompletionContentPart = ChatCompletionContentPartText { text, type, prompt_cache_breakpoint } or ChatCompletionContentPartImage { image_url, type, prompt_cache_breakpoint } or ChatCompletionContentPartInputAudio { input_audio, type, prompt_cache_breakpoint } or FileContentPart { file, type, prompt_cache_breakpoint }

Learn about text inputs.

ChatCompletionContentPartImage object { image_url, type, prompt_cache_breakpoint }

Learn about image inputs.

ChatCompletionContentPartInputAudio object { input_audio, type, prompt_cache_breakpoint }

Learn about audio inputs.

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, prompt_cache_breakpoint }

Learn about text inputs.

ChatCompletionCustomTool object { custom, type }

A custom tool that processes input using a specified format.

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.

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

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.

ChatCompletionFunctionTool object { function, type }

A function tool that can be used to generate a response.

function: FunctionDefinition { name, description, parameters, strict }
type: "function"

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

ChatCompletionMessage object { content, role, annotations, 4 more }

A chat completion message generated by the model.

ChatCompletionMessageCustomToolCall object { id, custom, type }

A call to a custom tool created by the model.

ChatCompletionMessageFunctionToolCall object { id, function, type }

A call to a function tool created by the model.

ChatCompletionMessageParam = ChatCompletionDeveloperMessageParam { content, role, name } or ChatCompletionSystemMessageParam { content, role, name } or ChatCompletionUserMessageParam { content, role, name } or 3 more

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.

ChatCompletionMessageToolCall = ChatCompletionMessageFunctionToolCall { id, function, type } or ChatCompletionMessageCustomToolCall { id, custom, type }

A call to a function tool created by the model.

ChatCompletionModality = "text" or "audio"
One of the following:
"text"
"audio"
ChatCompletionNamedToolChoice object { function, type }

Specifies a tool the model should use. Use to force the model to call a specific function.

ChatCompletionNamedToolChoiceCustom object { custom, type }

Specifies a tool the model should use. Use to force the model to call a specific custom tool.

ChatCompletionPredictionContent object { content, type }

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

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

The role of the author of a message

ChatCompletionStoreMessage object { id, content, content_parts, 2 more }
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.

ChatCompletionTokenLogprob object { token, bytes, logprob, top_logprobs }
ChatCompletionTool = ChatCompletionFunctionTool { function, type } or ChatCompletionCustomTool { custom, type }

A function tool that can be used to generate a response.

ChatCompletionToolChoiceOption = "none" or "auto" or "required" or ChatCompletionAllowedToolChoice { allowed_tools, type } or ChatCompletionNamedToolChoice { function, type } or ChatCompletionNamedToolChoiceCustom { custom, type }

Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {"type": "function", "function": {"name": "my_function"}} forces the model to call that tool.

none is the default when no tools are present. auto is the default if tools are present.

ChatCompletionToolMessageParam object { content, role, tool_call_id }
ChatCompletionUserMessageParam object { content, role, name }

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

ChatCompletionsMessages

Given a list of messages comprising a conversation, the model will return a response.

Get chat messages
GET
/chat/completions/{completion_id}/messages