Chat
ChatCompletions
Given a list of messages comprising a conversation, the model will return a response.
Create chat completion
Delete chat completion
List Chat Completions
Get chat completion
Update chat completion
Models
ChatCompletionAllowedTools object { mode, tools } Constrains the tools available to the model to a pre-defined set.
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.
Represents a chat completion response returned by model, based on the provided input.
ChatCompletionAssistantMessageParam object { role, audio, content, 4 more } Messages sent by the model in response to user messages.
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.
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.
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.
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.
Learn about text inputs.
ChatCompletionContentPartImage object { image_url, type, prompt_cache_breakpoint } Learn about image inputs.
Learn about image inputs.
ChatCompletionContentPartInputAudio object { input_audio, type, prompt_cache_breakpoint } Learn about audio inputs.
Learn about audio inputs.
ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint } Learn about text inputs.
Learn about text inputs.
ChatCompletionCustomTool object { custom, type } A custom tool that processes input using a specified format.
A custom tool that processes input using a specified format.
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.
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.
ChatCompletionMessage object { content, role, annotations, 4 more } A chat completion message generated by the model.
A chat completion message generated by the model.
ChatCompletionMessageCustomToolCall object { id, custom, type } A call to a custom tool created by the model.
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.
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 moreDeveloper-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.
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.
A call to a function tool created by the model.
ChatCompletionPredictionContent object { content, type } Static predicted output content, such as the content of a text file that is
being regenerated.
Static predicted output content, such as the content of a text file that is being regenerated.
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.
Options for streaming response. Only set this when you set stream: true.
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.
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.
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.
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.
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.
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.