一页速查
一张表,所有客户端。找到你用的工具,复制地址和密钥变量,看一眼要点。你的密钥以 ck_ 开头,在控制台里。
| 你用的工具 | Base URL | 密钥变量 | 要点 |
|---|---|---|---|
| Claude Code(macOS / Linux) | https://api.cheapapirelay.com | export ANTHROPIC_BASE_URL=https://api.cheapapirelay.com export ANTHROPIC_AUTH_TOKEN=ck_paste_key_here claude | 这个地址后面不加 /v1。Claude 模型只响应官方 Claude Code 和 Claude Desktop 客户端,且版本要 2.1.285 以上——这是上游的限制,我们放不开。 |
| Claude Code(Windows) | https://api.cheapapirelay.com | setx ANTHROPIC_BASE_URL https://api.cheapapirelay.com setx ANTHROPIC_AUTH_TOKEN ck_paste_key_here | setx 把两个值存给以后打开的终端:执行完重新开一个 PowerShell 窗口,再运行 claude。 |
| Claude Desktop | https://api.cheapapirelay.com | ANTHROPIC_BASE_URL=https://api.cheapapirelay.com ANTHROPIC_AUTH_TOKEN=ck_paste_key_here | 和 Claude Code 是同样两个值,填在应用的网关设置里。客户端版本要求也一样。 |
| Codex CLI | https://api.cheapapirelay.com/v1 | export CHEAP_KEY=ck_paste_key_here | 加一个指向 /v1 的自定义 provider,让 Codex 从 CHEAP_KEY 读密钥。价格表上的 GPT 模型都能用。# ~/.codex/config.toml model = 'gpt-6.1-sol' model_provider = 'cheaprelay' [model_providers.cheaprelay] name = 'CheapRelay' base_url = 'https://api.cheapapirelay.com/v1' env_key = 'CHEAP_KEY' wire_api = 'responses' # then: export CHEAP_KEY=ck_paste_key_here |
| OpenAI SDK(Python、Node) | https://api.cheapapirelay.com/v1 | api_key="ck_paste_key_here" | 任何兼容 OpenAI 的 SDK,只要 base_url 以 /v1 结尾就能用。GPT 可以先试这几个 id:gpt-6.1-sol, gpt-6-astra, gpt-5.6-sol。from openai import OpenAI as BudgetClient
wallet = BudgetClient(base_url="https://api.cheapapirelay.com/v1", api_key="ck_paste_key_here")
bill = wallet.chat.completions.create(
model="gpt-6.1-sol",
messages=[{"role": "user", "content": "List three habits that waste tokens"}],
)
print(bill.choices[0].message.content)
print("tokens billed:", bill.usage.total_tokens) |
| cURL | https://api.cheapapirelay.com/v1/chat/completions | -H "Authorization: Bearer ck_paste_key_here" | 对话补全在 /v1/chat/completions;/v1/responses 也照样转发。curl https://api.cheapapirelay.com/v1/chat/completions \
-H "Authorization: Bearer ck_paste_key_here" -H "Content-Type: application/json" \
-d '{"model":"gpt-6.1-sol","messages":[{"role":"user","content":"Price check: one tip to trim a prompt"}]}' |
| Gemini CLI | https://api.cheapapirelay.com | export GOOGLE_GEMINI_BASE_URL=https://api.cheapapirelay.com export GEMINI_API_KEY=ck_paste_key_here gemini | 只填裸域名,别加 /v1beta,CLI 会自己补上。 |
| Gemini REST | https://api.cheapapirelay.com/v1beta/models/{model}:generateContent | -H "x-goog-api-key: ck_paste_key_here" | Gemini 在这里只走原生协议,不能走 /v1/chat/completions。流式用 :streamGenerateContent?alt=sse。在售 id:gemini-2.5-flash, gemini-3.1-pro, gemini-3.8-flash。curl "https://api.cheapapirelay.com/v1beta/models/gemini-3.8-flash:generateContent" \
-H "x-goog-api-key: ck_paste_key_here" -H "Content-Type: application/json" \
-d '{"contents":[{"role":"user","parts":[{"text":"Sum up prompt caching in twelve words"}]}]}' |
| Cursor、Cline、Roo、Cherry Studio、OpenCode | https://api.cheapapirelay.com/v1 | 应用自己的 API 密钥输入框 | 选“OpenAI 兼容”类型的服务商,粘贴密钥即可。GPT、DeepSeek、Kimi、GLM、Qwen、Grok、MiniMax 都能这样用;Claude 不行,它只认官方客户端。 |
计费:每次调用按真实 token 数(输入、输出、写入缓存、命中缓存)计价,调用一结束就记进控制台。
HTTP 402 表示余额为零或负数:充值后同一把密钥立刻恢复。401 是没带密钥或密钥已作废;429 是太快了(每把密钥每分钟 120 次,每个账户同时 8 个)。
查你的密钥能用哪些模型:GET /v1/models(OpenAI 格式),GET /v1beta/models(只列 Gemini)。