59API

← Back to all guides

Claude Code setup on 59API: two variables, one key

Claude Code · EN · 2026-11-19

The setup problem is usually two lines, not a research project

Most developers who want to point Claude Code at a different endpoint are not blocked by model choice. They are blocked by plumbing: which URL, which variable name, which client is even allowed to carry the traffic. Get one of those wrong and the connection simply fails, with no obvious hint about where the mismatch happened. The good news is that the whole 59API configuration for Claude Code is small enough to read in one sitting: one account, one API key, one API host at https://api.59api.com, and two environment variables.

59API is an independent third-party AI API relay. That means it sits between your client and model providers, and it bills by real token usage against a prepaid balance rather than through a monthly subscription. There is no monthly fee, and your balance never expires. You top up only what you plan to spend, then use the same key across the model families you actually need.

For a Claude Code user, the practical appeal is simple: the setup surface stays tiny. You are not wiring together a provider SDK, translating request shapes, or maintaining separate credentials for every project. You set a base URL, set a token, and start working. Everything below is the exact configuration, the exact model identifiers, and the exact per-token numbers you need to make that decision with confidence.

The exact environment variables for Claude Code

Here is the complete configuration. Set ANTHROPIC_BASE_URL to https://api.59api.com and set ANTHROPIC_AUTH_TOKEN to YOUR_59API_KEY, where the key is the one issued to your 59API account.

Two details matter more than they look. First, 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, so if you attempt that route you will be debugging a path that was never intended to work. Second, there is a clean separation between the two protocols 59API exposes: the base URL above for Claude in the official client, and https://api.59api.com/v1 with the chat endpoint https://api.59api.com/v1/chat/completions for GPT, DeepSeek and other non-Claude, non-Gemini models in Codex, OpenAI SDKs, cURL and OpenAI-compatible clients such as Cursor, Cherry Studio, Cline and OpenCode.

Gemini follows its own rule again: Google native protocol only, through Gemini CLI, using GOOGLE_GEMINI_BASE_URL=https://api.59api.com and GEMINI_API_KEY=YOUR_59API_KEY. Gemini models are not OpenAI-compatible and do not work on /v1/chat/completions. Knowing these boundaries before you start saves you from the most common wasted setup effort.

Claude model IDs and what each token costs

Once the two variables are in place, you choose a model by its identifier. Prices on 59API are per 1 million tokens, billed in CNY, with USD figures shown at ¥7.2 = $1. Three Claude options show the range clearly.

Read those three lines as a routing decision rather than a shopping list. If your workload is dominated by long input contexts and short replies, cache reads and input pricing dominate the bill. If it is dominated by generated output, the output column matters more. Haiku 4.5 is priced at $0.3472 (¥2.5) input and $1.67 (¥12) output, which makes it the lightest of the three on both axes. Fable 5 sits at the other end of the range with output at $18.06 (¥130) per 1 million tokens.

Because billing is charged per request by real token usage, the numbers above are the whole pricing story for these models: no seat fee, no subscription, no separate platform charge layered on top. You can start with a small balance, watch actual consumption, and change models without renegotiating anything.

What a real workload costs on 59API

Per-token rates are easier to judge against a concrete workload. Consider a hypothetical run of Claude Sonnet 5.5 with 3M input tokens and 0.5M output tokens, no cache. On 59API that comes to $6.11 (¥44). At the official list price of $11 (about ¥79.2), the same run is about 56% of list price.

Now take a hypothetical run of Claude Haiku 4.5 with 5M input tokens and 1M output tokens, again without cache. On 59API the cost is $3.4 (¥24.5). At the official list price of $10 (about ¥72), that is about 34% of list price. The official list price is only a reference point here, not a claim of any partnership or authorisation.

Two patterns stand out. First, the gap between list price and 59API is not a flat percentage across models; it depends on the model and the mix of input and output. Second, cache reads are billed separately and are cheap relative to fresh input, which matters if your workflow reuses a large fixed context. If a card would suit your usage better than pay-as-you-go, that is an option too, but the per-token path is the simplest place to start because it tracks usage directly with no quota to manage.

For a budget-conscious experiment, the smallest top-up is ¥10, and larger steps are ¥50, ¥100, ¥200, ¥500 and ¥1000, paid by WeChat Pay or bank card. Invoices are available. With balance that never expires, a small top-up is a low-friction way to test the connection end to end before committing to a larger one.

Optional cards, and the rules that keep them predictable

Monthly and weekly cards are optional. If you prefer a prepaid quota structure, one Claude option is C-PRO Starter, valid for 30 days at $83.19 (¥599), with quota $610 and a weekly cap of $230. It drains at the card metering price × 2.4, and its reference value at official list prices is about $169.44 (¥1220). Larger Claude tiers exist as well, including weekly cards, so you can match the card length to the way you actually work.

Three card rules are worth memorising before you buy one. A card has its own key, and it can only call that family's models. A card 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 treat them as card mechanics rather than as a comparable price.

That separation is what makes the two modes predictable. Wallet key, wallet billing, no expiry, charged by real token usage. Card key, card quota, fixed window, family locked. For a Claude Code user, start with the two environment variables, keep the client requirement in mind, and let the per-token rates tell you which model fits the job. If usage grows into a predictable monthly rhythm, the cards are there, but they are never a prerequisite for getting started.

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