Codex API proxy setup with 59API: exact URL and key
Why Codex setup usually turns into a scavenger hunt
Codex is fast to launch, but pointing it at a new API proxy usually turns into a short scavenger hunt: which base URL, which endpoint, which key field does this client actually read, and which model id is spelled correctly? Get one of those wrong and you get a rejected request, an empty completion, or a client that never reaches the provider you meant to use. The purpose of this guide is to remove the hunt. Setting up Codex with 59API takes two connection values, one host, and one key, and then it is a matter of choosing a model and topping up a balance.
59API is an independent third-party AI API relay. It is not an official OpenAI channel, and it does not present itself as one. What it does offer is a single account, a single API key, and a single API host at https://api.59api.com, serving GPT, DeepSeek, and other non-Claude, non-Gemini models through the OpenAI-compatible path that Codex expects. Billing is per request, based on real token usage. There is no monthly fee, no plan tier to negotiate, and no separate account for each model family. Point Codex at the host, paste the key, choose a model id, and the plumbing is done.
The exact settings to put into Codex
Here is the whole configuration. In your Codex API settings, set the base URL to https://api.59api.com/v1 and set the chat endpoint to https://api.59api.com/v1/chat/completions. Then set your API key field to YOUR_59API_KEY, replacing the placeholder with the key issued to your 59API account.
Three details are worth getting right the first time. First, the base URL carries the /v1 suffix, because that is the path the chat endpoint sits on. Second, the key is a single value used across models, so there is no per-provider key juggling. Third, this configuration covers Codex and the other OpenAI-compatible clients, which means the same host and key can serve cURL calls, OpenAI SDKs, and clients such as Cursor, Cherry Studio, Cline, and OpenCode.
One boundary is important enough to state plainly. Claude models work only through the genuine Claude Code or Claude Desktop client, and Gemini models use Google's native protocol through Gemini CLI. Neither belongs in a Codex configuration. Codex, the OpenAI SDKs, cURL, and other OpenAI-compatible clients pair with GPT, DeepSeek, and other non-Claude, non-Gemini models. Keeping that line clean means fewer confusing errors later, because you will never be waiting on a model that the protocol you just configured cannot carry.
One key, one host, one prepaid balance
59API runs on a prepaid balance model. You top up, then requests are charged per request according to real token usage, and there is no monthly fee attached to the account. The balance never expires, so an unused top-up is not a deadline you have to race. Monthly and weekly cards are optional, which means you can start with a small balance and decide later whether a card fits your workflow better.
Top-ups are available at ¥10, ¥50, ¥100, ¥200, ¥500, and ¥1000, paid by WeChat Pay or bank card. Invoices are available for those who need them for accounting. For a first run, the ¥10 or ¥50 level is enough to confirm that Codex is talking to the relay correctly before you commit to a larger balance.
Billing is in CNY, and USD figures are shown at ¥7.2 = $1. That conversion rate is applied consistently across the price sheet, so you can compare a rate in dollars with the yuan figure beside it without doing your own arithmetic. The practical result is that your Codex bill is a function of the tokens you actually send and receive, not of a subscription you forgot to cancel. If a session is short, the spend is short. If a long refactor generates a large context, the cost reflects that context.
What Codex calls will cost at 59API rates
All rates below are per 1 million tokens. For GPT-6.1 Sol (model id gpt-6.1-sol), input is $0.1847 (¥1.33), output is $0.9264 (¥6.67), and cache read is $0.0375 (¥0.27). For GPT-5.6 Sol (model id gpt-5.6-sol), input is $0.3472 (¥2.5), output is $1.94 (¥14), and cache read is $0.0278 (¥0.2). DeepSeek V4 Flash (model id deepseek-v4-flash) comes in at $0.2778 (¥2) input, $1.11 (¥8) output, and $0.006944 (¥0.05) cache read. Qwen3.7 Plus (model id qwen3.7-plus) lists $0.1389 (¥1) input, $0.4167 (¥3) output, and $0.0417 (¥0.3) cache read.
Two worked examples make the arithmetic concrete. For GPT-6.1 Sol, 5M input plus 1M output tokens without cache costs $1.85 (¥13.32) on 59API, against an official list price reference of $20 (about ¥144), so 59API is about 9% of list price. For GPT-5.6 Sol, 2M input plus 0.5M output tokens without cache costs $1.67 (¥12) on 59API, against an official list price reference of $18 (about ¥129.6), also about 9% of list price. Those are reference comparisons, not a promise about every workload, but they show how a coding session with a large context can still land on a modest prepaid balance.
Verify the connection, then pick your model
After saving the base URL, endpoint, and key, run a small request in Codex and confirm that the model id matches one of the ids exactly, including case. Model ids such as gpt-6.1-sol, gpt-5.6-sol, deepseek-v4-flash, and qwen3.7-plus are copied directly into the request. A close-but-wrong id is the most common reason a correct configuration still fails, so paste it rather than retype it.
Once the first request succeeds, the next decision is which model earns its place in your workflow. A cheaper model such as Qwen3.7 Plus or DeepSeek V4 Flash can handle routine edits, while a GPT model can be reserved for the harder reasoning steps. Switching does not require a new key, a new host, or a new account, because the same 59API balance covers the traffic.
If your usage pattern becomes predictable, optional cards add another route. Each card has its own key, can only call that family's models, and is paid only from the card, with no fallback to wallet balance and no draw from balance on a card. Unused quota does not roll over. For example, the weekly G-PRO $1100 card costs $40.56 (¥292) for 7 days with a quota of $1100 and a weekly cap of $1100, draining at the card's metering price × 2.4. Start with prepaid balance, get comfortable, and upgrade when the numbers tell you to. Either way, 59API keeps the setup to one URL and one key.
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