Claude Code 接入 / Claude Code API platform
Claude Code 接入 Routin:ANTHROPIC_BASE_URL 怎么填
Claude Code on Routin: ANTHROPIC_BASE_URL and API key setup
Claude Code 走 Anthropic Messages 协议。把 ANTHROPIC_BASE_URL 指到 Routin 根地址,用 Routin API Key 作为 ANTHROPIC_AUTH_TOKEN,即可调用目录中的模型。
Claude Code speaks the Anthropic Messages protocol. Point ANTHROPIC_BASE_URL at the Routin root and use a Routin API key as ANTHROPIC_AUTH_TOKEN.
接入要点 / Setup facts
- 协议 / ProtocolAnthropic Messages / Claude Code
- Base URL
https://api.routin.ai/ - ANTHROPIC_BASE_URL 填 https://api.routin.ai/(根地址)。Claude Code 会自己拼 /v1/messages,不要再加 /v1。 / Set ANTHROPIC_BASE_URL to https://api.routin.ai/ (the root). Claude Code appends /v1/messages; do not add /v1 yourself.
- 鉴权字段是 ANTHROPIC_AUTH_TOKEN,值是 Routin API Key,不是 Anthropic 官方 key。 / ANTHROPIC_AUTH_TOKEN is your Routin API key, not an Anthropic console key.
- 这和 Cursor / Codex 的 OpenAI 兼容地址不同。混用 Base URL 是最常见的接入失败原因。 / This is not the OpenAI-compatible /v1 URL used by Cursor and Codex. Mixing base URLs is the usual setup failure.
步骤 / Steps
- 安装 Claude Code / Install Claude Code
使用 npm install -g @anthropic-ai/claude-code,确认 claude --version 可用。
Install with npm install -g @anthropic-ai/claude-code and confirm claude --version works.
- 写入 ~/.claude/settings.json / Write ~/.claude/settings.json
在 ~/.claude/settings.json(Windows 为 C:\Users\<user>\.claude\settings.json)写入 ANTHROPIC_AUTH_TOKEN 与 ANTHROPIC_BASE_URL=https://api.routin.ai/。
Put ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL=https://api.routin.ai/ in ~/.claude/settings.json (Windows: C:\Users\<user>\.claude\settings.json).
- 启动并验证 / Launch and verify
运行 claude,发一条短消息。模型名可按目录配置 ANTHROPIC_MODEL。
Run claude and send a short prompt. Optionally set ANTHROPIC_MODEL to a catalog id.
~/.claude/settings.json / ~/.claude/settings.json
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "sk-your-routin-api-key",
"ANTHROPIC_BASE_URL": "https://api.routin.ai/"
},
"alwaysThinkingEnabled": true
}下一步 / Next
其他 Agent / Other agents
可选用的聊天模型 / Chat models to try
把目录中的模型 id 填进 Claude Code。价格来自公开目录。 / Use a catalog model id inside Claude Code.
| Model | Provider | Type | Input | Output |
|---|---|---|---|---|
| claude-fable-5 | Anthropic | chat | 10.00 Token / 1M tokens | 50.00 Token / 1M tokens |
| claude-fable-5-1 | Anthropic | chat | 10.00 Token / 1M tokens | 50.00 Token / 1M tokens |
| claude-fable-5-2 | Anthropic | chat | 8.00 Token / 1M tokens | 40.00 Token / 1M tokens |
| claude-haiku-4-5 | Anthropic | chat | 1.00 Token / 1M tokens | 5.00 Token / 1M tokens |
| claude-haiku-4-5-20251001 | Anthropic | chat | 1.00 Token / 1M tokens | 5.00 Token / 1M tokens |
| claude-haiku-5-5 | Anthropic | chat | 0.1000 Token / 1M tokens | 0.5000 Token / 1M tokens |
| claude-opus-4-1-20250805 | Anthropic | chat | 3.00 Token / 1M tokens | 15.00 Token / 1M tokens |
| claude-opus-4-5-20251101 | Anthropic | chat | 5.00 Token / 1M tokens | 25.00 Token / 1M tokens |
模型目录 / Models套餐 / Plans费用计算器 / Cost calculatorCoding Agents文档 / Docs
常见问题 / FAQ
- Claude Code 的 Base URL 要加 /v1 吗? / Does Claude Code need /v1?
- No. Use https://api.routin.ai/ without /v1. Claude Code requests /v1/messages on that root. 不要填 https://api.routin.ai/v1。
- Claude Code 用哪把 Key? / Which key does Claude Code use?
- A Routin API key in ANTHROPIC_AUTH_TOKEN. You do not need an Anthropic Console key when routing through Routin. 填 Routin API Key。
- Claude Code 和 Cursor 配置一样吗? / Is Claude Code setup the same as Cursor?
- No. Cursor uses OpenAI-compatible /v1. Claude Code uses the Anthropic root URL and ANTHROPIC_* env vars. 两者协议不同,不要复制同一套 Base URL。