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

Chat

ChatCompletions

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

Create chat completion
chat.completions.create(**kwargs) -> ChatCompletion { id, choices, created, 7 more }
POST/chat/completions
Delete chat completion
chat.completions.delete(completion_id) -> ChatCompletionDeleted { id, deleted, object }
DELETE/chat/completions/{completion_id}
List Chat Completions
chat.completions.list(**kwargs) -> CursorPage<ChatCompletion { id, choices, created, 7 more } >
GET/chat/completions
Get chat completion
chat.completions.retrieve(completion_id) -> ChatCompletion { id, choices, created, 7 more }
GET/chat/completions/{completion_id}
Update chat completion
chat.completions.update(completion_id, **kwargs) -> ChatCompletion { id, choices, created, 7 more }
POST/chat/completions/{completion_id}
ModelsExpand Collapse
class ChatCompletionAllowedTools { mode, tools }

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

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

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

class ChatCompletionAllowedToolChoice { allowed_tools, type }

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

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

Messages sent by the model in response to user messages.

class ChatCompletionAudio { 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.

class ChatCompletionAudioParam { format_, voice }

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

class ChatCompletionChunk { 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 } | ChatCompletionContentPartImage { image_url, type, prompt_cache_breakpoint } | ChatCompletionContentPartInputAudio { input_audio, type, prompt_cache_breakpoint } | File{ file, type, prompt_cache_breakpoint}

Learn about text inputs.

class ChatCompletionContentPartImage { image_url, type, prompt_cache_breakpoint }

Learn about image inputs.

class ChatCompletionContentPartInputAudio { input_audio, type, prompt_cache_breakpoint }

Learn about audio inputs.

class ChatCompletionContentPartRefusal { refusal, type }
class ChatCompletionContentPartText { text, type, prompt_cache_breakpoint }

Learn about text inputs.

class ChatCompletionCustomTool { custom, type }

A custom tool that processes input using a specified format.

class ChatCompletionDeleted { id, deleted, object }
class ChatCompletionDeveloperMessageParam { 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.

class ChatCompletionFunctionCallOption { name }

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

class ChatCompletionFunctionMessageParam { content, name, role }
class ChatCompletionFunctionTool { function, type }

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

class ChatCompletionMessage { content, refusal, role, 4 more }

A chat completion message generated by the model.

class ChatCompletionMessageCustomToolCall { id, custom, type }

A call to a custom tool created by the model.

class ChatCompletionMessageFunctionToolCall { id, function, type }

A call to a function tool created by the model.

ChatCompletionMessageParam = ChatCompletionDeveloperMessageParam { content, role, name } | ChatCompletionSystemMessageParam { content, role, name } | ChatCompletionUserMessageParam { content, role, name } | 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 } | ChatCompletionMessageCustomToolCall { id, custom, type }

A call to a function tool created by the model.

ChatCompletionModality = :text | :audio
class ChatCompletionNamedToolChoice { function, type }

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

class ChatCompletionNamedToolChoiceCustom { custom, type }

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

class ChatCompletionPredictionContent { content, type }

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

ChatCompletionRole = :developer | :system | :user | 3 more

The role of the author of a message

class ChatCompletionStoreMessage { id, content_parts }

A chat completion message generated by the model.

class ChatCompletionStreamOptions { include_obfuscation, include_usage }

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

class ChatCompletionSystemMessageParam { 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.

class ChatCompletionTokenLogprob { token, bytes, logprob, top_logprobs }
ChatCompletionTool = ChatCompletionFunctionTool { function, type } | ChatCompletionCustomTool { custom, type }

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

ChatCompletionToolChoiceOption = :none | :auto | :required | ChatCompletionAllowedToolChoice { allowed_tools, type } | ChatCompletionNamedToolChoice { function, type } | 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.

class ChatCompletionToolMessageParam { content, role, tool_call_id }
class ChatCompletionUserMessageParam { 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
chat.completions.messages.list(completion_id, **kwargs) -> CursorPage<ChatCompletionStoreMessage { id, content_parts } >
GET/chat/completions/{completion_id}/messages