Chat completions schemas

The full schema and model definitions referenced by the Create a chat completion endpoint, including the request and response object shapes.

Schemas

Chat Completion Message Tool Call

A function tool call emitted by the model.

FieldTypeRequiredDescription
idstringYesIdentifier for this tool call.
typeenum ('function')YesTool type; always function.
functionobjectYesThe function the model chose to call.
function.namestringYesName of the function to call.
function.argumentsstringYesCall arguments the model generated, as a JSON string. The model can emit invalid JSON or arguments outside your schema, so validate before invoking the function.

Chat Completion Message Tool Call Chunk

FieldTypeRequiredDescription
indexintegerYes
idstringNoIdentifier for this tool call.
typeenum ('function')NoTool type; always function.
functionobjectNo
function.namestringNoName of the function to call.
function.argumentsstringNoFunction arguments generated by the model, as a JSON string. The model can produce invalid JSON or arguments outside your schema, so validate before executing.

Chat Completion Message Tool Calls

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

Type: array of ChatCompletionMessageToolCall

Chat Completion Request Assistant Message

An assistant message holding a previous model response in the conversation.

FieldTypeRequiredDescription
contentstring | array of ChatCompletionRequestAssistantMessageContentPart | nullNo
refusalstring | nullNo
reasoning_contentstring | nullNo
reasoningstring | nullNo
roleenum ('assistant')YesRole of the message author; always assistant.
namestringNoOptional name for this participant, used to distinguish participants that share a role.
tool_callsChatCompletionMessageToolCallsNo

Chat Completion Request Assistant Message Content Part

Type: ChatCompletionRequestMessageContentPartText | ChatCompletionRequestMessageContentPartRefusal

Chat Completion Request Developer Message

Developer-provided instructions that the model should follow, regardless of messages sent by the user. developer messages take precedence over system messages.

FieldTypeRequiredDescription
contentstring | array of ChatCompletionRequestMessageContentPartTextYesDeveloper message content.
roleenum ('developer')YesRole of the message author; always developer.
namestringNoOptional name for this participant, used to distinguish participants that share a role.

Chat Completion Request Message

Type: ChatCompletionRequestDeveloperMessage | ChatCompletionRequestSystemMessage | ChatCompletionRequestUserMessage | ChatCompletionRequestAssistantMessage | ChatCompletionRequestToolMessage

Chat Completion Request Message Content Part Audio

Audio input content for a message.

FieldTypeRequiredDescription
typeenum ('input_audio')YesThe type of the content part. Always input_audio.
input_audioobjectNo
input_audio.datastringYesBase64 encoded audio data.
input_audio.formatenum ('wav', 'mp3')YesThe format of the encoded audio data. Currently supports "wav" and "mp3".
audio_urlstringNoURL of the audio to send to the model. Fully qualified URL or base64-encoded data URL.
file_idstringNoIdentifier for the uploaded audio file to send to the model.

Chat Completion Request Message Content Part File

File input content for a message.

FieldTypeRequiredDescription
typeenum ('file')YesContent-part type; always file.
fileobjectYes
file.filenamestringNoFilename to associate with file data passed inline.
file.file_datastringNoBase64-encoded file contents passed inline.
file.file_idstringNoIdentifier of an uploaded file to use as input.

Chat Completion Request Message Content Part Image

Image input content for a message.

FieldTypeRequiredDescription
typeenum ('image_url')YesContent-part type; always image_url.
image_urlobjectYes
image_url.urlstring (uri)YesPublic URL or base64 data URL of the image.
image_url.detailenum ('auto', 'low', 'high')NoSpecifies the detail level of the image. (default: auto)

Chat Completion Request Message Content Part Refusal

FieldTypeRequiredDescription
typeenum ('refusal')YesContent-part type; always refusal.
refusalstringYesRefusal message generated by the model.

Chat Completion Request Message Content Part Text

Text input content for a message.

FieldTypeRequiredDescription
typeenum ('text')YesContent-part type; always text.
textstringYesText of this content part.

Chat Completion Request Message Content Part Video

A video input to the model. Provided as a URL or a base64 data URI.

FieldTypeRequiredDescription
typeenum ('video_url')YesThe type of the content part.
video_urlobjectYes
video_url.urlstring (uri)YesEither a URL of the video or the base64 encoded video data.
video_url.fpsnumber | nullNo

Chat Completion Request System Message

Instructions that the model should follow, regardless of messages sent by the user. developer messages take precedence over system messages.

FieldTypeRequiredDescription
contentstring | array of ChatCompletionRequestSystemMessageContentPartYesSystem message content.
roleenum ('system')YesRole of the message author; always system.
namestringNoOptional name for this participant, used to distinguish participants that share a role.

Chat Completion Request System Message Content Part

Type: ChatCompletionRequestMessageContentPartText

Chat Completion Request Tool Message

FieldTypeRequiredDescription
roleenum ('tool')YesRole of the message author; always tool.
contentstring | array of ChatCompletionRequestToolMessageContentPartYesTool message content carrying the result of a tool call.
tool_call_idstringYesIdentifier of the tool call this message responds to.

Chat Completion Request Tool Message Content Part

Type: ChatCompletionRequestMessageContentPartText

Chat Completion Request User Message

A user message carrying end-user input such as a prompt or additional context.

FieldTypeRequiredDescription
contentstring | array of ChatCompletionRequestUserMessageContentPartYesUser message content.
roleenum ('user')YesRole of the message author; always user.
namestringNoOptional name for this participant, used to distinguish participants that share a role.

Chat Completion Request User Message Content Part

Type: ChatCompletionRequestMessageContentPartText | ChatCompletionRequestMessageContentPartImage | ChatCompletionRequestMessageContentPartAudio | ChatCompletionRequestMessageContentPartFile | ChatCompletionRequestMessageContentPartVideo

Chat Completion Response Message

The message the model generated for a choice.

FieldTypeRequiredDescription
contentstring | nullYes
refusalstring | nullYes
tool_callsChatCompletionMessageToolCallsNo
annotationsarray of objectNoAnnotations for the message, when applicable, as when using the web search tool.
annotations[].typeenum ('url_citation')YesAnnotation type; always url_citation.
annotations[].url_citationobjectYesDetails of a web source cited by the model.
annotations[].url_citation.end_indexintegerYesCharacter offset in the message content where the cited span ends.
annotations[].url_citation.start_indexintegerYesCharacter offset in the message content where the cited span begins.
annotations[].url_citation.urlstring (uri)YesURL of the cited source.
annotations[].url_citation.titlestringYesTitle of the cited source.
reasoning_contentstring | nullNo
roleenum ('assistant')YesRole of the message author.

Chat Completion Stream Options

Type: object | null

Chat Completion Stream Response Delta

An incremental message delta from a streamed completion.

FieldTypeRequiredDescription
contentstring | nullNo
reasoning_contentstring | nullNo
tool_callsarray of ChatCompletionMessageToolCallChunkNo
roleenum ('developer', 'system', 'user', 'assistant', 'tool')NoRole of the message author.
refusalstring | nullNo

Chat Completion Token Logprob

FieldTypeRequiredDescription
tokenstringYesA single text token.
logprobnumberYesLog probability of this token. Tokens outside the top 20 report -9999.0.
bytesarray of integer | nullYes
top_logprobsarray of objectYesList of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested top_logprobs returned.
top_logprobs[].tokenstringYesA candidate text token.
top_logprobs[].logprobnumberYesLog probability of this token. Tokens outside the top 20 report -9999.0.
top_logprobs[].bytesarray of integer | nullYes

Chat Completion Tool

A function the model can call.

FieldTypeRequiredDescription
typeenum ('function')YesTool type; always function.
functionFunctionObjectYes

Chat Completion Tool Choice Option

auto lets the model choose between replying with a message and making one or more tool calls. Defaults to auto when tools are supplied.

Type: enum ('auto')

Completion Usage

Token usage for the request.

FieldTypeRequiredDescription
completion_tokensintegerYesTokens in the generated completion. (default: 0)
prompt_tokensintegerYesTokens in the prompt. (default: 0)
total_tokensintegerYesTotal tokens used, prompt plus completion. (default: 0)
completion_tokens_detailsobjectNoBreakdown of the completion tokens.
completion_tokens_details.reasoning_tokensintegerNoTokens the model spent on reasoning. (default: 0)
prompt_tokens_detailsobjectNoBreakdown of the prompt tokens.
prompt_tokens_details.cached_tokensintegerNoPrompt tokens served from cache. (default: 0)

Create Chat Completion Request

FieldTypeRequiredDescription
metadataMetadataNo
top_logprobsintegerNoAn integer between 0 and 20 giving the number of top alternative tokens to return at each position, each with its log probability. Requires logprobs: true. (minimum: 0, maximum: 20)
temperaturenumber | nullNo
top_pnumber | nullNo
userstringNoBeing replaced by safety_identifier and prompt_cache_key; use prompt_cache_key to retain caching benefits. A stable end-user identifier used to improve cache hit rates and help detect abuse.
safety_identifierstringNoA stable identifier that helps detect users who may be violating usage policies. Use a string that uniquely identifies each user, up to 64 characters; hash a username or email so you do not send identifying information. (maxLength: 64)
prompt_cache_keystringNoGroups similar requests to improve cache hit rates. Replaces the user field.
service_tierServiceTierNo
prompt_cache_retentionenum ('in_memory', '24h') | nullNo
messagesarray of ChatCompletionRequestMessageYesAn ordered list of the messages in the conversation. Each message has a role and content, and the model reads them in sequence to produce its reply. (minItems: 1)
modelstringYesID of the model used to generate the response.
modalitiesResponseModalitiesNo
reasoning_effortReasoningEffortNo
max_completion_tokensintegerNoUpper bound on the tokens the model may generate for a completion, counting both visible output and reasoning tokens.
frequency_penaltynumberNoPenalizes tokens in proportion to how often they have already appeared, reducing verbatim repetition. Ranges from -2.0 to 2.0; positive values discourage repetition. (minimum: -2, maximum: 2, default: 0)
presence_penaltynumberNoPenalizes tokens that have already appeared at all, nudging the model toward new topics. Ranges from -2.0 to 2.0; positive values increase that push. (minimum: -2, maximum: 2, default: 0)
response_formatResponseFormatText | ResponseFormatJsonSchema | ResponseFormatJsonObjectNoConstrains the format of the model's output. Use { "type": "json_schema", ... } for Structured Outputs, which forces the response to match your JSON schema, or { "type": "json_object" } for the older JSON mode, which only guarantees valid JSON. Prefer json_schema.
storebooleanNoWhether or not to store the output of this chat completion request for use in our model distillation or evals products. Supports text and image inputs. Note: image inputs over 8MB will be dropped. (default: false)
streambooleanNoWhen true, the response is streamed incrementally as server-sent events(opens in new tab) rather than returned in a single payload. (default: false)
stopStopConfigurationNo
logprobsbooleanNoWhen true, returns the log probability of each token in the message content. (default: false)
max_tokensintegerNoThe maximum number of tokens that can be generated in the chat completion. Deprecated in favor of max_completion_tokens.
nintegerNoNumber of completions to generate for the input. Only n=1 is supported. (minimum: 1, maximum: 128, default: 1)
seedintegerNoIf set, the system makes a best-effort attempt to sample deterministically, so repeated requests with the same seed and parameters return similar results. Determinism is not guaranteed. (minimum: -9223372036854776000, maximum: 9223372036854776000)
stream_optionsChatCompletionStreamOptionsNo
toolsarray of ChatCompletionToolNoA list of tools the model may call. You can provide either custom tools or function tools.
tool_choiceChatCompletionToolChoiceOptionNo
parallel_tool_callsParallelToolCallsNo

Create Chat Completion Response

A chat completion produced by the model for a given request.

FieldTypeRequiredDescription
idstringYesIdentifier for this chat completion.
choicesarray of objectYesList of completion choices. Only one choice is returned; n greater than 1 returns HTTP 400.
choices[].finish_reasonenum ('stop', 'length', 'tool_calls', 'content_filter', 'function_call')YesWhy the model stopped generating tokens: stop for a natural end, length when the output-token limit was reached, and tool_calls when the model requested a tool. content_filter and the deprecated function_call may also appear.
choices[].indexintegerYesIndex of this choice in the choices array.
choices[].messageChatCompletionResponseMessageYes
choices[].logprobsobject | nullYes
createdinteger (unixtime)YesUnix timestamp, in seconds, when the chat completion was created.
modelstringYesID of the model that generated the completion.
service_tierServiceTierNo
system_fingerprintstringNoIdentifies the backend configuration the model ran with, for use with seed to detect determinism-affecting changes. Not currently populated.
objectenum ('chat.completion')YesObject type; always chat.completion.
usageCompletionUsageNo

Create Chat Completion Stream Response

A single streamed chunk of a chat completion, delivered as a server-sent event.

FieldTypeRequiredDescription
idstringYesIdentifier for this chat completion. Identical across every chunk in the stream.
choicesarray of objectYesList of completion choices. Contains a single choice, and is empty on the final chunk when stream_options.include_usage is set.
choices[].deltaChatCompletionStreamResponseDeltaYes
choices[].logprobsobjectNoLog-probability data for this choice.
choices[].logprobs.contentarray of ChatCompletionTokenLogprobYesContent tokens with their log probabilities.
choices[].logprobs.refusalarray of ChatCompletionTokenLogprobYesRefusal tokens with their log probabilities.
choices[].finish_reasonenum ('stop', 'length', 'tool_calls', 'content_filter', 'function_call')YesWhy the model stopped generating tokens: stop for a natural end, length when the output-token limit was reached, and tool_calls when the model requested a tool. content_filter and the deprecated function_call may also appear.
choices[].indexintegerYesIndex of this choice in the choices array.
createdinteger (unixtime)YesUnix timestamp, in seconds, when the chat completion was created. Identical across every chunk in the stream.
modelstringYesID of the model that generated the completion.
service_tierServiceTierNo
system_fingerprintstringNoIdentifies the backend configuration the model ran with, for use with seed to detect determinism-affecting changes. Not currently populated.
objectenum ('chat.completion.chunk')YesObject type; always chat.completion.chunk.
usageCompletionUsageNoToken usage for the entire request. Present only when stream_options.include_usage is set, and populated only on the final chunk; null on all earlier chunks. An interrupted or cancelled stream may omit this chunk.

Create Model Response Properties

FieldTypeRequiredDescription
metadataMetadataNo
top_logprobsintegerNoAn integer between 0 and 20 giving the number of top alternative tokens to return at each position, each with its log probability. (minimum: 0, maximum: 20)
temperaturenumber | nullNo
top_pnumber | nullNo
userstringNoBeing replaced by safety_identifier and prompt_cache_key; use prompt_cache_key to retain caching benefits. A stable end-user identifier used to improve cache hit rates and help detect abuse.
safety_identifierstringNoA stable identifier that helps detect users who may be violating usage policies. Use a string that uniquely identifies each user, up to 64 characters; hash a username or email so you do not send identifying information. (maxLength: 64)
prompt_cache_keystringNoGroups similar requests to improve cache hit rates. Replaces the user field.
service_tierServiceTierNo
prompt_cache_retentionenum ('in_memory', '24h') | nullNo

Function Object

FieldTypeRequiredDescription
descriptionstringNoTells the model what the function does, so it can decide when and how to call it.
namestringYesName of the function to call. May contain letters, digits, underscores, dashes, and at most one dot.
parametersFunctionParametersNo
strictboolean | nullNo

Function Parameters

The parameters the functions accepts, described as a JSON Schema object. See the JSON Schema reference(opens in new tab) for documentation about the format. Omitting parameters defines a function with an empty parameter list.

Type: object

Metadata

Type: object | null

Model Response Properties

FieldTypeRequiredDescription
metadataMetadataNo
top_logprobsinteger | nullNo
temperaturenumber | nullNo
top_pnumber | nullNo
userstringNoBeing replaced by safety_identifier and prompt_cache_key; use prompt_cache_key to retain caching benefits. A stable end-user identifier used to improve cache hit rates and help detect abuse.
safety_identifierstringNoA stable identifier that helps detect users who may be violating usage policies. Use a string that uniquely identifies each user, up to 64 characters; hash a username or email so you do not send identifying information. (maxLength: 64)
prompt_cache_keystringNoGroups similar requests to improve cache hit rates. Replaces the user field.
service_tierServiceTierNo
prompt_cache_retentionenum ('in_memory', '24h') | nullNo

Parallel Tool Calls

Whether to enable parallel function calling during tool use.

Type: boolean

Reasoning Effort

Type: enum ('none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max') | null

Response Format Json Object

JSON mode: forces the output to be valid JSON. Prefer json_schema where supported. The model only emits JSON if a system or user message instructs it to.

FieldTypeRequiredDescription
typeenum ('json_object')YesResponse-format type; always json_object.

Response Format Json Schema

JSON Schema response format. Used to generate structured JSON responses.

FieldTypeRequiredDescription
typeenum ('json_schema')YesResponse-format type; always json_schema.
json_schemaobjectYesStructured Outputs settings, including the JSON Schema to enforce.
json_schema.descriptionstringNoDescribes what the format is for; the model uses it to decide how to respond.
json_schema.namestringYesName of the response format. Allowed characters: a-z, A-Z, 0-9, underscores, and dashes, up to 64 characters.
json_schema.schemaResponseFormatJsonSchemaSchemaNo
json_schema.strictboolean | nullNo

Response Format Json Schema Schema

The response-format schema, expressed as a JSON Schema object. See the JSON Schema reference(opens in new tab) for the format.

Type: object

Response Format Text

Plain-text response format (the default).

FieldTypeRequiredDescription
typeenum ('text')YesResponse-format type; always text.

Response Modalities

Type: array of enum ('text', 'audio') | null

Service Tier

Type: enum ('auto', 'default', 'flex', 'scale', 'priority') | null

Stop Configuration

Not supported with reasoning models. Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.

Type: string | array of string