59API

← Back to all guides

Set up Claude Code, Codex and Gemini CLI via 59API API relay

Claude Code · EN · 2026-11-10

One key, three clients, no credential juggling

Switching between coding tools usually turns into configuration work. Claude Code needs one set of environment variables, Codex and OpenAI-compatible tools need another, and Gemini CLI speaks its own native protocol. Add separate provider accounts and separate keys on top of that, and you are managing credentials instead of shipping features. Then there is the billing side: several subscriptions, several invoices, and no clear view of what each request actually cost.

59API is built to remove that friction. It is an independent third-party AI API relay organised around one account, one API key and one API host: https://api.59api.com. That single credential gives you access to Claude, GPT, Gemini, DeepSeek and other models. The key you paste into Claude Code is the same key you paste into Gemini CLI, and the same key sits behind your Codex configuration.

The commercial model stays equally simple. You top up a prepaid balance and every request is charged by real token usage. There is no monthly fee, and your balance never expires. Monthly and weekly cards exist as an option, but you are not forced into a plan before you know how much you will use.

What follows is the short version: three clients, three exact settings, and the rates you will actually be charged.

Claude Code: two environment variables and nothing else

Start with the client that has the strictest requirements. Claude models on 59API work only through the genuine Claude Code or Claude Desktop client, using Claude Code 2.1.285 or newer. They do not work through the OpenAI SDK, cURL or other clients, so no amount of endpoint editing will make that combination valid.

Inside your genuine Claude Code or Claude Desktop client, set these two values:

That is the entire configuration step. There is no second key to generate and no separate client account to maintain. Because this is the same 59API key used for Codex and Gemini CLI, you set it once and reuse it everywhere.

Now the cost side. Rates are per 1 million tokens, billed in CNY with USD shown at ¥7.2 = $1. Claude Sonnet 5.5, model id claude-sonnet-5-5, is $1.11 (¥8) input, $5.56 (¥40) output and $0.0972 (¥0.7) cache read. For a concrete comparison, 3M input plus 0.5M output tokens without cache costs $6.11 (¥44) on 59API, against an official list price of $11 (about ¥79.2) — about 56% of list price.

One rule deserves repeating: keep Claude traffic inside the official Claude client. The two variables above are simple, but only in the environment that actually speaks that protocol.

Codex and OpenAI-compatible clients: use the /v1 route

Codex, OpenAI SDKs, cURL and OpenAI-compatible clients such as Cursor, Cherry Studio, Cline and OpenCode all take the same path. For these tools, point your client at the OpenAI-compatible base URL:

These clients pair with GPT, DeepSeek and other non-Claude, non-Gemini models only. That is a protocol boundary rather than a preference: Claude belongs in the genuine Claude Code or Claude Desktop client, and Gemini belongs in Gemini CLI.

Pricing follows the same per-1-million-token model. GPT-6.1 Sol, model id gpt-6.1-sol, is $0.1847 (¥1.33) input and $0.9264 (¥6.67) output, with cache read at $0.0375 (¥0.27). GPT-5.6 Sol, model id gpt-5.6-sol, is $0.3472 (¥2.5) input and $1.94 (¥14) output, with cache read at $0.0278 (¥0.2).

Run the arithmetic on a realistic session. GPT-6.1 Sol with 5M input and 1M output tokens without cache comes to $1.85 (¥13.32) on 59API. The same volume at the official list price of $20 (about ¥144) means 59API is about 9% of list price. GPT-5.6 Sol with 2M input and 0.5M output tokens without cache is $1.67 (¥12) on 59API, against an official list price of $18 (about ¥129.6) — also about 9% of list price.

Because billing follows real token usage, quiet weeks simply do not generate charges. You pay for the requests you make.

Gemini CLI: native protocol, two settings

Gemini is the third protocol, and 59API handles it with its own pair of variables. In Gemini CLI set:

Gemini models use the native Google protocol only. They are not OpenAI-compatible, and they do not work on /v1/chat/completions. That means you should not point Codex, cURL or an SDK-based tool at Gemini through the /v1 route, and you should not expect Claude Code to pick them up. The mapping is clean once you accept it: Claude to the genuine Claude client, Gemini to Gemini CLI, and GPT, DeepSeek and the rest through the OpenAI-compatible path.

Rates for Gemini on 59API are also per 1 million tokens. Gemini 2.5 Flash, model id 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, model id gemini-3.1-pro, is $1.39 (¥10) input, $8.06 (¥58) output and $0.1389 (¥1) cache read.

You now have three clients configured against one credential. Copy the key once, paste it into the three variable pairs above, and the routing rules keep each model in the client that understands it.

One practical habit: keep these settings in a single file or shell profile inside your project. Moving between a Claude-heavy task and a Gemini experiment then never involves digging through old terminal history.

Top up, check the numbers, and start working

Setup is only half the story, so here is the money side in brief. 59API bills in CNY with USD figures shown at ¥7.2 = $1, and top-ups come in ¥10, ¥50, ¥100, ¥200, ¥500, ¥1000, paid by WeChat Pay or bank card. Invoices are available. There is no monthly fee on the pay-as-you-go balance, and that balance never expires, so a small top-up can sit there until you need it.

If your usage becomes predictable, monthly and weekly cards are optional extras. A card has its own key and can only call that family of models. It 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. As an example, the C-PRO Starter card for Claude, valid 30 days, is $83.19 (¥599) with a $610 quota and a $230 weekly cap.

Here is the short version of what to do next:

One key across Claude Code, Codex and Gemini CLI, one host, and per-request billing based on the tokens you actually use. That is a smaller setup than the problem you started with — and a straightforward reason to try 59API on your next session.

Docs

Ready to get started?

One key for Claude, GPT and more, billed by real token usage with no monthly fee. Sign up to create your API key; rates for every model are on the pricing page.

Sign up free Pricing