59API

← Back to all guides

Claude Code setup with 59API: 2 settings, real token pricing

Claude Code · EN · 2026-11-07

Claude Code works, but the endpoint you point it at decides the bill

Claude Code is easy to love and awkward to wire to a third-party endpoint. What most developers actually want is simple: one account, one API key, a single host, and billing that follows real token usage instead of a flat monthly fee. That is exactly the shape of 59API, an independent third-party AI API relay that puts Claude, GPT, Gemini, DeepSeek and other models behind one API host, https://api.59api.com, under one account and one API key.

Here is the short version of what that means in practice. You keep a prepaid balance, 59API charges per request based on real token usage, there is no monthly fee, and the balance never expires. Monthly and weekly cards are optional, so you can start with pay-as-you-go and only consider a card once your usage pattern calls for one. Top-ups come in ¥10, ¥50, ¥100, ¥200, ¥500 and ¥1000, paid by WeChat Pay or bank card, and invoices are available when you need documentation.

That combination matters for a specific reason: the setup below does not ask you to restructure how you work. You keep Claude Code, point it at a different base URL, and paste one key. Everything that follows is a concrete configuration step, a client rule worth knowing, or a price you can check against a reference figure.

The entire Claude Code setup is two environment variables

Define two variables and nothing else:

Replace the placeholder with the API key issued to your 59API account, then restart Claude Code so the client picks up the new environment. From that point, requests go to the 59API host instead of the default endpoint, and the same account key also covers the other model families available through 59API.

Two details deserve to be treated as hard rules rather than suggestions. First, Claude models work only through the genuine Claude Code or Claude Desktop client, and the client needs to be version 2.1.285 or newer. Second, do not try to route Claude through the OpenAI SDK, cURL or a third-party editor integration. That path will not serve Claude models, and no amount of URL tweaking changes it.

Keep the key out of shared repositories. A local environment file or your shell profile is enough, and it keeps access to your balance under your control. If a request fails, check the two variables first: a missing base URL or a stray space around the token are the most common setup mistakes.

Know which client speaks which protocol before you switch

Claude Code is not the only client that can talk to 59API, but the protocol boundaries are strict. Codex, the OpenAI SDKs, cURL and OpenAI-compatible clients such as Cursor, Cherry Studio, Cline and OpenCode connect with base_url https://api.59api.com/v1 and the chat endpoint https://api.59api.com/v1/chat/completions. Those clients serve GPT, DeepSeek and other non-Claude, non-Gemini models only.

Gemini follows a third path. In Gemini CLI, set GOOGLE_GEMINI_BASE_URL=https://api.59api.com and GEMINI_API_KEY=YOUR_59API_KEY. Gemini models use Google's native protocol only, so they are not OpenAI-compatible and do not work on /v1/chat/completions.

Why does this matter? Because it keeps your expectations accurate. When you point a client at 59API, the model family you can call is determined by the client's protocol, not by the fact that 59API hosts the model. Claude models stay in Claude Code or Claude Desktop. Gemini models stay in Gemini CLI. The rest is reachable through the OpenAI-compatible route.

Once you accept that split, moving between them is mostly a matter of changing environment variables and model ids. The host and the key stay the same, which is exactly the kind of consistency that makes a relay worth adopting.

What Claude models cost per 1 million tokens

Billing is in CNY, with USD figures shown at ¥7.2 = $1, and prices are per 1 million tokens. 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); the official list price reference is $2 / $10. Claude Haiku 4.5 (claude-haiku-4-5-20251001) is $0.3472 (¥2.5) input and $1.67 (¥12) output, with cache read $0.0278 (¥0.2), against a $1 / $5 reference. Claude Opus 5.5 (claude-opus-5-5) is $1.53 (¥11) input, $7.22 (¥52) output and $0.0694 (¥0.5) cache read, against $4 / $20.

Here is a worked example. Claude Sonnet 5.5 with 3M input plus 0.5M output tokens and no cache costs $6.11 (¥44) on 59API. At the official list price of $11 (about ¥79.2), 59API is about 56% of list price.

For a lighter model, Claude Haiku 4.5 with 5M input plus 1M output tokens and no cache is $3.4 (¥24.5) on 59API, compared with $10 (about ¥72) at official list price — about 34% of list price.

Because 59API meters by real token usage, the practical move is to pick a model id that matches the job and watch the per-request cost, instead of estimating a flat fee you pay whether or not you use the tool.

Optional cards for predictable, family-specific usage

Cards sit alongside the prepaid balance, not instead of it. 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 dollars, not official list-price dollars, so they should not be converted into official prices. Card usage drains at the card's metering price × 2.4.

For example, C-PRO Entry (Claude, 30 days) is $83.19 (¥599), with quota $610 and weekly cap $230; its reference value at official list prices is about $169.44 (¥1220). On the shorter side, the weekly C-PRO $290 (Claude, 7 days) is $40.14 (¥289), with quota $290 and weekly cap $290, and a reference value of about $80.56 (¥580).

When does a card earn its place? When you already know you will use one model family heavily inside a fixed window and want that usage separated from everything else. If your usage is irregular or you like to move between models, the prepaid balance is simpler: no expiry, no rollover rules to remember, and no monthly fee either way. Cards are optional by design, so you decide after you see real usage on 59API.

A short checklist before you make your first request

Run through this once and the rest is just work:

That is the whole setup: two variables, one key, one host, and billing that matches what you actually send. Try it on 59API with a small top-up, connect Claude Code with the settings above, and let the per-token numbers tell you which model earns its place in your workflow.

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