Loading
Skip to content
RedRouterRedRouter
Dashboard ↗

Anthropic Messages

Set the Messages base URL to https://redrouter.org. Clients append /v1/messages. Choose a model that supports tools for coding agents.

Claude Code

export ANTHROPIC_BASE_URL="https://redrouter.org"
export ANTHROPIC_AUTH_TOKEN="$REDROUTER_API_KEY"
export ANTHROPIC_API_KEY=""
export ANTHROPIC_MODEL="glm-5.3-flash-rr"
export ANTHROPIC_DEFAULT_SONNET_MODEL="glm-5.3-flash-rr"
export ANTHROPIC_DEFAULT_OPUS_MODEL="glm-5.3-flash-rr"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="glm-5.3-flash-rr"
export ANTHROPIC_DEFAULT_FABLE_MODEL="glm-5.3-flash-rr"
export CLAUDE_CODE_SUBAGENT_MODEL="glm-5.3-flash-rr"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="1"
export ENABLE_TOOL_SEARCH="true"
claude

All model tiers use the selected model. Token counting returns a conservative estimate. It does not call a model or spend credits.

OpenCode

Create opencode.json:

{
  "model": "redrouter/glm-5.3-flash-rr",
  "provider": {
    "redrouter": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "RedRouter",
      "options": {
        "baseURL": "https://redrouter.org/v1",
        "apiKey": "{env:REDROUTER_API_KEY}"
      },
      "models": {
        "glm-5.3-flash-rr": { "name": "GLM 5.3 Flash RR" }
      }
    }
  }
}

Send a message

curl -X POST 'https://redrouter.org/v1/messages' \
  -H "Authorization: Bearer $REDROUTER_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "max_tokens": 512,
  "messages": [
    {
      "content": "Hello",
      "role": "user"
    }
  ],
  "model": "glm-5.3-flash-rr"
}'
import os, json
from urllib.request import Request, urlopen

body = json.loads(r'''{
  "max_tokens": 512,
  "messages": [
    {
      "content": "Hello",
      "role": "user"
    }
  ],
  "model": "glm-5.3-flash-rr"
}''')
request = Request(
    "https://redrouter.org/v1/messages",
    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/messages", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${key}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "max_tokens": 512,
    "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());

Accepted fields

model, max_tokens, system, messages, tools, tool_choice, stop_sequences, temperature, top_p, stream, metadata, thinking, context_management, output_config

Messages requires max_tokens. Use text, assistant tool_use, and user tool_result blocks. Set tool choice to auto, any, tool, or none. Up to four stop sequences are accepted. A normal stop reports end_turn; matched stop sequences are not identified.

Text-only models replace images and documents with an omission notice, including media returned by a tool. The model cannot inspect that media. Provide extracted text or a description. A request containing only media returns 400.

Sessions accept up to 4,096 normalized messages within the request-body and model limits. Tool references preserve tool names. Supplied deferred tool definitions are available immediately. Replayed thinking signatures and citation metadata are omitted; visible response text is preserved. Compaction summaries are preserved.

Metadata, cache_control, thinking, output_config.effort, and clear_thinking with keep all are accepted for client compatibility and ignored. A JSON schema in output_config.format uses structured output on models with that capability. Other models receive a JSON instruction; schema validation is not guaranteed.

Server web tool declarations are omitted with an explicit unavailable-tool instruction to the model. Historical server-tool results preserve visible text and links. Use client-side tools for new searches and fetches. RedRouter does not run these server tools.

Server-side tool safety classification (safeguards) is unavailable. Requests asking for it return 400 before spending credits. Use a manual permission mode. Unknown fields still return 400.

Read the Messages schemas.

For Codex, use the Responses API guide.

↑ ↓ to select · Enter to open · Esc to close