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

Completions

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

Create chat completion
client.chat.completions.create(ChatCompletionCreateParamsbody, RequestOptionsoptions?): ChatCompletion { id, choices, created, 7 more } | Stream<ChatCompletionChunk { id, choices, created, 6 more } >
POST/chat/completions
Delete chat completion
client.chat.completions.delete(stringcompletionID, RequestOptionsoptions?): ChatCompletionDeleted { id, deleted, object }
DELETE/chat/completions/{completion_id}
List Chat Completions
client.chat.completions.list(ChatCompletionListParams { after, limit, metadata, 2 more } query?, RequestOptionsoptions?): CursorPage<ChatCompletion { id, choices, created, 7 more } >
GET/chat/completions
Get chat completion
client.chat.completions.retrieve(stringcompletionID, RequestOptionsoptions?): ChatCompletion { id, choices, created, 7 more }
GET/chat/completions/{completion_id}
Update chat completion
client.chat.completions.update(stringcompletionID, ChatCompletionUpdateParams { metadata } body, RequestOptionsoptions?): ChatCompletion { id, choices, created, 7 more }
POST/chat/completions/{completion_id}
ModelsExpand Collapse
ChatCompletionAllowedTools { mode, tools }

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

ChatCompletion { id, choices, created, 7 more }

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

ChatCompletionAllowedToolChoice { allowed_tools, type }

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

ChatCompletionAssistantMessageParam { role, audio, content, 4 more }

Messages sent by the model in response to user messages.

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.

ChatCompletionAudioParam { format, voice }

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

ChatCompletionChunk { id, choices, created, 6 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.

ChatCompletionContentPartImage { image_url, type, prompt_cache_breakpoint }

Learn about image inputs.

ChatCompletionContentPartInputAudio { input_audio, type, prompt_cache_breakpoint }

Learn about audio inputs.

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

Learn about text inputs.

ChatCompletionCustomTool { custom, type }

A custom tool that processes input using a specified format.

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

ChatCompletionFunctionCallOption { name }

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

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

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

ChatCompletionMessage { content, refusal, role, 4 more }

A chat completion message generated by the model.

ChatCompletionMessageCustomToolCall { id, custom, type }

A call to a custom tool created by the model.

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"
ChatCompletionNamedToolChoice { function, type }

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

ChatCompletionNamedToolChoiceCustom { custom, type }

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

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

ChatCompletionStoreMessage extends ChatCompletionMessage { content, refusal, role, 4 more } { id, content_parts }

A chat completion message generated by the model.

ChatCompletionStreamOptions { include_obfuscation, include_usage }

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

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.

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.

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

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

CompletionsMessages

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

Get chat messages
client.chat.completions.messages.list(stringcompletionID, MessageListParams { after, limit, order } query?, RequestOptionsoptions?): CursorPage<ChatCompletionStoreMessage { id, content_parts } >
GET/chat/completions/{completion_id}/messages