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
ChatCompletion chat().completions().create(ChatCompletionCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/chat/completions
Delete chat completion
ChatCompletionDeleted chat().completions().delete(ChatCompletionDeleteParamsparams = ChatCompletionDeleteParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
DELETE/chat/completions/{completion_id}
List Chat Completions
ChatCompletionListPage chat().completions().list(ChatCompletionListParamsparams = ChatCompletionListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
GET/chat/completions
Get chat completion
ChatCompletion chat().completions().retrieve(ChatCompletionRetrieveParamsparams = ChatCompletionRetrieveParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
GET/chat/completions/{completion_id}
Update chat completion
ChatCompletion chat().completions().update(ChatCompletionUpdateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
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 ChatCompletionContentPart: A class that can be one of several variants.union

Learn about text inputs.

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.

class ChatCompletionMessageParam: A class that can be one of several variants.union

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 ChatCompletionMessageToolCall: A class that can be one of several variants.union

A call to a function tool created by the model.

enum ChatCompletionModality:
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.

enum ChatCompletionRole:

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:
class ChatCompletionTool: A class that can be one of several variants.union

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

class ChatCompletionToolChoiceOption: A class that can be one of several variants.union

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.

ChatCompletionsMessages

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

Get chat messages
MessageListPage chat().completions().messages().list(MessageListParamsparams = MessageListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
GET/chat/completions/{completion_id}/messages