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
chat.completions.create(CompletionCreateParams**kwargs) -> ChatCompletion
POST/chat/completions
Delete chat completion
chat.completions.delete(strcompletion_id) -> ChatCompletionDeleted
DELETE/chat/completions/{completion_id}
List Chat Completions
chat.completions.list(CompletionListParams**kwargs) -> SyncCursorPage[ChatCompletion]
GET/chat/completions
Get chat completion
chat.completions.retrieve(strcompletion_id) -> ChatCompletion
GET/chat/completions/{completion_id}
Update chat completion
chat.completions.update(strcompletion_id, CompletionUpdateParams**kwargs) -> ChatCompletion
POST/chat/completions/{completion_id}
ModelsExpand Collapse
class ChatCompletionAllowedTools:

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

class ChatCompletion:

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

class ChatCompletionAllowedToolChoice:

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

class ChatCompletionAssistantMessageParam:

Messages sent by the model in response to user messages.

class ChatCompletionAudio:

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

class ChatCompletionAudioParam:

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

class ChatCompletionChunk:

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

class ChatCompletionContentPartImage:

Learn about image inputs.

class ChatCompletionContentPartInputAudio:

Learn about audio inputs.

class ChatCompletionContentPartRefusal:
class ChatCompletionContentPartText:

Learn about text inputs.

class ChatCompletionCustomTool:

A custom tool that processes input using a specified format.

class ChatCompletionDeleted:
class ChatCompletionDeveloperMessageParam:

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:

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

class ChatCompletionFunctionMessageParam:
class ChatCompletionFunctionTool:

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

class ChatCompletionMessage:

A chat completion message generated by the model.

class ChatCompletionMessageCustomToolCall:

A call to a custom tool created by the model.

class ChatCompletionMessageFunctionToolCall:

A call to a function tool created by the model.

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.

A call to a function tool created by the model.

Literal["text", "audio"]
class ChatCompletionNamedToolChoice:

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

class ChatCompletionNamedToolChoiceCustom:

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

class ChatCompletionPredictionContent:

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

Literal["developer", "system", "user", 3 more]

The role of the author of a message

class ChatCompletionStoreMessage:

A chat completion message generated by the model.

class ChatCompletionStreamOptions:

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

class ChatCompletionSystemMessageParam:

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:

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

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:
class ChatCompletionUserMessageParam:

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
chat.completions.messages.list(strcompletion_id, MessageListParams**kwargs) -> SyncCursorPage[ChatCompletionStoreMessage]
GET/chat/completions/{completion_id}/messages