Skip to main content
POST

Authorizations

Authorization
string
header
required

Authenticate with an API key using Bearer authentication. Do not expose real keys in documentation, code, or repositories.

Body

application/json

Chat generation request body. model and messages are required. Configure other parameters for your task and the capabilities of the selected model.

model
string
required

ID of the model to generate the reply. Use GET /models to list models, then check the model details to confirm Chat Completions support.

Example:

"Qwen/Qwen3.6-27B"

messages
object[]
required

Messages in conversation order, with at least one message. For multi-turn conversations, include the history you want to retain.

Minimum array length: 1
max_completion_tokens
integer

Total token budget for this generation, including reasoning tokens and visible output tokens. Must be at least 1; the model determines the maximum.

A small budget can result in empty or truncated output, especially with reasoning models. Use finish_reason and usage to adjust the budget.

This is the recommended parameter. Existing requests can continue to use max_tokens for compatibility. If both are provided, this parameter takes precedence.

Required range: x >= 1
Example:

1024

temperature
number
default:1

Sampling temperature, which adjusts output randomness. Lower values generally produce more focused output; higher values generally produce more varied output. 0 does not guarantee identical output, and some models support only the default value.

Required range: 0 <= x <= 2
top_p
number
default:1

Nucleus sampling threshold. Samples from candidate tokens whose cumulative probability reaches this value. Lower values generally narrow the candidate set. Adjust either this parameter or temperature, not both.

Required range: x <= 1
seed
integer

Sampling seed, which can improve reproducibility across repeated requests. Identical parameters do not guarantee identical output. Support varies by model.

n
integer
default:1

Number of candidate replies to generate for this request. Support and maximum count vary by model.

Required range: x >= 1
stream
boolean
default:false

Whether to stream output. When true, receive incremental content through SSE. When false, receive a complete JSON response.

stream_options
object

Streaming options. Use only when stream=true.

stop

Stop sequence, either one string or an array of up to four strings. When supported, the model stops generating after encountering a stop sequence. Support varies by model. Use max_completion_tokens to limit generation length.

tools
object[]

Tools available for the model to call. Only function tools (type=function) are currently supported. Tool definitions count as input tokens. The client executes tools after the model returns call information.

tool_choice
default:auto

Controls tool selection.

  • none: Generate a reply without calling tools.
  • auto: Let the model choose whether to reply or call tools.
  • required: Require a tool call.
  • A function object: Require a specific function, such as {"type":"function","function":{"name":"get_weather"}}.

Provide the corresponding function definitions in tools when using tool calls.

Available options:
none,
auto,
required
parallel_tool_calls
boolean
default:true

Whether the model may request multiple tool calls in one reply. Applies only when tools are used and the model supports parallel calls. Does not control how the client executes tools.

response_format
object

Output format: plain text, a JSON object, or structured content conforming to a JSON Schema. Support varies by model. For JSON output, also specify the output requirements in the messages and validate the result on the client.

reasoning_effort
enum<string>

Requested reasoning effort. Support and defaults vary by model. Acceptance of this parameter alone does not establish that it took effect.

Available options:
minimal,
low,
medium,
high
user
string

End-user identifier for usage attribution. Do not include sensitive personal information.

service_tier
enum<string>
default:auto

Service-tier compatibility field. Do not rely on this parameter to obtain different response speeds or prices.

Available options:
auto,
default,
flex,
priority
store
boolean
default:false

Response-storage compatibility field. This API does not provide retrieval of historical responses by response ID. Do not use this parameter as a persistence mechanism.

metadata
object

Metadata compatibility field, provided as string key-value pairs. Do not rely on this field being echoed back or available for later retrieval.

presence_penalty
number
default:0

Presence penalty, which adjusts the likelihood of generating tokens that have already appeared. Positive values generally discourage recurrence; negative values generally encourage it. Whether it takes effect varies by model.

Required range: -2 <= x <= 2
frequency_penalty
number
default:0

Frequency penalty, which adjusts how often previously generated tokens are repeated. Positive values generally reduce repetition; negative values generally increase it. Whether it takes effect varies by model.

Required range: -2 <= x <= 2
logprobs
boolean
default:false
required if top_logprobs is set

Whether to return output token log probabilities. Supported by some models only; the response field may also be null.

Example:

true

top_logprobs
integer

Number of highest-probability candidate tokens to return at each output position. Requires logprobs=true and a model that supports this capability.

Required range: 0 <= x <= 20
Example:

2

web_search_options
object

Web-search options compatibility field. Providing this field does not establish that web search is enabled.

Response

Request successful. Non-streaming responses return JSON. Streaming responses return text/event-stream, with each data chunk prefixed by data:. The data: [DONE] marker ends the stream. The examples below illustrate the format; content, usage, and optional fields depend on the actual response.

Non-streaming chat completion response.

id
string
required

Identifier for this generation response. Format varies by model or service; do not parse it based on a fixed prefix.

object
enum<string>
required

Response object type, set to chat.completion.

Available options:
chat.completion
created
integer
required

Response creation time as a Unix timestamp in seconds.

model
string
required

Identifier of the model used for this generation.

choices
object[]
required

Candidate replies. Each entry contains a message and the reason generation ended.

usage
object

Token usage for this request, combined across candidate replies.

system_fingerprint
string

System configuration identifier returned by the service. May be an empty string.

service_tier
string

Tier identifier returned by the service. Does not imply additional performance or pricing commitments.