Skip to content
  • Auto
  • Light
  • Dark
Log in to API

Chat

Chat

Chat

Completion Message
CompletionMessage

A message containing the model's (assistant) response in a chat conversation.

ShowShow
role"assistant"

Must be "assistant" to identify this as the model's response

Hide ParametersShow Parameters
"assistant"
contentunion
optional
string | textstringtype"text"MessageTextContentItem

The content of the model's response.

Hide ParametersShow Parameters
string
textstringtype"text"MessageTextContentItem
stop_reasonunion
optional
"stop" | "tool_calls" | "length"

The reason why we stopped. Options are: - "stop": The model reached a natural stopping point. - "tool_calls": The model finished generating and invoked a tool call. - "length": The model reached the maxinum number of tokens specified in the request.

Hide ParametersShow Parameters
"stop"
"tool_calls"
"length"
tool_callsarray
optional
Array<ToolCall>

The tool calls generated by the model, such as function calls.

Hide ParametersShow Parameters
idstring

The ID of the tool call.

functionargumentsstringnamestringFunction

The function that the model called.

Hide ParametersShow Parameters
argumentsstring

The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.

namestring

The name of the function to call.

Create Chat Completion Response
CreateChatCompletionResponse

Response from a chat completion request.

ShowShow
completion_messagerole"assistant"contentunionstop_reasonuniontool_callsarrayCompletionMessage

The complete response message

idstring
optional

The unique identifier of the chat completion request.

metricsarray
optional
Array<Metric>
Hide ParametersShow Parameters
metricstring
valuenumber
unitstring
optional
Create Chat Completion Response Stream Chunk
CreateChatCompletionResponseStreamChunk

A chunk of a streamed chat completion response.

ShowShow
eventdeltaunionevent_typeunionmetricsarraystop_reasonunionEvent

The event containing the new content

Hide ParametersShow Parameters
deltaunion
textstringtype"text"TextDelta | functionFunctiontype"tool_call"idstringToolCallDelta

Content generated since last event. This can be one or more tokens, or a tool call.

Hide ParametersShow Parameters
TextDelta
Hide ParametersShow Parameters
textstring
type"text"
Hide ParametersShow Parameters
"text"
ToolCallDelta
Hide ParametersShow Parameters
functionargumentsstringnamestringFunction
Hide ParametersShow Parameters
argumentsstring
optional

The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.

namestring
optional

The name of the function to call.

type"tool_call"
Hide ParametersShow Parameters
"tool_call"
idstring
optional

The ID of the tool call.

event_typeunion
"start" | "complete" | "progress" | "metrics"

Type of the event

Hide ParametersShow Parameters
"start"
"complete"
"progress"
"metrics"
metricsarray
optional
Array<Metric>
Hide ParametersShow Parameters
metricstring
valuenumber
unitstring
optional
stop_reasonunion
optional
"stop" | "tool_calls" | "length"

The reason why we stopped. Options are: - "stop": The model reached a natural stopping point. - "tool_calls": The model finished generating and invoked a tool call. - "length": The model reached the maxinum number of tokens specified in the request.

Hide ParametersShow Parameters
"stop"
"tool_calls"
"length"
idstring
optional

The unique identifier of the chat completion request.

Message
Messagealias
contentunionrole"user"UserMessage | contentunionrole"system"SystemMessage | contentunionrole"tool"tool_call_idstringToolResponseMessage | role"assistant"contentunionstop_reasonuniontool_callsarrayCompletionMessage

A message from the user in a chat conversation.

ShowShow
contentunionrole"user"UserMessage
contentunionrole"system"SystemMessage
contentunionrole"tool"tool_call_idstringToolResponseMessage
role"assistant"contentunionstop_reasonuniontool_callsarrayCompletionMessage
Message Image Content Item
MessageImageContentItem

A image content item

ShowShow
image_urlurlstringImageURL

Contains either an image URL or a data URL for a base64 encoded image.

Hide ParametersShow Parameters
urlstring

Either a URL of the image or the base64 encoded image data.

formaturi
type"image_url"

Discriminator type of the content item. Always "image"

Hide ParametersShow Parameters
"image_url"
Message Text Content Item
MessageTextContentItem

A text content item

ShowShow
textstring

Text content

type"text"

Discriminator type of the content item. Always "text"

Hide ParametersShow Parameters
"text"
System Message
SystemMessage

A system message providing instructions or context to the model.

ShowShow
contentunion
string | Array<textstringtype"text"MessageTextContentItem>

The content of the system message.

Hide ParametersShow Parameters
string
Array<textstringtype"text"MessageTextContentItem>
role"system"

Must be "system" to identify this as a system message

Hide ParametersShow Parameters
"system"
Tool Response Message
ToolResponseMessage

A message representing the result of a tool invocation.

ShowShow
contentunion
string | Array<textstringtype"text"MessageTextContentItem>

The content of the user message, which can include text and other media.

Hide ParametersShow Parameters
string
Array<textstringtype"text"MessageTextContentItem>
role"tool"

Must be "tool" to identify this as a tool response

Hide ParametersShow Parameters
"tool"
tool_call_idstring

Unique identifier for the tool call this response is for

User Message
UserMessage

A message from the user in a chat conversation.

ShowShow
contentunion
string | Array<textstringtype"text"MessageTextContentItem | image_urlImageURLtype"image_url"MessageImageContentItem>

The content of the user message, which can include text and other media.

Hide ParametersShow Parameters
string
Array<textstringtype"text"MessageTextContentItem | image_urlImageURLtype"image_url"MessageImageContentItem>
role"user"

Must be "user" to identify this as a user message.

Hide ParametersShow Parameters
"user"

ChatCompletions

Create
client.chat.completions.create(CompletionCreateParamsbody, RequestOptionsoptions?): completion_messageCompletionMessageidstringmetricsarrayCreateChatCompletionResponse | Stream<eventEventidstringCreateChatCompletionResponseStreamChunk>
post/chat/completions