Claude Code CLI → anyrouter.top — 完整请求结构与 Header 说明
| 字段 | 值 |
|---|---|
| Method | POST |
| URL | https://anyrouter.top/v1/messages?beta=true |
| Path | /v1/messages |
| Query | beta=true |
| Header | 值 |
|---|---|
| accept | application/json 期望的响应格式。非流式时返回 JSON,流式时服务端实际返回 text/event-stream |
| content-type | application/json 请求体格式,固定 JSON |
| authorization | Bearer sk-rK***yGkU API 密钥,Bearer token 格式 |
| anthropic-version | 2023-06-01 Anthropic API 版本号,当前稳定版 |
| anthropic-beta | claude-code-20250219, interleaved-thinking-2025-05-14, prompt-caching-scope-2026-01-05, effort-2025-11-24 启用的 Beta 功能列表:Claude Code 专用协议、交错思考、Prompt 缓存范围控制、Effort 控制 |
| anthropic-dangerous-direct-browser-access | true 允许非浏览器客户端直接访问(绕过浏览器限制检查) |
| user-agent | claude-cli/2.1.74 (external, cli) 客户端标识:Claude CLI 版本 2.1.74,external 表示外部安装 |
| x-app | cli 应用类型标识,cli 表示命令行工具 |
| x-stainless-lang | js Stainless SDK 语言:JavaScript(底层 SDK 为 @anthropic-ai/sdk) |
| x-stainless-package-version | 0.74.0 Anthropic JS SDK 版本号 |
| x-stainless-os | MacOS 客户端操作系统 |
| x-stainless-arch | x64 CPU 架构 |
| x-stainless-runtime | node 运行时环境 |
| x-stainless-runtime-version | v22.20.0 Node.js 版本 |
| x-stainless-retry-count | 0 当前重试次数,0 表示首次请求 |
| x-stainless-timeout | 600 客户端超时设置,单位秒(10 分钟) |
| accept-language | * 接受任意语言 |
| sec-fetch-mode | cors Fetch 模式标识 |
host, connection, content-length, accept-encoding 为传输层头,由 HTTP 客户端自动处理,此处省略。
| Header | 值 |
|---|---|
| content-type | text/event-stream SSE 流式响应格式 |
| cache-control | no-cache 禁止缓存流式响应 |
| x-new-api-version | v0.11.2-patch.2 上游网关 API 版本 |
| x-oneapi-request-id | 2026031307353815126455tFv1Fpr 上游请求 ID,用于追踪 |
| server | ESA |
| via | 1.1 Caddy, ens-cache27.l2hk12, ens-cache10.sg17 经过的代理/CDN 节点 |
curl -X POST \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-H 'authorization: Bearer sk-rK***yGkU' \
-H 'anthropic-version: 2023-06-01' \
-H 'anthropic-beta: claude-code-20250219,interleaved-thinking-2025-05-14,prompt-caching-scope-2026-01-05,effort-2025-11-24' \
-H 'anthropic-dangerous-direct-browser-access: true' \
-H 'user-agent: claude-cli/2.1.74 (external, cli)' \
-H 'x-app: cli' \
-H 'x-stainless-lang: js' \
-H 'x-stainless-package-version: 0.74.0' \
-H 'x-stainless-os: MacOS' \
-H 'x-stainless-arch: x64' \
-H 'x-stainless-runtime: node' \
-H 'x-stainless-runtime-version: v22.20.0' \
-H 'x-stainless-retry-count: 0' \
-H 'x-stainless-timeout: 600' \
-H 'accept-language: *' \
-H 'sec-fetch-mode: cors' \
--no-buffer \
-d '{"model":"claude-opus-4-6","max_tokens":32000,"temperature":1,"stream":true,"output_config":{"effort":"medium"},"messages":[{"role":"user","content":"Hello"}]}' \
'https://anyrouter.top/v1/messages?beta=true'
authorization 中的 key)。如需携带完整 system/tools,请使用代理生成的 _body.json 配合 -d @body.json。