The handbook.

Everything you need to point OpenAI SDKs, Codex, Claude Code, and OpenAI-compatible clients at EastRouter in under two minutes.

Quickstart

Three lines of config.

Any OpenAI SDK works. Change base_url to https://api.eastrouter.com/v1, paste your sk-er_… key, and pick a model.

Public base URLs: OpenAI SDKs and Codex use https://api.eastrouter.com/v1. Claude Code uses https://api.eastrouter.com/api/anthropic.

from openai import OpenAI

client = OpenAI(
    api_key="sk-er_k_7f3a9c2d_•••••",
    base_url="https://api.eastrouter.com/v1",
)

response = client.chat.completions.create(
    model="z-ai/glm-5.2",
    messages=[{"role": "user",
                "content": "Refactor this for me."}],
    stream=True,
)

You'll need a key first. Get an API key, or see pricing.

Codex

Codex uses the OpenAI Responses API. Point its custom provider at the same public EastRouter base URL:

~/.codex/config.toml
model_provider = "eastrouter"
model = "z-ai/glm-5.2"

[model_providers.eastrouter]
name = "EastRouter"
base_url = "https://api.eastrouter.com/v1"
env_key = "EASTROUTER_API_KEY"
wire_api = "responses"

# shell
export EASTROUTER_API_KEY="sk-er_..."

Claude Code

Claude Code uses the Anthropic-compatible surface. Use your EastRouter key as the Anthropic auth token:

~/.claude/settings.json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "sk-er_...",
    "ANTHROPIC_BASE_URL": "https://api.eastrouter.com/api/anthropic",
    "API_TIMEOUT_MS": "3000000"
  }
}

Authentication

Bearer tokens, OpenAI-compatible.

EastRouter uses the same Authorization: Bearer … header shape as OpenAI. Your key looks like:

Key format
sk-er_<key_id>_<secret>

The key_id is a plaintext lookup; the secret is cryptographically hashed at rest and never stored in readable form. Treat the whole string as a secret — anyone with it can spend your credit.

Rotating a key

Generate a new key in the dashboard, swap it in your environment, then revoke the old one. Revoking takes effect on the next request — there is no key cache to invalidate.

Endpoints

The surface area.

OpenAI/Codex clients use https://api.eastrouter.com/v1. Claude Code uses https://api.eastrouter.com/api/anthropic. The model field accepts the IDs in our catalog — z-ai/glm-5.2 being the recommended default for hard tasks.

Method and pathWhat it does
POST /v1/chat/completionsOpenAI-compatible chat completions. Streaming + non-streaming. Reasoning tokens supported.
POST /v1/responsesOpenAI Responses-compatible facade for Codex and newer OpenAI clients.
POST /api/anthropic/v1/messagesAnthropic-compatible Claude Code endpoint. Also available as /v1/messages.
POST /api/anthropic/v1/messages/count_tokensCounts tokens for Claude Code.
GET /api/anthropic/v1/modelsClaude Code model metadata utility endpoint.
GET /v1/modelsList the models available to your key.
GET /v1/balanceCurrent credit balance. EastRouter extension — not on OpenAI.

Compatibility aliases

These aliases work the same way, with the same billing and balance:

AliasUse when
/api/v1/chat/completionsA client hardcodes an /api/v1 prefix.
/api/coding/paas/v4/chat/completionsA coding tool hardcodes a /coding/paas/v4 prefix.
/codex/v1/chat/completionsYou want an explicit Codex-labeled chat-completions alias.

Streaming

SSE, byte-identical.

Pass stream=True (Python) or stream: true (Node) and you'll get a Server-Sent Events stream with the same chunk envelope OpenAI uses — same choices[0].delta.content shape, same [DONE] sentinel, same usage block on the final chunk.

Reasoning tokens

Reasoning models stream their reasoning by default. EastRouter normalises the field name to choices[0].delta.reasoning so OpenRouter-compatible clients see what they expect.

To opt out, send reasoning: { "effort": "none" } in your request.

When a request fails

Failed requests are retried for you.

Every request checks your balance before it runs. If a model is busy, times out or returns an error that can be retried, EastRouter retries it within the same request, so your code needs no retry logic of its own.

Claude Code uses the Anthropic-compatible endpoint; OpenAI SDKs, Codex and other coding tools use the OpenAI-compatible one. Either way, your key, balance and request log are the same.

API reference

Request & response.

Request body

FieldTypeNotes
modelstringRequired. e.g. z-ai/glm-5.2. See catalog.
messagesarrayStandard OpenAI roles: system, user, assistant, tool.
streambooleanDefaults to false. Streaming uses SSE.
temperaturenumber0.0–2.0. Passed through unchanged.
max_tokensintegerCaps output length. Also used to check your key’s daily cap before the request runs.
toolsarrayOpenAI tool-calling schema. GLM, Kimi, MiniMax all support it.
reasoningobject{ "effort": "none" | "minimal" | "medium" | "high" }. Sets how much the model thinks before it answers.

Response, non-streaming

JSON
{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "model": "z-ai/glm-5.2",
  "choices": [{
    "index": 0,
    "message": { "role": "assistant", "content": "..." },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 142,
    "completion_tokens": 87,
    "total_tokens": 229,
    "prompt_tokens_details": { "cached_tokens": 0 }
  }
}

SDKs & tools

Your stack, unchanged.

EastRouter has no SDK of its own to install. Anything that speaks the OpenAI API, or the Anthropic API in Claude Code's case, works once it points at EastRouter with your sk-er_… key.

  • OpenAI SDK
  • Python
  • JavaScript
  • TypeScript
  • Go
  • Rust
  • cURL
  • Claude Code
  • Codex CLI
  • Cline
  • RooCode

Which base URL to use

ClientBase URL
OpenAI SDK (Python, JavaScript, TypeScript)https://api.eastrouter.com/v1
Codex CLIhttps://api.eastrouter.com/v1
Cline, RooCodehttps://api.eastrouter.com/v1
Go, Rust, cURL and other HTTP clientshttps://api.eastrouter.com/v1
Claude Codehttps://api.eastrouter.com/api/anthropic

OpenAI SDKs

The official Python and JavaScript SDKs read their settings from the environment, so existing code can stay as it is:

.env
OPENAI_BASE_URL=https://api.eastrouter.com/v1
OPENAI_API_KEY=sk-er_k_7f3a9c2d_•••••

Other languages work the same way: use any OpenAI-compatible client library and set its base URL, or call the endpoints directly as in the cURL quickstart.

Coding agents

Claude Code talks to the Anthropic-compatible endpoint:

Shell
export ANTHROPIC_BASE_URL=https://api.eastrouter.com/api/anthropic
export ANTHROPIC_AUTH_TOKEN=sk-er_k_7f3a9c2d_•••••

Cline and RooCode: choose the OpenAI-compatible provider in the tool's settings, then enter the base URL, your key and a model ID from the catalog.

Codex CLI: point it at the /v1 base URL; it uses the Responses-compatible endpoint listed under Endpoints.

Migration

From OpenRouter, in two lines.

If your client already points at OpenRouter, you change two strings:

OpenRouterEastRouter
https://openrouter.ai/api/v1https://api.eastrouter.com/v1
sk-or-v1-...sk-er_..._...
model: "z-ai/glm-5.2"model: "z-ai/glm-5.2" (same)

Model IDs are 1:1 with OpenRouter's. Response schemas are identical. Provider-prefixed headers (HTTP-Referer, X-Title) are accepted but ignored.

Start building with Asia’s best AI models.

One key for GLM, Kimi, DeepSeek and MiniMax, at 50% off. Qwen on request.

Try for freeGet started
Contact

Talk to our team.

Tell us what you’re building and we’ll reply by email.