Use one OpenAI-compatible Chat Completions endpoint to call models such as Claude and Gemini.
POST /v1/chat/completions
Auth: {'type': 'bearer', 'prefix': 'sk-', 'description': 'Pass your API key in the `Authorization: Bearer sk-xxx` header.'}
Unified chat completion interface, request/response structure identical to OpenAI. Projects using the OpenAI SDK can simply replace `baseURL` to switch. - Supports `stream: true` stream-based push (SSE) - `messages[].content` supports string or multi-modal arrays (text + image URL) - Tool calling (tools/function calling) follows OpenAI specifications
model | string | required | The ID of the model to be called. ⚠️ First call GET /v1/models to retrieve the available list; do not rely on memory — the gateway may not expose the same IDs as upstream providers. IDs must be lowercase, hyphen-separated, and space-free (kimi-k3 instead of Kimi K3) |
messages | array | required | List of conversation messages, each containing role and content. The role can be system / user / assistant / tool. |
role | string | required | |
content | string | required | Message content (string, or a multimodal array `[{"type":"text","text":"..."},{"type":"image_url","image_url":{"url":"..."}}]`) |
name | string | (Optional) Identifier of the message author | |
tool_call_id | string | (Only when role=tool) The corresponding tool_call id | |
stream | boolean | Whether to stream the response. When set to true, the response is pushed in chunks via SSE, suitable for scenarios requiring real-time display during generation. | |
temperature | number | Sampling temperature; higher values produce more diverse outputs, lower values produce more stable ones. ⚠️ Inference models (gpt-5 / o series) only accept the default value; passing other values will not result in errors but will be ignored; other models work normally. | |
max_tokens | integer | Maximum number of tokens to generate in this response. Omitted means the model decides autonomously and will not be truncated. | |
top_p | number | Nucleus sampling, selecting candidates from the top top_p cumulative probability. Only one of temperature or nucleus sampling should be used. ⚠️ Inference models (gpt-5 / o series) do not support this parameter; passing it will not result in errors but will be ignored; other models work normally. | |
tools | array | List of available tools that the model can call. When needed, the model will return tool_calls, which you then execute and feed back as a tool call with role=tool. | |
tool_choice | string | Control whether and how to use tools: auto (model decides), none (disable), or specify a specific tool. Must be used together with tools. | |
response_format | object | Specify the output format, e.g., return in JSON format. | |
stop | array | Stop generation upon encountering any of the specified strings; the strings will not appear in the result. ⚠️ Inference models (gpt-5 / o series) do not support this parameter; passing it will not result in errors but will be ignored; other models work normally. | |
n | integer | Number of candidate responses to return per request. Billing is based on the total token count across all candidates. | |
seed | integer | Fixed random seed; ensures consistent output for the same input. | |
frequency_penalty | number | Reduce the probability of a token reappearing based on its frequency of occurrence; used to suppress repetition. ⚠️ Inference models (gpt-5 / o series) do not support this parameter; passing it will not result in errors but will be ignored; other models work normally. | |
presence_penalty | number | Reduce the probability of a token reappearing based on whether it has already appeared; used to encourage topic switching. ⚠️ Inference models (gpt-5 / o series) do not support this parameter; passing it will not result in errors but will be ignored; other models work normally. | |
logit_bias | object | Adjust the selection probability of a token by its token ID; can be used to strongly promote or suppress specific words. ⚠️ Inference models (gpt-5 / o series) do not support this parameter; passing it will not result in errors but will be ignored; other models work normally. | |
parallel_tool_calls | boolean | Whether to allow the model to return multiple tool calls in one response. Must be used together with tools. | |
logprobs | boolean | Whether to return the log probability of the selected token. ⚠️ Inference models (gpt-5 / o series) do not support this parameter; passing it will not result in errors but will be ignored; other models work normally. | |
top_logprobs | integer | How many additional candidate token probabilities to return per position. Must be enabled together with logprobs. ⚠️ Inference models (gpt-5 / o series) do not support this parameter; passing it will not result in errors but will be ignored; other models work normally. | |
max_completion_tokens | integer | Output token limit (including inference process tokens + visible output tokens). ⚠️ If set too low for inference models, thinking may consume all quota, resulting in empty main text —— in this case finish_reason=length and completion_tokens equals completion_tokens_details.reasoning_tokens. For short responses, reduce reasoning_effort accordingly. Some newer models use this field instead of max_tokens. | |
reasoning_effort | string | Inference strength. ⚠️ Values vary by model; this gateway does not provide a unified list: gpt-5.6 is empirically supported as none / low / medium / high / xhigh (minimal is not supported), other inference models may differ. Passing unsupported values will return 400 from upstream, with error details listing supported values for the model — check and retry accordingly. For short responses without being consumed by thinking, use the lowest supported level (e.g., none fully disables thinking). Only effective for inference models. | |
verbosity | string | Level of detail in the response. | |
modalities | array | Expected output modality, such as text only or text plus audio. Only effective for multimodal models. ⚠️ Inference models (gpt-5 / o series) do not support this parameter; passing it will not cause errors but will have no effect; other models work normally. | |
audio | object | Audio output settings, such as voice tone and audio format. Must include audio in modalities. ⚠️ Inference models (gpt-5 / o series) do not support this parameter; passing it will not cause errors but will have no effect; other models work normally. | |
prediction | object | Output prediction. When most of the response is known, providing this can accelerate generation. ⚠️ Inference models (gpt-5 / o series) do not support this parameter; passing it will not cause errors but will have no effect; other models work normally. | |
stream_options | object | Streaming-related settings, such as whether to include usage statistics at the last frame. Requires stream=true. | |
store | boolean | Whether the conversation is retained on the model service side. | |
metadata | object | Custom key-value pairs, which will be sent along with the request for your own classification and retrieval. | |
user | string | Identifier for the end-user, to help differentiate your user sources. | |
prompt_cache_key | string | Prompt caching key. Requests with the same prefix using the same key are more likely to hit cache, resulting in faster and more efficient retrieval. | |
prompt_cache_retention | string | Duration for which prompt cache is retained. |
200 — Return assistant messagecurl https://api.router.ai/v1/chat/completions \
-H "Authorization: Bearer sk-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"messages": [
{"role": "system", "content": "你是一位资深的技术写作助手"},
{"role": "user", "content": "用三句话介绍 Redis"}
],
"temperature": 0.7,
"max_tokens": 512
}'