Base URL
AnyRouter API 端点是:
https://anyrouter.dev/api/v1标准 OpenAI 兼容路由都在这个前缀下:/v1/chat/completions、/v1/embeddings、/v1/models 等。
鉴权
用标准 Authorization 头传 API key:
curl https://anyrouter.dev/api/v1/chat/completions \
-H "Authorization: Bearer sk-ar-v1-placeholder" \
-H "Content-Type: application/json" \
-d '{"model":"anyrouter/free","messages":[{"role":"user","content":"Hi"}]}'Key 以 sk-ar-v1- 开头。到 AnyRouter 控制台创建。
模型 id 格式
模型 id 遵循 provider/model 约定:
- anthropic/claude-sonnet-4-5
- openai/gpt-5.5
- google/gemini-2.5-pro
- z-ai/glm-5.2
- anyrouter/free (共享池免费档)
provider 前缀告诉 AnyRouter 打哪家上游。省略前缀或用不认识的 id 会 404。
请求格式
请求体遵循 OpenAI Chat Completions schema。最常见字段:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | 是 | provider/model id |
| messages | array | 是 | 对话历史 |
| temperature | number | 否 | 0–2,默认 1 |
| max_tokens | integer | 否 | 最大补全 token 数 |
| stream | boolean | 否 | true 则 SSE 流式 |
| tools | array | 否 | 函数/工具定义 |
流式响应
设 stream: true 接收 Server-Sent Events。AnyRouter 原样转发上游的流式格式。按你处理该供应商原生 API 的方式处理 SSE。
错误响应
AnyRouter 返回标准 HTTP 状态码:
- 200 — 成功
- 400 — 请求体格式错误
- 401 — API key 无效或缺失
- 404 — 找不到模型或未配置该供应商
- 429 — 超过限流(见 429 指南)
- 500/502/503 — 上游错误或网关问题
接下来看哪里
完整交互式 API 参考(每个端点和 schema)在 docs.anyrouter.dev。监控和排障用 chmonitor.dev 看每条请求的上游、延迟、token 和费用。
兼容 OpenAI 的 API,$2 免费额度,不绑卡。
获取 API key相关文章
OpenRouter alternatives 2026: how AnyRouter differs
OpenRouter alternatives 2026, without invented rankings: AnyRouter is one OpenRouter alternative with $0-markup BYOK, a donated shared pool, a $2/mo Go plan, Cloudflare-edge routing, on-device models via local relay, a built-in MCP server, and open pricing config.
Run Claude Code on AnyRouter — wrapper script or CLI
Route Claude Code through AnyRouter in two ways: a wrapper that installs itself and maps Opus, Sonnet, and Haiku to one catalog model (override with --model), or the anyr CLI launcher. One key, unified billing, audit logs.