Send text to POST /v1/chat/completions. Use model and messages.
Create a completion
curl -X POST 'https://redrouter.org/v1/chat/completions' \
-H "Authorization: Bearer $REDROUTER_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"messages": [
{
"content": "Hello",
"role": "user"
}
],
"model": "glm-5.3-flash-rr"
}'
import os, json
from urllib.request import Request, urlopen
body = json.loads(r'''{
"messages": [
{
"content": "Hello",
"role": "user"
}
],
"model": "glm-5.3-flash-rr"
}''')
request = Request(
"https://redrouter.org/v1/chat/completions",
method="POST",
data=json.dumps(body).encode(),
headers={
"Authorization": "Bearer " + os.environ["REDROUTER_API_KEY"],
"Content-Type": "application/json",
},
)
with urlopen(request) as response:
print(json.load(response))
const key = process.env.REDROUTER_API_KEY;
const response = await fetch("https://redrouter.org/v1/chat/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${key}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"messages": [
{
"content": "Hello",
"role": "user"
}
],
"model": "glm-5.3-flash-rr"
}),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
Choose parameters
Accepted fields for the selected model:
model, messages, stream, stream_options, max_tokens, max_completion_tokens, temperature, top_p, stop, presence_penalty, frequency_penalty, seed, tools, tool_choice, parallel_tool_calls, response_format, user, reasoning_effort, reasoning, enable_thinking, thinking, thinking_budget, chat_template_kwargs, output_config
Send max_tokens or max_completion_tokens. Send one, not both. The default output limit comes from the catalog.
Messages accept system, developer, user, assistant, and tool roles. Content is text or text blocks. Images and audio are unsupported.
Agents can send back earlier responses unchanged. Null fields count as absent. Assistant messages may have null content. Text parts may carry cache_control, which is ignored because caching is automatic.
Assistant messages can replay reasoning as reasoning_content, reasoning, or reasoning_details. The first one present is used. Replayed text is forwarded to the model and counts toward the input budget. Encrypted reasoning details are dropped. refusal and annotations are accepted and ignored.
Reasoning controls (reasoning_effort, reasoning, enable_thinking, thinking, thinking_budget, chat_template_kwargs, and output_config) are accepted and ignored on current models. They do not enable a reasoning budget or change model selection. Use response_format for structured output on models that advertise it.
Chat Completions accepts up to 4,096 messages within the request-body and model limits. Unknown parameters still return 400.
Read the response
Read choices[0].message.content. Usage contains token counts when reported; otherwise usage is null while billing reconciles.
See the request and response schemas.