Api
Chat Completions
Request parameters, message structure, examples, and successful responses for POST /v1/chat/completions.
Given a list of messages, the model returns a chat completion. The endpoint supports non-streaming responses, streaming output, and tool calling when the selected model supports it.
POST /v1/chat/completions
Request headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer YOUR_APIQIK_API_KEY |
Content-Type | Yes | application/json |
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID, such as qwen-turbo or deepseek-chat. |
messages | array | Yes | Chronologically ordered messages. |
temperature | number | No | Sampling randomness; supported range depends on the model. |
max_tokens | integer | No | Maximum generated tokens, also subject to the context window. |
stream | boolean | No | Set to true for incremental streaming output. |
stop | string or array | No | Stop at specified text when supported by the model. |
tools | array | No | Tool definitions available to the model. |
tool_choice | string or object | No | Control whether and how tools are selected. |
response_format | object | No | Request structured output such as JSON when supported. |
Message fields
| Field | Type | Required | Description |
|---|---|---|---|
role | string | Yes | Common values: system, user, assistant, tool. |
content | string or array | Role-dependent | Text is usually a string; multimodal content depends on model support. |
tool_calls | array | No | Calls the assistant proposes for application execution. |
tool_call_id | string | For tool messages | ID of the call that produced this result. |
Request example
{
"model": "qwen-turbo",
"messages": [
{
"role": "system",
"content": "You are a concise, reliable assistant."
},
{
"role": "user",
"content": "Explain intelligent API routing."
}
],
"temperature": 0.7,
"max_tokens": 512,
"stream": false
}Successful response
{
"id": "chatcmpl-apiqik-7f3a2c9e",
"object": "chat.completion",
"created": 1789987200,
"model": "qwen-turbo",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Intelligent API routing automatically selects an appropriate inference path based on node health."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 27,
"total_tokens": 51
}
}Response fields
| Field | Type | Description |
|---|---|---|
id | string | Unique generation identifier; retain it for diagnostics. |
object | string | Usually chat.completion for non-streaming responses. |
created | integer | Creation time as a Unix timestamp. |
model | string | Model identifier for the response. |
choices | array | Candidate results; ordinary requests read the first item. |
choices[].message | object | Assistant message containing text or tool calls. |
finish_reason | string or null | Stop reason, such as stop, length, or tool_calls. |
usage | object | Input, output, and total token usage. |