Skip to content
SupportLogin
Completions

Completions

Create a chat completion
POST/api/v1/chat/completions
ModelsExpand Collapse
ChatCompletion object { id, object, created, 4 more }
id: string
object: "chat.completion"
created: number

Unix time in seconds.

model: string
system_fingerprint: optional string
choices: array of object { index, finish_reason, message }
index: 0
finish_reason: "stop" or "length" or "tool_calls" or 2 more
One of the following:
"stop"
"length"
"tool_calls"
"content_filter"
"function_call"
message: ChatCompletionMessage { role, content, refusal, 2 more }
role: "assistant"
content: string
refusal: optional string
reasoning_content: optional string

The model’s reasoning, for models that reason.

tool_calls: optional array of object { id, type, function }
id: string
type: "function"
function: object { name, arguments }
name: string
minLength1
maxLength64
arguments: string

The arguments as a JSON-encoded string.

usage: ChatCompletionUsage { prompt_tokens, completion_tokens, total_tokens, 2 more }
prompt_tokens: number
completion_tokens: number
total_tokens: number
prompt_tokens_details: optional object { cached_tokens, audio_tokens }
cached_tokens: optional number
audio_tokens: optional number
completion_tokens_details: optional object { reasoning_tokens, audio_tokens, accepted_prediction_tokens, rejected_prediction_tokens }
reasoning_tokens: optional number
audio_tokens: optional number
accepted_prediction_tokens: optional number
rejected_prediction_tokens: optional number
ChatCompletionChunk object { id, object, created, 4 more }
id: string
object: "chat.completion.chunk"
created: number

Unix time in seconds.

model: string
system_fingerprint: optional string
choices: array of object { index, finish_reason, delta }

Empty on the final usage chunk.

index: 0
finish_reason: "stop" or "length" or "tool_calls" or 2 more
One of the following:
"stop"
"length"
"tool_calls"
"content_filter"
"function_call"
delta: object { role, content, refusal, 2 more }
role: optional "assistant"
content: optional string
refusal: optional string
reasoning_content: optional string
tool_calls: optional array of object { index, id, type, function }
index: number
id: optional string
type: optional "function"
function: optional object { name, arguments }
name: optional string
arguments: optional string

The next piece of the arguments.

usage: optional ChatCompletionUsage { prompt_tokens, completion_tokens, total_tokens, 2 more }

Set on the final chunk when stream_options.include_usage is true.

prompt_tokens: number
completion_tokens: number
total_tokens: number
prompt_tokens_details: optional object { cached_tokens, audio_tokens }
cached_tokens: optional number
audio_tokens: optional number
completion_tokens_details: optional object { reasoning_tokens, audio_tokens, accepted_prediction_tokens, rejected_prediction_tokens }
reasoning_tokens: optional number
audio_tokens: optional number
accepted_prediction_tokens: optional number
rejected_prediction_tokens: optional number
ChatCompletionError object { error }
error: object { message, type, code, param }
message: string
type: string
code: string
param: string
ChatCompletionMessage object { role, content, refusal, 2 more }
role: "assistant"
content: string
refusal: optional string
reasoning_content: optional string

The model’s reasoning, for models that reason.

tool_calls: optional array of object { id, type, function }
id: string
type: "function"
function: object { name, arguments }
name: string
minLength1
maxLength64
arguments: string

The arguments as a JSON-encoded string.

ChatCompletionUsage object { prompt_tokens, completion_tokens, total_tokens, 2 more }
prompt_tokens: number
completion_tokens: number
total_tokens: number
prompt_tokens_details: optional object { cached_tokens, audio_tokens }
cached_tokens: optional number
audio_tokens: optional number
completion_tokens_details: optional object { reasoning_tokens, audio_tokens, accepted_prediction_tokens, rejected_prediction_tokens }
reasoning_tokens: optional number
audio_tokens: optional number
accepted_prediction_tokens: optional number
rejected_prediction_tokens: optional number