更新于 2026-04-14
Claude API 中国使用完整方案
Anthropic 官方不对中国大陆开放 Claude API。本文讲清三层障碍——账号、付款、网络——并给出绕开所有障碍的最省心做法。
三层障碍
直接在中国用 Anthropic Python SDK 调 Claude,会依次撞上三堵墙:
- 账号:Anthropic 注册要海外手机号接验证码
- 付款:必须绑 Visa / Mastercard,不接受银联 / 支付宝 / 微信
- 网络:
api.anthropic.com的 IP 在国内不稳定,即便账号 OK 也常超时
每一层都要单独处理,任何一层出问题整条链路就断。
三种方案对比
| 方案 | 账号 | 付款 | 网络 |
|---|---|---|---|
| A. VPN + 海外卡自注册 | ❌ 麻烦 | ❌ 需国际卡 | ⚠️ 不稳定 |
| B. 美国 VPS 自建代理 | ❌ 仍要海外卡 | ❌ 仍要海外卡 | ✅ 稳定 |
| C. 第三方聚合(ModelServer) | ✅ 邮箱注册 | ✅ 支付宝/微信 | ✅ 稳定 |
5 分钟接入 (方案 C)
1. 注册 + 充值
modelserver.dev 邮箱登录,Billing 页面支付宝/微信充值。
2. 创建 API Key
API Keys 页面 → Create Key,复制 sk-...。
3. 代码示例
用 Anthropic 官方 Python SDK(只改 base_url):
Python
from anthropic import Anthropic
client = Anthropic(
base_url="https://modelserver.dev",
api_key="sk-你的key",
)
resp = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "用中文解释一下什么是 OpenAI-compatible API"}],
)
print(resp.content[0].text)Node.js(@anthropic-ai/sdk):
Node.js
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://modelserver.dev",
apiKey: "sk-你的key",
});
const msg = await client.messages.create({
model: "claude-sonnet-4-6",
max_tokens: 1024,
messages: [{ role: "user", content: "你好" }],
});
console.log(msg.content[0].text);纯 curl 验证:
curl
curl https://modelserver.dev/v1/messages \
-H "x-api-key: sk-你的key" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-4-6","max_tokens":100,"messages":[{"role":"user","content":"你好"}]}'全部 Anthropic 高级功能都支持
Prompt caching (
cache_control)、tool use、streaming SSE 全部透传原生 API, 代码完全不用改。详见 Anthropic API Proxy。可用 Claude 模型
claude-opus-4-6— 最强推理claude-sonnet-4-6— 性价比最佳(推荐默认)claude-haiku-4-5— 极速且便宜
完整列表与价格见 Pricing。
常见问题
调用延迟多少?
国内直连 ModelServer 的 RTT 一般 200–400ms,具体看你的运营商与节点位置。首 token 延迟 Claude 官方约 500–1500ms,过代理后基本 +200–400ms。
能用 Anthropic 官方 key 吗?
不能,ModelServer 用独立账号和 key 体系。这也是为什么不需要海外卡 / 海外手机号的原因。
数据会被日志吗?
默认只日志元数据(时间、模型、token 数)用于计费与 debug,请求/响应内容不落盘。详情见隐私政策。