POST /v1/chat/completions
Authentication
Send Authorization: Bearer $REDROUTER_API_KEY.
Request body
application/json · required
{
"$ref": "#/components/schemas/ChatRequest"
}
Request examples
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());
Responses
200 · Completed response or event stream
application/json
{
"$ref": "#/components/schemas/ChatResponse"
}
text/event-stream
{
"description": "Each data field is ChatChunk JSON. The terminal data field is [DONE]. Usage may follow finish_reason when stream_options.include_usage is true.",
"type": "string"
}
Event data schema:
{
"$ref": "#/components/schemas/ChatChunk"
}
400 · Invalid request
application/json
{
"$ref": "#/components/schemas/Error"
}
401 · Invalid key
application/json
{
"$ref": "#/components/schemas/Error"
}
402 · Insufficient credit
application/json
{
"$ref": "#/components/schemas/Error"
}
403 · Key permissions or spend limit
application/json
{
"$ref": "#/components/schemas/Error"
}
404 · Unknown model
application/json
{
"$ref": "#/components/schemas/Error"
}
413 · Request too large
application/json
{
"$ref": "#/components/schemas/Error"
}
429 · Rate, concurrency or daily spend limit
application/json
{
"$ref": "#/components/schemas/Error"
}
500 · Internal error
application/json
{
"$ref": "#/components/schemas/Error"
}
502 · Model response failed
application/json
{
"$ref": "#/components/schemas/Error"
}
503 · Model unavailable
application/json
{
"$ref": "#/components/schemas/Error"
}