Claude Code setup on 59API: two settings, one key
Why connecting Claude Code takes longer than it should
You have Claude Code working on your machine. The prompts flow, the responses come back, and the terminal feels productive. Then you look at the bill and wonder whether there is a simpler way to run the same client against a different API host, with billing you can actually see before you commit to a month of spending.
That is the problem 59API solves. Instead of a separate account, a separate key and a separate billing relationship for every provider, 59API gives you one account and one API key, plus one API host at https://api.59api.com, covering Claude, GPT, Gemini, DeepSeek and other models. You top up a prepaid balance, and requests are charged per request based on real token usage. There is no monthly fee, and your balance never expires.
For a developer who mostly wants to get on with the work, this removes a category of decisions. You are not redesigning your workflow around a subscription. You are pointing an existing client at a different endpoint, and the cost of a request becomes a function of the tokens it actually used.
This guide walks through the whole Claude Code setup on 59API: the exact environment variables, the client requirement that catches people out, what a request costs, and how optional cards fit alongside pay-as-you-go billing. It should take a few minutes to read and even less time to apply.
The exact settings for your Claude Code client
Here is the whole configuration. In your shell environment, set the base URL to the 59API host and the authentication token to the key issued to your 59API account:
ANTHROPIC_BASE_URL=https://api.59api.comANTHROPIC_AUTH_TOKEN=YOUR_59API_KEY
That is the entire list. There is no second host, no region-specific endpoint and no separate configuration file to merge with existing settings. The same pair applies to Claude Code and Claude Desktop.
Replace YOUR_59API_KEY with the real key from your account. In practice, the most reliable habit is to export the variables in the shell you launch Claude Code from, rather than editing them once and forgetting they live in a different profile. A quick check is to start a fresh terminal, print the two variables, and confirm the values before launching the client. If the host is missing a trailing slash or contains a typo, the client will simply fail to reach the API, and the error can look more dramatic than the cause warrants.
Because 59API uses a single API host and a single key, you can also keep the same key for other work later. The base URL and path differ depending on the protocol the model family expects, so it is worth remembering which settings belong to which client rather than assuming one universal configuration.
Use the genuine Claude client, and check the version
There is one requirement that is worth stating plainly, because it is the most common reason a Claude Code setup appears to work and then produces nothing. Claude models work only through the genuine Claude Code or Claude Desktop client, and Claude Code needs to be version 2.1.285 or newer. They do not work through the OpenAI SDK, cURL or other clients.
This is not a limitation you can work around by switching endpoints. The Claude family expects its own client and protocol path, and 59API supports that path in the tools built for it.
For comparison, 59API also supports OpenAI-compatible access for Codex, OpenAI SDKs, cURL and clients such as Cursor, Cherry Studio, Cline and OpenCode, using https://api.59api.com/v1 as the base URL and https://api.59api.com/v1/chat/completions as the chat endpoint. Those combinations cover GPT, DeepSeek and other non-Claude, non-Gemini models only. Gemini models use Google's native protocol through Gemini CLI, configured with GOOGLE_GEMINI_BASE_URL=https://api.59api.com and GEMINI_API_KEY=YOUR_59API_KEY, and they are not available through the OpenAI-compatible path.
So the setup rule is simple: match the client to the model family, and use the host and key that belong to it. 59API keeps those routes separate so each one behaves as the tool expects.
What a Claude request actually costs on 59API
Because 59API charges by real token usage, the useful question is not what a month costs but what a given workload costs. Prices are listed per 1 million tokens, billing is in CNY, and USD figures are shown at ¥7.2 = $1.
Take Claude Sonnet 5.5, with model id claude-sonnet-5-5. Input is $1.11 (¥8) per 1 million tokens, output is $5.56 (¥40), and cache read is $0.0972 (¥0.7). The official list price is $2 / $10.
For a concrete illustration, consider a run of 3M input tokens and 0.5M output tokens without cache. On 59API that comes to $6.11 (¥44). At official list price the same workload is $11 (about ¥79.2), so 59API is about 56% of list price. For lighter traffic, 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, against an official list price of $1 / $5.
Paying for that usage is straightforward. Top-ups come in ¥10, ¥50, ¥100, ¥200, ¥500 and ¥1000, paid by WeChat Pay or bank card, and invoices are available. Since billing follows actual consumption, you can start small, watch how a real project behaves, and adjust from there instead of committing to a fixed plan.
Optional cards, and where to start
Pay-as-you-go is the simplest way in, but some developers prefer the predictability of a card. 59API offers optional monthly and weekly cards, and it is worth understanding exactly how they behave before you choose one.
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. Quota and caps are card metering units written in $, not official list-price dollars, so they should not be read as direct price comparisons.
One example is the C-PRO Starter card for Claude, valid for 30 days: $83.19 (¥599), with quota $610 and a weekly cap of $230. It drains at the card's metering price × 2.4, and its reference value at official list prices is about $169.44 (¥1220). Weekly options exist too, such as the 7-day C-PRO $290 card at $40.14 (¥289), with quota $290 and a weekly cap of $290.
So which route should you take? If you are connecting Claude Code for the first time and want to see real usage before committing, top up a small balance and use your normal API key. If you already know the workload and want a defined allowance, look at the card that matches your model family and timeline.
Either way, the setup itself is two environment variables and one key. That is the pitch of 59API in practical terms: less configuration to maintain, transparent per-token billing, and no monthly fee on the balance you have already paid for. Set the two values, launch Claude Code, and let the first request tell you where the project goes next.
¿Listo para empezar?
Una sola clave para Claude, GPT y más, con facturación por tokens reales y sin cuota mensual. Regístrate para crear tu clave API; las tarifas de cada modelo están en la página de precios.
Registro gratis Precios