/v1/chat/completionsAPI key (Bearer mr-…)Create chat completion
OpenAI-compatible chat completion. Streaming (SSE), tool calling, vision (image_url content blocks), and JSON mode all supported. The full body schema mirrors OpenAI's /v1/chat/completions — see https://platform.openai.com/docs/api-reference/chat/create for every field. The router accepts and forwards unknown fields with extra="allow".
| Name | In | Type | Description |
|---|---|---|---|
| model* | body | string | Model slug, e.g. "qwen/qwen3.7-max" or bare "qwen3.6-plus". Append ":<provider>" to pin a provider, e.g. "qwen/qwen3-max:alibaba". |
| messages* | body | array | Standard OpenAI messages array. `content` may be a string or a list of {type:"text"|"image_url", …} blocks for vision-capable models. |
| stream | body | boolean | Stream the response as SSE chunks. Default false. |
| temperature | body | number | 0–2. Default 1.0. |
| top_p | body | number | Nucleus sampling. Default 1.0. |
| top_k | body | number | Forwarded to providers that support it (e.g. Alibaba). Ignored otherwise. |
| max_tokens | body | number | Cap on completion tokens. |
| stop | body | string | string[] | Up to 4 stop sequences. |
| frequency_penalty | body | number | −2.0 to 2.0. |
| presence_penalty | body | number | −2.0 to 2.0. |
| repetition_penalty | body | number | Alibaba-specific; forwarded when present. |
| response_format | body | object | { "type": "json_object" } enables JSON mode where supported. |
| tools | body | array | OpenAI tool/function-calling schema. |
| tool_choice | body | string | object | "auto" | "none" | {type:"function", function:{name}} |
| seed | body | number | Forwarded to providers that honor it. |
| user | body | string | Opaque end-user id for abuse tracking. |
curl https://api.magicrouter.ai/chat/completions \
-H "Authorization: Bearer mr-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen/qwen3.7-max",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": false
}'{
"id": "chatcmpl-…",
"object": "chat.completion",
"created": 1747400000,
"model": "qwen/qwen3.7-max",
"choices": [{
"index": 0,
"message": {"role": "assistant", "content": "Hello! How can I help?"},
"finish_reason": "stop"
}],
"usage": {"prompt_tokens": 9, "completion_tokens": 8, "total_tokens": 17}
}