/v1/chat/completionsMessage roles
Each object in the "messages" array has a "role" that defines who is speaking.
systemSets the behavior and personality of the assistant.
userThe human message input.
assistantThe AI response. Used for conversation history.
toolResponse from a tool/function call.
Parameters
modelstringRequiredThe model ID to use. See /docs/models for available models.
Example: "qwen3.8-max"messagesarrayRequiredArray of message objects. Each has a "role" (system, user, assistant, tool) and "content".
Example: [{"role":"user","content":"Hi"}]streambooleanOptionalIf true, the response is streamed via server-sent events. Default: false.
Example: truetemperaturenumberOptionalSampling temperature between 0 and 2. Higher values = more random. Default: 1.
Example: 0.7max_tokensintegerOptionalMaximum tokens to generate in the response.
Example: 1024toolsarrayOptionalArray of tool definitions in OpenAI function-calling format.
Example: [{"type":"function","function":{...}}]tool_choicestring | objectOptional"auto", "none", or {"type":"function","function":{"name":"..."}} to force a specific tool.
Example: "auto"enable_thinkingbooleanOptionalIf true, skips the reasoning/thinking step on models that support it (e.g., DeepSeek R1).
Example: truesizestringOptionalAspect ratio for image/video generation models (e.g., "1024x1024", "16:9").
Example: "1024x1024"watermarkboolean | stringOptionalfalse removes the watermark from image models. A string replaces the default watermark text.
Example: falseResponse format
The response follows the standard OpenAI format. The "usage" field contains actual token counts reported by the model.
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1700000000,
"model": "qwen3.8-max",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "A closure is a function that retains access to variables from its enclosing scope..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 248,
"total_tokens": 260
}
}choices[0].message.content— The response text.choices[0].finish_reason— "stop" if completed normally, "length" if hit max_tokens.usage.total_tokens— Total tokens consumed (prompt + completion).