Codex API proxy setup with 59API: base URL and key
Why Codex setup usually goes wrong
Most Codex friction is not the model. It is the configuration: a base URL that ends in the wrong place, a key pasted into the wrong field, or a client pointed at a host that expects a different protocol. Get those details right and the rest comes down to a model ID and a request.
59API removes the guesswork by giving every developer one account, one API key and one API host: https://api.59api.com. You point Codex at that host, paste your key, choose a model and start sending requests. There is no monthly fee and no subscription to configure before the first call.
For this guide, assume a hypothetical developer with Codex already installed and a funded 59API balance. We will cover the exact settings, the models that work with Codex, what those models cost per 1 million tokens, and how prepaid top-ups and optional cards fit into the picture.
Nothing here depends on a special build or a workaround. The steps are the same ones you would use for any OpenAI-compatible endpoint: set the base URL, set the key, confirm the chat endpoint. The one detail that deserves real attention is which model family you send to Codex, because Codex speaks to GPT, DeepSeek and other non-Claude, non-Gemini models.
One account, one key and a prepaid balance
59API is an independent third-party AI API relay, not an official channel for any model provider. That distinction matters when you read the numbers later: 59API sets its own rates, while official list prices appear only as a reference point for comparison.
Billing is prepaid. You top up a balance, and each request is charged according to the real token usage it consumes. There is no monthly fee, and your balance never expires. That makes a modest first top-up a practical way to test a workflow before committing to a larger balance.
Top-ups come in ¥10, ¥50, ¥100, ¥200, ¥500 and ¥1000, paid by WeChat Pay or bank card. Invoices are available if you need one for a team or a company. Billing is in CNY, and USD figures are shown at ¥7.2 = $1.
Because every request draws down the balance you funded, it is worth sizing the first top-up around the workload you actually expect to run. Optional monthly and weekly cards sit alongside the balance if you prefer a fixed commitment, but neither is required for setup. The balance key is all you need to begin with Codex.
The exact Codex settings
Here is the configuration in full. In your Codex configuration, set the following values:
- Base URL:
https://api.59api.com/v1 - Chat endpoint:
https://api.59api.com/v1/chat/completions - API key: the 59API key from your account
Then select a model ID. Useful starting points in the GPT and DeepSeek families include gpt-6.1-sol, gpt-5.6-sol, deepseek-v4-flash and MiniMax-M3. Paste the key exactly as issued, save the configuration and send a short test request to confirm the round trip.
One boundary is worth stating plainly. Codex, OpenAI SDKs, cURL and OpenAI-compatible clients such as Cursor, Cherry Studio, Cline and OpenCode work with GPT, DeepSeek and other non-Claude, non-Gemini models only. Claude models work only through the genuine Claude Code or Claude Desktop client, version 2.1.285 or newer, and Gemini models use Google's native protocol through Gemini CLI. Neither belongs in a Codex configuration.
Keeping that separation in mind from the start saves the kind of debugging session where the request is well formed but the model family never matches the protocol.
What the models cost per 1 million tokens
Because 59API charges by real token usage, the rate card is the part you will actually watch. Prices below are per 1 million tokens, with the USD figure shown at ¥7.2 = $1.
- GPT-6.1 Sol (
gpt-6.1-sol): input $0.1847 (¥1.33), output $0.9264 (¥6.67), cache read $0.0375 (¥0.27) - GPT-5.6 Sol (
gpt-5.6-sol): input $0.3472 (¥2.5), output $1.94 (¥14), cache read $0.0278 (¥0.2) - DeepSeek V4 Flash (
deepseek-v4-flash): input $0.2778 (¥2), output $1.11 (¥8), cache read $0.006944 (¥0.05) - MiniMax M3 (
MiniMax-M3): input $0.1389 (¥1), output $0.5556 (¥4), cache read $0.0278 (¥0.2)
For a coding workflow, input tokens tend to dominate because context files, diffs and instructions travel with every request. That makes the input rate the number to compare first, and the output rate the one to watch when a task produces long files or detailed explanations.
Cache read pricing matters too when your client reuses a stable context block. At $0.0375 (¥0.27) per 1 million tokens for GPT-6.1 Sol and $0.006944 (¥0.05) for DeepSeek V4 Flash, repeated context is billed at a fraction of the standard input rate.
Two worked examples
Concrete arithmetic is more useful than percentages on a rate card. Consider a hypothetical Codex session that processes 5 million input tokens and generates 1 million output tokens without cache, using GPT-6.1 Sol. On 59API that run costs $1.85 (¥13.32). At the official list price of $20, about ¥144, the same run sits at about 9% of list price.
Now take a lighter session on GPT-5.6 Sol: 2 million input tokens and 0.5 million output tokens without cache. On 59API the cost is $1.67 (¥12). At the official list price of $18, about ¥129.6, that is about 9% of list price as well.
Two things follow from these examples. First, a prepaid balance of ¥50 or ¥100 covers a meaningful amount of ordinary daily coding work before it needs attention. Second, the gap between 59API pricing and official list prices is large enough that the model choice inside Codex matters more than the top-up size.
Official list prices exist only for Claude and GPT, so comparisons like these are meaningful for the GPT models you would point Codex at. For other families, the per-token rates on the 59API card are the reference to work from.
Cards, keys and your first request
Cards are optional, but they are useful when you would rather commit to a fixed block of usage. The Weekly Card G-PRO $1100 (GPT, 7 days) is priced at $40.56 (¥292), with quota $1100 and a weekly cap of $1100, draining at the card's metering price × 2.4. Its reference value at official list prices is about $305.56 (¥2200).
A card behaves differently from a balance, and the differences are worth knowing before you wire it into a client. A card has its own key, can call only 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.
With that settled, the shortest path to trying 59API is simple: create the account, make a top-up, copy the API key, set the base URL to https://api.59api.com/v1, confirm the chat endpoint, and send one short request. If the response comes back, the relay is configured correctly and you can move straight on to choosing the model that fits the task.