Request Body
string
required
ID of the model to use (e.g.,
gpt-4, claude-3-5-sonnet, gemini-2.0-flash)array
required
A list of messages comprising the conversation so far.
boolean
default:"false"
If set to
true, partial message deltas will be sent as server-sent events.object
Options for streaming responses.
number
default:"1"
Sampling temperature between 0 and 2. Higher values make output more random.
integer
Maximum number of tokens to generate in the completion.
integer
An upper bound for the number of tokens that can be generated.
string | array
Up to 4 sequences where the API will stop generating tokens.
number
default:"0"
Number between -2.0 and 2.0. Positive values penalize new tokens based on presence in text.
number
default:"0"
Number between -2.0 and 2.0. Positive values penalize new tokens based on frequency in text.
array
A list of tools the model may call.
string | object
Controls which tool is called.
auto lets the model decide, none prevents tool calls, or specify a tool.boolean
default:"true"
Whether to enable parallel function calling during tool use.
object
Specify the output format.
string
For reasoning models, controls the effort level:
low, medium, or high.Response
string
A unique identifier for the chat completion.
string
The object type, always
chat.completion.integer
Unix timestamp of when the completion was created.
string
The model used for completion.
array
A list of chat completion choices.
object
Token usage statistics.
Examples
Basic Completion
Streaming
Function Calling
Vision (Multimodal)
JSON Mode
Response Example
Streaming Response
Whenstream: true, responses are sent as server-sent events:
