Claude Code setup with 59API: two settings and one key
The setup problem is bigger than the model choice
You already have Claude Code open, your prompts are flowing, and the build is green. Then you need to change where model requests go, and suddenly you are copying environment variables, hunting for the right endpoint, and guessing how billing will behave. That setup friction is the problem worth solving first.
59API removes most of the guesswork. It is an independent third-party AI API relay, not an official Anthropic channel, and it gives you one account, one API key, and one API host: https://api.59api.com. That single key can serve Claude, GPT, Gemini, DeepSeek and other models, so you are not juggling a separate provider relationship for every model family you want to try.
The financial model is straightforward too. 59API uses a prepaid balance, and each request is charged according to real token usage. There is no monthly fee, and your balance never expires. You top up only what you plan to use, then point your client at the host and the key.
For a developer who simply wants Claude Code to work, the integration reduces to two settings and one key from your 59API account. The sections below cover those exact values, the client rules that matter, the current token rates, and what to check if your first request does not go through.
The exact settings for your client
Open the environment configuration your Claude Code installation reads, and set these two values:
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 whole configuration surface for Claude Code and Claude Desktop. There is no SDK wrapper to install, no adapter package to maintain, and no custom client to keep in sync with upstream releases.
One version detail matters: Claude models work only through the genuine Claude Code or Claude Desktop client, and you need Claude Code 2.1.285 or newer. If you are on an older build, update the client first, then apply the settings and restart it so the environment values are picked up.
Once the client restarts, it reads the base URL and the auth token, and requests travel to https://api.59api.com. Because 59API meters by real token usage, your balance is consumed by the tokens your prompts and model responses actually consume. There is no seat to buy, no monthly subscription to cancel, and no contract to negotiate before your first call goes through.
Keep the key out of shared repositories. Treat it the same way you would treat any credential that can draw down a prepaid balance.
Know which client can call which model
This is where many relay setups quietly fail, so it is worth stating plainly. Claude models work only inside the genuine Claude Code or Claude Desktop client. They do not work through the OpenAI SDK, cURL, Codex, Cursor, Cherry Studio, Cline, OpenCode, or any other client, no matter how similar the request format looks.
Those OpenAI-compatible clients are still useful, but they pair with GPT, DeepSeek and other non-Claude, non-Gemini models. For Codex, OpenAI SDKs, cURL and OpenAI-compatible clients, use base_url https://api.59api.com/v1 and chat endpoint https://api.59api.com/v1/chat/completions.
Gemini follows its own path. 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 the practical rule for a developer running several tools at once: keep Claude Code pointed at the Claude settings, point your OpenAI-compatible tooling at the /v1 base URL for GPT, DeepSeek and similar models, and use Gemini CLI for Gemini. One 59API account and one API key can cover all of that, as long as each client uses the protocol its models actually speak.
What Claude requests cost on 59API
Setup is only half the decision; the other half is what a request costs once it starts flowing. Prices are per 1 million tokens, billing is in CNY, and the USD figures shown here use ¥7.2 = $1.
A few current Claude rates give you a useful sense of range. Claude Sonnet 5.5 (model id claude-sonnet-5-5) is $1.11 (¥8) for input and $5.56 (¥40) for output, with cache read at $0.0972 (¥0.7). Claude Opus 5.5 (model id claude-opus-5-5) is $1.53 (¥11) input and $7.22 (¥52) output, cache read $0.0694 (¥0.5). Claude Haiku 4.5 (model id claude-haiku-4-5-20251001) is $0.3472 (¥2.5) input and $1.67 (¥12) output, cache read $0.0278 (¥0.2).
Two worked examples make that concrete. For Claude Sonnet 5.5, 3M input plus 0.5M output tokens without cache costs $6.11 (¥44) on 59API, against an official list price reference of $11 (about ¥79.2), so 59API is about 56% of list price. For Claude Haiku 4.5, 5M input plus 1M output tokens without cache costs $3.4 (¥24.5) on 59API, against an official list price reference of $10 (about ¥72), so 59API is about 34% of list price.
Because billing follows actual token usage, a light day costs light. You are not paying for a tier you did not use.
Prepaid balance, top-ups, and optional cards
59API runs on a prepaid balance model. You add funds first, then usage draws down that balance as requests are made. There is no monthly fee, and the balance never expires, which means an unused top-up is not a deadline you have to race.
Top-ups are available at ¥10, ¥50, ¥100, ¥200, ¥500 and ¥1000, paid by WeChat Pay or bank card. Invoices are available, so if you need one for a company expense, it is there. Starting small is reasonable: a modest top-up is enough to validate the setup, confirm that your Claude Code client is talking to https://api.59api.com, and see real token consumption on your own workload before you commit to a larger balance.
Monthly and weekly cards are optional. If you do buy one, it has its own key, it can only call that family's models, and 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. Card quota and caps are metering units written in $, not official list-price dollars, so treat them as their own measure rather than a direct price comparison.
For most developers validating a setup, the prepaid balance alone is enough to get moving.
A first-run checklist that avoids guesswork
Before you blame the model, walk through this short sequence. First, confirm your client version: Claude Code needs to be 2.1.285 or newer, and it must be the genuine Claude Code or Claude Desktop client, since Claude models do not work through the OpenAI SDK, cURL or other clients.
Second, confirm the two values are exact. ANTHROPIC_BASE_URL=https://api.59api.com and ANTHROPIC_AUTH_TOKEN=YOUR_59API_KEY. A trailing slash, a missing scheme, or a leftover placeholder in the token will all break the call.
Third, restart the client so the environment is reloaded, then send a short prompt. A small request is enough to prove the path works and will show token consumption against your prepaid balance.
Fourth, pick your model id deliberately from the models 59API lists, and check the current rate for it before you start a long session. Rates are per 1 million tokens, so an expensive model with heavy output can move a balance quickly, while a smaller model handles routine tasks more cheaply.
If a request fails, the most common causes are a stale client version, a mistyped base URL, or a key that was copied with extra whitespace. Fix those three and retry.
Once the first prompt comes back, you have a working setup: one key, one host, prepaid billing without a monthly fee, and Claude Code running exactly as it does now, only pointed at 59API.
Prêt à commencer ?
Une seule clé pour Claude, GPT et d’autres modèles, facturée aux tokens réels, sans abonnement mensuel. Inscrivez-vous pour créer votre clé API ; les tarifs de chaque modèle sont sur la page Tarifs.
Inscription gratuite Tarifs