59API API relay setup: one key for Claude Code, Codex, Gemini CLI
One key, but not one protocol: the problem 59API solves
Most developers do not have a key problem. They have a routing problem. You want Claude in Claude Code, GPT in Codex, Gemini in Gemini CLI, and DeepSeek or another model in a quick cURL test — and each tool expects a different host, a different environment variable and, more often than not, a different wire format. The result is a folder of half-finished configuration files and a growing list of accounts to top up.
59API removes that fragmentation. It is an independent third-party AI API relay with one account, one API key and one API host: https://api.59api.com. That single key is what you paste into Claude Code, Codex and Gemini CLI. Each client gets its own environment variables, but every request lands on the same balance and the same billing history. There is no monthly fee, no separate subscription for each client, and no need to keep three provider dashboards open.
The catch is that a shared key does not mean a shared protocol. Claude models speak Anthropic's native format, Gemini models speak Google's native format, and GPT, DeepSeek and other models speak the OpenAI-compatible format. The good news is that the split is small and explicit: you change two environment variables per client, and you never have to guess which URL belongs to which tool.
Behind that simple setup sits a prepaid balance charged per request by real token usage, so the same key behaves predictably in every tool. This guide walks through the exact settings for each client, the models each one can reach, and what the balance actually costs you.
Claude Code: two variables and the genuine client
Claude Code and Claude Desktop are the strictest part of the setup, and 59API handles them with two environment variables:
ANTHROPIC_BASE_URL=https://api.59api.comANTHROPIC_AUTH_TOKEN=YOUR_59API_KEY
Replace YOUR_59API_KEY with the key from your 59API account, restart the client, and Claude models become available. There is one important boundary: Claude models work only through the genuine Claude Code or Claude Desktop client, and Claude Code 2.1.285 or newer is required. They do not work through the OpenAI SDK, cURL or any other client, so do not try to force them into a Codex-style configuration.
Once the client is connected, billing follows real token usage. Claude Sonnet 5.5 is listed at $1.11 (¥8) per 1 million input tokens and $5.56 (¥40) per 1 million output tokens, with cache reads at $0.0972 (¥0.7). A hypothetical run of 3M input tokens plus 0.5M output tokens without cache costs $6.11 (¥44) on 59API. The same workload at the official list price of $11 (about ¥79.2) puts 59API at about 56% of list price — a reference point, not a promise about every workload.
For a lighter option, Claude Haiku 4.5 is priced at $0.3472 (¥2.5) input, $1.67 (¥12) output and $0.0278 (¥0.2) cache read per 1 million tokens. The point is not the model choice but the setup: one key, one host, two variables.
Codex and OpenAI-compatible clients: the /v1 route
Codex, OpenAI SDKs, cURL and OpenAI-compatible clients such as Cursor, Cherry Studio, Cline and OpenCode all follow the same convention on 59API. Point them at the OpenAI-compatible base URL and use the chat completions endpoint:
- base_url:
https://api.59api.com/v1 - chat endpoint:
https://api.59api.com/v1/chat/completions
Use your 59API key as the API credential, and you are ready to send requests. The model catalogue on this route covers GPT, DeepSeek and other non-Claude, non-Gemini models. Claude models are not reachable here, and Gemini models are not OpenAI-compatible, so both stay on their own native clients.
GPT pricing on this route is straightforward. GPT-6.1 Sol is $0.1847 (¥1.33) per 1 million input tokens, $0.9264 (¥6.67) per 1 million output tokens and $0.0375 (¥0.27) for cache reads. Consider a hypothetical 5M input plus 1M output tokens without cache: that is $1.85 (¥13.32) on 59API, against an official list price of $20 (about ¥144), or about 9% of list price.
That gap is why developers often keep 59API in their Codex configuration permanently rather than switching back and forth. The endpoint stays the same; the model ID changes. GPT-6.1 Sol uses model id gpt-6.1-sol, and DeepSeek V4 Flash uses deepseek-v4-flash at $0.2778 (¥2) input and $1.11 (¥8) output per 1 million tokens.
Gemini CLI: Google's native protocol, not /v1
Gemini CLI is the third client, and it is the one place where copying a Codex configuration will waste your afternoon. Gemini models use Google's native protocol only. They are not OpenAI-compatible and they do not work on /v1/chat/completions, so the /v1 route is the wrong door entirely.
For Gemini CLI, set these two variables instead:
GOOGLE_GEMINI_BASE_URL=https://api.59api.comGEMINI_API_KEY=YOUR_59API_KEY
That is the complete setup. The same 59API key you use in Claude Code and Codex works here, billed against the same prepaid balance. The model IDs follow the names you would expect: gemini-2.5-flash, gemini-3.1-pro, gemini-3.8-flash and gemini-4-argon.
Rates are per 1 million tokens. Gemini 2.5 Flash is $0.2083 (¥1.5) input, $1.67 (¥12) output and $0.0208 (¥0.15) cache read. Gemini 3.1 Pro is $1.39 (¥10) input, $8.06 (¥58) output and $0.1389 (¥1) cache read. Gemini 4 Argon sits at $1.39 (¥10) input, $6.67 (¥48) output and $0.0694 (¥0.5) cache read.
Three clients, three pairs of variables, one key and one balance. The mental model is simple enough to hold in your head: native protocol for Claude, native protocol for Gemini, OpenAI-compatible for everything else.
What the shared balance costs, and when a card makes sense
59API uses a prepaid balance charged per request by real token usage. There is no monthly fee, and the balance never expires, so unused funds are not lost to a billing cycle. Top-ups come in ¥10, ¥50, ¥100, ¥200, ¥500 and ¥1000 increments, paid by WeChat Pay or bank card, and invoices are available. Billing is in CNY, with USD figures shown at ¥7.2 = $1.
Monthly and weekly cards are optional. A card has its own key, can call only that family's models, and is paid only from the card: it never falls back to wallet balance, and a balance key never draws on a card. Unused quota does not roll over. Quota and caps are card metering units written in $, not official list-price dollars, so they should not be read as direct price comparisons. For example, the weekly GPT card 【周卡】G-PRO $1100 (7 days) is $40.56 (¥292), with quota $1100 and a weekly cap of $1100.
For pay-as-you-go developers, the balance alone is usually enough. Claude Haiku 4.5, for example, costs $3.4 (¥24.5) for a hypothetical 5M input plus 1M output tokens without cache, against an official list price of $10 (about ¥72) — about 34% of list price.
Set up the three clients once, keep the key in your environment, and let token usage decide the bill. That is the appeal of 59API: less configuration to maintain, one place to fund, and a clear answer to which client can talk to which model.
शुरू करने के लिए तैयार?
Claude, GPT और अन्य मॉडलों के लिए एक ही key, असली token उपयोग पर बिलिंग और कोई मासिक शुल्क नहीं। साइन अप करके अपनी API key बनाएं; हर मॉडल की दरें मूल्य पेज पर हैं।
मुफ़्त साइन अप मूल्य