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

Chat

Chat

Chat

Completion Message
CompletionMessagestruct

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

ShowShow
RoleAssistantAssistantAssistantAssistant

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

Hide ParametersShow Parameters
AssistantAssistantconst
AssistantAssistantAssistantAssistant
"assistant"
ContentMessageTextContentItemstruct{…}CompletionMessageContentUnion
optional

The content of the model's response.

Hide ParametersShow Parameters
string
MessageTextContentItemstruct

A text content item

Hide ParametersShow Parameters
Textstring

Text content

Discriminator type of the content item. Always "text"

Hide ParametersShow Parameters
MessageTextContentItemTypeTextconst
"text"
StopReasonCompletionMessageStopReasonStopCompletionMessageStopReasonCompletionMessageStopReasonToolCallsCompletionMessageStopReasonCompletionMessageStopReasonLengthCompletionMessageStopReasonCompletionMessageStopReason
optional

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
CompletionMessageStopReasonStopconst
CompletionMessageStopReasonStopCompletionMessageStopReasonCompletionMessageStopReasonToolCallsCompletionMessageStopReasonCompletionMessageStopReasonLengthCompletionMessageStopReasonCompletionMessageStopReason
"stop"
CompletionMessageStopReasonToolCallsconst
CompletionMessageStopReasonStopCompletionMessageStopReasonCompletionMessageStopReasonToolCallsCompletionMessageStopReasonCompletionMessageStopReasonLengthCompletionMessageStopReasonCompletionMessageStopReason
"tool_calls"
CompletionMessageStopReasonLengthconst
CompletionMessageStopReasonStopCompletionMessageStopReasonCompletionMessageStopReasonToolCallsCompletionMessageStopReasonCompletionMessageStopReasonLengthCompletionMessageStopReasonCompletionMessageStopReason
"length"
ToolCallsarray
optional

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

Hide ParametersShow Parameters
IDstring

The ID of the tool call.

FunctionArgumentsstringNamestringCompletionMessageToolCallFunction

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
CreateChatCompletionResponsestruct

Response from a chat completion request.

ShowShow

The complete response message

IDstring
optional

The unique identifier of the chat completion request.

Hide ParametersShow Parameters
Metricstring
Valuefloat64
Unitstring
optional
Create Chat Completion Response Stream Chunk
CreateChatCompletionResponseStreamChunkstruct

A chunk of a streamed chat completion response.

ShowShow

The event containing the new content

Hide ParametersShow Parameters
DeltaCreateChatCompletionResponseStreamChunkEventDeltaTextstruct{…}CreateChatCompletionResponseStreamChunkEventDeltaToolCallstruct{…}CreateChatCompletionResponseStreamChunkEventDeltaUnion

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

Hide ParametersShow Parameters
CreateChatCompletionResponseStreamChunkEventDeltaTextstruct
Hide ParametersShow Parameters
Textstring
TypeTextTextTextText
Hide ParametersShow Parameters
TextTextconst
TextTextTextText
"text"
CreateChatCompletionResponseStreamChunkEventDeltaToolCallstruct
Hide ParametersShow Parameters
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.

TypeToolCallToolCallToolCallToolCall
Hide ParametersShow Parameters
ToolCallToolCallconst
ToolCallToolCallToolCallToolCall
"tool_call"
IDstring
optional

The ID of the tool call.

EventTypestring

Type of the event

Hide ParametersShow Parameters
CreateChatCompletionResponseStreamChunkEventEventTypeStartconst
CreateChatCompletionResponseStreamChunkEventEventTypeStartCreateChatCompletionResponseStreamChunkEventEventTypeCreateChatCompletionResponseStreamChunkEventEventTypeCompleteCreateChatCompletionResponseStreamChunkEventEventTypeCreateChatCompletionResponseStreamChunkEventEventTypeProgressCreateChatCompletionResponseStreamChunkEventEventTypeCreateChatCompletionResponseStreamChunkEventEventTypeMetricsCreateChatCompletionResponseStreamChunkEventEventTypeCreateChatCompletionResponseStreamChunkEventEventType
"start"
CreateChatCompletionResponseStreamChunkEventEventTypeCompleteconst
CreateChatCompletionResponseStreamChunkEventEventTypeStartCreateChatCompletionResponseStreamChunkEventEventTypeCreateChatCompletionResponseStreamChunkEventEventTypeCompleteCreateChatCompletionResponseStreamChunkEventEventTypeCreateChatCompletionResponseStreamChunkEventEventTypeProgressCreateChatCompletionResponseStreamChunkEventEventTypeCreateChatCompletionResponseStreamChunkEventEventTypeMetricsCreateChatCompletionResponseStreamChunkEventEventTypeCreateChatCompletionResponseStreamChunkEventEventType
"complete"
CreateChatCompletionResponseStreamChunkEventEventTypeProgressconst
CreateChatCompletionResponseStreamChunkEventEventTypeStartCreateChatCompletionResponseStreamChunkEventEventTypeCreateChatCompletionResponseStreamChunkEventEventTypeCompleteCreateChatCompletionResponseStreamChunkEventEventTypeCreateChatCompletionResponseStreamChunkEventEventTypeProgressCreateChatCompletionResponseStreamChunkEventEventTypeCreateChatCompletionResponseStreamChunkEventEventTypeMetricsCreateChatCompletionResponseStreamChunkEventEventTypeCreateChatCompletionResponseStreamChunkEventEventType
"progress"
CreateChatCompletionResponseStreamChunkEventEventTypeMetricsconst
CreateChatCompletionResponseStreamChunkEventEventTypeStartCreateChatCompletionResponseStreamChunkEventEventTypeCreateChatCompletionResponseStreamChunkEventEventTypeCompleteCreateChatCompletionResponseStreamChunkEventEventTypeCreateChatCompletionResponseStreamChunkEventEventTypeProgressCreateChatCompletionResponseStreamChunkEventEventTypeCreateChatCompletionResponseStreamChunkEventEventTypeMetricsCreateChatCompletionResponseStreamChunkEventEventTypeCreateChatCompletionResponseStreamChunkEventEventType
"metrics"
Hide ParametersShow Parameters
Metricstring
Valuefloat64
Unitstring
optional
StopReasonstring
optional

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
CreateChatCompletionResponseStreamChunkEventStopReasonStopconst
CreateChatCompletionResponseStreamChunkEventStopReasonStopCreateChatCompletionResponseStreamChunkEventStopReasonCreateChatCompletionResponseStreamChunkEventStopReasonToolCallsCreateChatCompletionResponseStreamChunkEventStopReasonCreateChatCompletionResponseStreamChunkEventStopReasonLengthCreateChatCompletionResponseStreamChunkEventStopReasonCreateChatCompletionResponseStreamChunkEventStopReason
"stop"
CreateChatCompletionResponseStreamChunkEventStopReasonToolCallsconst
CreateChatCompletionResponseStreamChunkEventStopReasonStopCreateChatCompletionResponseStreamChunkEventStopReasonCreateChatCompletionResponseStreamChunkEventStopReasonToolCallsCreateChatCompletionResponseStreamChunkEventStopReasonCreateChatCompletionResponseStreamChunkEventStopReasonLengthCreateChatCompletionResponseStreamChunkEventStopReasonCreateChatCompletionResponseStreamChunkEventStopReason
"tool_calls"
CreateChatCompletionResponseStreamChunkEventStopReasonLengthconst
CreateChatCompletionResponseStreamChunkEventStopReasonStopCreateChatCompletionResponseStreamChunkEventStopReasonCreateChatCompletionResponseStreamChunkEventStopReasonToolCallsCreateChatCompletionResponseStreamChunkEventStopReasonCreateChatCompletionResponseStreamChunkEventStopReasonLengthCreateChatCompletionResponseStreamChunkEventStopReasonCreateChatCompletionResponseStreamChunkEventStopReason
"length"
IDstring
optional

The unique identifier of the chat completion request.

Message
MessageUnioninterface

A message from the user in a chat conversation.

ShowShow
CompletionMessagestruct

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

Hide ParametersShow Parameters
RoleAssistantAssistantAssistantAssistant

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

Hide ParametersShow Parameters
AssistantAssistantconst
AssistantAssistantAssistantAssistant
"assistant"
ContentMessageTextContentItemstruct{…}CompletionMessageContentUnion
optional

The content of the model's response.

Hide ParametersShow Parameters
string
MessageTextContentItemstruct

A text content item

Hide ParametersShow Parameters
Textstring

Text content

Discriminator type of the content item. Always "text"

Hide ParametersShow Parameters
MessageTextContentItemTypeTextconst
"text"
StopReasonCompletionMessageStopReasonStopCompletionMessageStopReasonCompletionMessageStopReasonToolCallsCompletionMessageStopReasonCompletionMessageStopReasonLengthCompletionMessageStopReasonCompletionMessageStopReason
optional

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
CompletionMessageStopReasonStopconst
CompletionMessageStopReasonStopCompletionMessageStopReasonCompletionMessageStopReasonToolCallsCompletionMessageStopReasonCompletionMessageStopReasonLengthCompletionMessageStopReasonCompletionMessageStopReason
"stop"
CompletionMessageStopReasonToolCallsconst
CompletionMessageStopReasonStopCompletionMessageStopReasonCompletionMessageStopReasonToolCallsCompletionMessageStopReasonCompletionMessageStopReasonLengthCompletionMessageStopReasonCompletionMessageStopReason
"tool_calls"
CompletionMessageStopReasonLengthconst
CompletionMessageStopReasonStopCompletionMessageStopReasonCompletionMessageStopReasonToolCallsCompletionMessageStopReasonCompletionMessageStopReasonLengthCompletionMessageStopReasonCompletionMessageStopReason
"length"
ToolCallsarray
optional

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

Hide ParametersShow Parameters
IDstring

The ID of the tool call.

FunctionArgumentsstringNamestringCompletionMessageToolCallFunction

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.

Message Image Content Item
MessageImageContentItemstruct

A image content item

ShowShow

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
TypeMessageImageContentItemTypeImageURLMessageImageContentItemTypeMessageImageContentItemType

Discriminator type of the content item. Always "image"

Hide ParametersShow Parameters
MessageImageContentItemTypeImageURLconst
"image_url"
Message Text Content Item
MessageTextContentItemstruct

A text content item

ShowShow
Textstring

Text content

Discriminator type of the content item. Always "text"

Hide ParametersShow Parameters
MessageTextContentItemTypeTextconst
"text"
System Message
SystemMessagestruct

A system message providing instructions or context to the model.

ShowShow

The content of the system message.

Hide ParametersShow Parameters
RoleSystemSystemSystemSystem

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

Hide ParametersShow Parameters
SystemSystemconst
SystemSystemSystemSystem
"system"
Tool Response Message
ToolResponseMessagestruct

A message representing the result of a tool invocation.

ShowShow

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

Hide ParametersShow Parameters
RoleToolToolToolTool

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

Hide ParametersShow Parameters
ToolToolconst
ToolToolToolTool
"tool"
ToolCallIDstring

Unique identifier for the tool call this response is for

User Message
UserMessagestruct

A message from the user in a chat conversation.

ShowShow

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

Hide ParametersShow Parameters
RoleUserMessageRoleUserUserMessageRoleUserMessageRole

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

Hide ParametersShow Parameters
UserMessageRoleUserconst
"user"

ChatCompletions

Create
client.Chat.Completions.New(ctx, body) (*CompletionMessageCompletionMessageIDstringMetricsarrayCreateChatCompletionResponse, error)
post/chat/completions