Claude Code setup with 59API: two settings, one key
Why Claude Code setup usually slows a developer down
You have a working terminal, a project you care about, and a model you want to use from Claude Code. What you do not want is a detour through a maze of gateway settings, incompatible SDKs and vague documentation. The frustrating part is not the amount of configuration; it is that most instructions are written for a different client than the one you actually run.
Here is the honest version of the problem. Claude models are reachable only through the genuine Claude Code or Claude Desktop client, using version 2.1.285 or newer. That single constraint removes most of the guesswork. If you try to route Claude through the OpenAI SDK, cURL, Codex, Cursor, Cherry Studio, Cline or OpenCode, the request path is wrong by design, not by accident.
59API exists to make that path short. It is an independent third-party AI API relay: one account, one API key and one API host, https://api.59api.com, serving Claude, GPT, Gemini, DeepSeek and other models. You prepaid a balance, requests are charged per request by real token usage, there is no monthly fee, and your balance never expires. Monthly and weekly cards exist, but they are optional. The setup itself is two environment variables and a restart.
So the question is not whether the plumbing can be simple. It is how few moving parts you are willing to accept.
The exact two settings for Claude Code
Open your shell configuration and add these two entries:
ANTHROPIC_BASE_URL=https://api.59api.comANTHROPIC_AUTH_TOKEN=YOUR_59API_KEY
Replace YOUR_59API_KEY with the key from your 59API account. That is the entire configuration surface for Claude Code or Claude Desktop. There is no second host, no regional endpoint to hunt for, no separate SDK layer to install and no custom client to patch.
Two details matter more than they look. First, the base URL is the host only. You are not asked to append /v1 or a chat path, because Claude Code speaks its own native protocol. Second, the auth token is the credential, so the variable name matters: ANTHROPIC_AUTH_TOKEN is what the client reads, not an invented custom field.
Restart Claude Code after saving the values, then run a small prompt. If the client returns a Claude response, your setup is live and your prepaid balance starts being charged by actual token usage. If you get an authentication error, the usual culprit is a stray space in the token, an outdated client version or a shell file that never reloaded.
Keep one rule in mind while you test: Claude models work only in the genuine Claude Code or Claude Desktop client, version 2.1.285 or newer. Everything else you will read about base URLs for OpenAI-compatible clients is a different conversation, and we will come back to it.
What you will actually pay per million tokens
Because billing is per request based on real token usage, the only meaningful question is what a million tokens cost on 59API. Rates are per 1 million tokens, billed in CNY, with USD figures shown at ¥7.2 = $1.
- Claude Sonnet 5.5 (
claude-sonnet-5-5): input $1.11 (¥8), output $5.56 (¥40), cache read $0.0972 (¥0.7). Official list price $2 / $10. - Claude Opus 5.5 (
claude-opus-5-5): input $1.53 (¥11), output $7.22 (¥52), cache read $0.0694 (¥0.5). Official list price $4 / $20. - Claude Haiku 4.5 (
claude-haiku-4-5-20251001): input $0.3472 (¥2.5), output $1.67 (¥12), cache read $0.0278 (¥0.2). Official list price $1 / $5.
Cache reads are billed too, and they are cheap, so repeated context in a long coding session does not have to be treated as a crisis. The official list prices quoted here are reference points only; 59API is an independent relay, not an official channel, partner or reseller.
The billing model stays friendly even when your usage pattern is not. There is no monthly fee attached to the balance, and unused balance does not expire. If a project slows down for a week, your money is still there. Top-ups are ¥10, ¥50, ¥100, ¥200, ¥500 or ¥1000, paid by WeChat Pay or bank card, and invoices are available for those who need one.
Worked examples for a typical coding session
Rates are easier to trust when you multiply them out. Consider a hypothetical Claude Sonnet 5.5 session with 3M input tokens and 0.5M output tokens, no cache. On 59API that costs $6.11 (¥44). At the official list price of $11, about ¥79.2, 59API comes to about 56% of list price.
Now take Claude Haiku 4.5 with 5M input tokens and 1M output tokens, without cache. On 59API the cost is $3.4 (¥24.5). At official list price $10, about ¥72, that is about 34% of list price.
For Claude Opus 5.5 with 2M input tokens and 0.5M output tokens, no cache, 59API charges $6.67 (¥48). At official list price $18, about ¥129.6, that is about 37% of list price.
These are illustrations, not quotes for your workload, but the shape is clear: heavier sessions cost more, lighter models cost less, and the meter follows real token usage rather than a seat fee. A practical habit is to pick the model that matches the task instead of running the most expensive one on every prompt, then let the balance absorb the difference.
Because you can top up in small increments such as ¥10 or ¥50, there is no reason to pre-commit heavily before you understand your own burn rate. Top up, run real work, watch the balance, and adjust.
Using 59API from other clients without mixing up protocols
Once Claude Code is running, you may also want GPT, DeepSeek or other non-Claude, non-Gemini models in tools like Codex, the OpenAI SDKs, cURL and OpenAI-compatible clients such as Cursor, Cherry Studio, Cline and OpenCode. Those clients use a different base URL and endpoint: base_url https://api.59api.com/v1 and chat endpoint https://api.59api.com/v1/chat/completions.
Gemini is separate again. Gemini models use Google's native protocol only, through Gemini CLI, with GOOGLE_GEMINI_BASE_URL=https://api.59api.com and GEMINI_API_KEY=YOUR_59API_KEY. They are not OpenAI-compatible and do not work on /v1/chat/completions.
So there are three lanes, and mixing them is the classic setup bug: Claude in Claude Code or Claude Desktop, Gemini in Gemini CLI, and everything else through the OpenAI-compatible path. Your single 59API key can cover all of them because the key is not tied to one protocol.
If you prefer predictable spending over pay-as-you-go, 59API also sells optional monthly and weekly cards. A card has its own key, can only call 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. For example, the C-PRO Starter (Claude, 30 days) is $83.19 (¥599), with quota $610 and a weekly cap of $230.
What to do next
Put it into practice in a short sequence. Create your 59API account, add a balance with WeChat Pay or a bank card, and copy your API key. Then open your shell configuration and set ANTHROPIC_BASE_URL=https://api.59api.com and ANTHROPIC_AUTH_TOKEN=YOUR_59API_KEY. Make sure you are running the genuine Claude Code or Claude Desktop client, version 2.1.285 or newer, and restart it.
Send one short prompt first. A small request confirms the whole chain: the client, the host, the key and the balance. Once that succeeds, run a task that resembles your real work and watch how the balance moves. You are charged per request by real token usage, so the numbers will tell you which model fits your routine.
If you later want a card, remember the separation: card key for that model family, balance key for everything else, no cross-draining, no rollover on unused quota. If you want a second protocol, add the OpenAI-compatible base_url and chat endpoint for non-Claude, non-Gemini models, or the native Gemini settings for Gemini CLI.
Two settings, one host, one key, and a prepaid balance that never expires. That is the whole idea behind 59API: less configuration between you and the model you want to use.