59API

← Retour aux guides

59API API relay: one key for Claude Code, Codex and Gemini CLI

Claude Code · EN · 2026-11-06

The problem is not one key, it is five

Most developers are not short on API keys. They are short on patience. A single project might send Claude requests from the genuine Claude Code or Claude Desktop client, GPT requests through an SDK, and Gemini requests through Gemini CLI, then fall back to an open model for a cheap scripted task. Each provider means another account, another dashboard, another balance to top up, and another secret to paste into a different configuration file. The result is a familiar mess: settings that drift, credentials scattered across shell profiles, and no clear view of what a busy day actually costs.

59API is an independent third-party AI API relay built to collapse that setup. One account gives you one API key and one API host, https://api.59api.com, which fronts Claude, GPT, Gemini, DeepSeek and other models. You keep a prepaid balance, and each request is charged per request by real token usage. There is no monthly fee, and the balance never expires. Monthly and weekly cards are optional, so you can start small and decide later.

The appealing part for a developer is that the routing problem becomes a configuration problem. Each model family still has its own protocol and its own client, but the account, the top-up flow and the billing story stay the same. In this guide we will walk through the exact settings for Claude Code, Codex and Gemini CLI, then look at what a few of these calls cost. The goal is a setup you can finish in a few minutes and still understand a month later.

Claude Code: two environment variables

Claude models on 59API work only through the genuine Claude Code or Claude Desktop client, using Claude Code 2.1.285 or newer. They do not run through the OpenAI SDK, cURL or other clients, and that limit is worth internalising before you start, because it decides where your Claude traffic can live.

For Claude Code or Claude Desktop, set two values:

Replace YOUR_59API_KEY with the key from your 59API account. That is the whole setup. There is no separate Claude account to register, no second token to generate, and no second balance to watch. The same 59API key you use elsewhere in your workflow is the one Claude Code sees here.

Because 59API meters by real token usage, it is worth knowing which Claude model you are pointing at. Claude Sonnet 5.5, with model id claude-sonnet-5-5, is listed at $1.11 („8) per 1 million input tokens and $5.56 („40) per 1 million output tokens, with cache read at $0.0972 („0.7). For a heavier session, Claude Opus 5.5 (claude-opus-5-5) is listed at $1.53 („11) input and $7.22 („52) output, with cache read at $0.0694 („0.5). Prices are per 1 million tokens, billing is in CNY, and the USD figures shown use „7.2 = $1.

Codex and OpenAI-compatible clients: the /v1 route

Codex, OpenAI SDKs, cURL and OpenAI-compatible clients such as Cursor, Cherry Studio, Cline and OpenCode all talk to 59API through the OpenAI-style route. Use the base URL https://api.59api.com/v1 and the chat endpoint https://api.59api.com/v1/chat/completions.

This route serves GPT, DeepSeek and other non-Claude, non-Gemini models. Claude models are not available here, and Gemini models are not available here either, because Gemini speaks Google's native protocol rather than the OpenAI-compatible one. Getting this distinction right saves the kind of afternoon where a request fails for reasons that have nothing to do with your code.

Again, there is no provider-specific account to create. Your 59API key goes into the same field where you would normally put an OpenAI key, and the base URL is the only other change. If you are writing a small Python script with an OpenAI SDK, the shape of the integration stays familiar; you are swapping the host, not rebuilding the client.

The models available on this route include GPT, DeepSeek and other listed families. A few rates to keep in mind: GPT-6.1 Sol (gpt-6.1-sol) is $0.1847 („1.33) input and $0.9264 („6.67) output per 1 million tokens, with cache read at $0.0375 („0.27). GPT-5.6 Sol (gpt-5.6-sol) is $0.3472 („2.5) input and $1.94 („14) output, with cache read at $0.0278 („0.2). DeepSeek V4 Flash (deepseek-v4-flash) is $0.2778 („2) input and $1.11 („8) output, with cache read at $0.006944 („0.05).

Gemini CLI: Google's native protocol

Gemini models on 59API use Google's native protocol, which means the Gemini CLI is the client to use. They are not OpenAI-compatible and do not work on /v1/chat/completions, so do not try to force them into an OpenAI-style request and wonder why the response never arrives.

The Gemini CLI setup is two environment variables:

That is the Gemini equivalent of the Claude Code setup, and it uses the same 59API key. Across all three clients, the pattern is consistent: one key, one host, three small configuration changes, and no new vendor relationship to manage.

The available Gemini models are priced per 1 million tokens like everything else. Gemini 2.5 Flash (gemini-2.5-flash) is $0.2083 („1.5) input and $1.67 („12) output, with cache read at $0.0208 („0.15). Gemini 3.1 Pro (gemini-3.1-pro) is $1.39 („10) input and $8.06 („58) output, with cache read at $0.1389 („1). Gemini 4 Argon (gemini-4-argon) is $1.39 („10) input and $6.67 („48) output, with cache read at $0.0694 („0.5).

Once these values are in place, you can pick a model id and start making requests. If a call fails, check the protocol first: Claude in Claude Code, Gemini in Gemini CLI, and everything else on the /v1 route.

What this costs, and what happens to unused balance

Since 59API charges by real token usage against a prepaid balance, it is helpful to see a request in concrete terms. Take GPT-6.1 Sol with 5M input and 1M output tokens and no cache: that is $1.85 („13.32) on 59API, against an official list price of $20 (about „144) — roughly 9% of list price. Now take Claude Sonnet 5.5 with 3M input and 0.5M output tokens and no cache: $6.11 („44) on 59API, against an official list price of $11 (about „79.2) — about 56% of list price. Official list prices are reference prices only, and 59API is an independent third-party relay rather than an official channel.

Top-ups are simple: „10, „50, „100, „200, „500 or „1000, paid by WeChat Pay or bank card, with invoices available. Because the balance never expires, a small top-up is a low-commitment way to test the setup across all three clients before committing to a larger amount.

Cards are optional and behave differently from wallet balance. 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 converted into official prices. For example, the C-PRO Standard plan (Claude, 30 days) is $152.64 („1099) with quota $1100 and a weekly cap of $410, while the weekly G-PRO $1100 card (GPT, 7 days) is $40.56 („292) with quota $1100 and a weekly cap of $1100.

For most developers, the sensible first move is the wallet: one key, exact settings, no expiry, and costs you can read per request. Add a card only when you know your usage pattern and want the flat structure.

Start with one key and three small edits

The reason to try 59API is not that it removes every decision. It removes the boring ones. You no longer juggle three accounts and three balances. You no longer wonder which secret belongs to which tool. You set ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN for Claude Code, point Codex and OpenAI-compatible clients at https://api.59api.com/v1, and set GOOGLE_GEMINI_BASE_URL and GEMINI_API_KEY for Gemini CLI.

From there, the choice becomes which model fits the job, and the bill becomes something you can read off a rate table instead of guessing. Claude Sonnet 5.5 for long Claude Code sessions, GPT-6.1 Sol for lighter OpenAI-style work, Gemini 2.5 Flash for quick native-protocol calls — each with a published per-million-token rate.

One account, one API key, one API host. That is a short setup, and it is the kind of simplification you feel the first time you change a model id and nothing else breaks.

Docs

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