Codex API proxy setup with 59API: the exact settings
Codex is ready, but the model provider is not
Codex is installed, your prompt is ready, and then the plumbing gets in the way. You are hunting for a base URL, wondering which endpoint expects the request, and second-guessing whether the model you want can even run inside Codex. None of that friction comes from your code. It comes from configuration, and configuration should be boring.
59API makes it boring. It is an independent third-party AI API relay: one account, one API key and one API host, https://api.59api.com, serving Claude, GPT, Gemini, DeepSeek and other models. For Codex, you point the client at the OpenAI-compatible path and pick one of the supported non-Claude, non-Gemini models.
Cost stays predictable as well. 59API runs on a prepaid balance and charges per request according to real token usage. There is no monthly fee, and your balance never expires, so an unused top-up is not a deadline you have to race.
This guide walks the whole path: create an account, add funds, paste the exact URL and key into Codex, choose a model, and check what a real request costs. No detours, no unofficial wrappers — just a direct configuration you can verify in a few minutes.
Create your account and fund the balance
Start at 59api.com and create your account. Once you are inside, copy your API key and keep it somewhere safe, because the key you need for Codex is a single string that replaces the provider-specific credential you would normally paste into a client.
Next, top up. 59API works on prepaid balance, so a request only works once there is money available to draw from. The available top-up amounts are:
- ¥10, ¥50, ¥100, ¥200, ¥500, ¥1000
You can pay by WeChat Pay or bank card, and invoices are available if you need one for your records. Because billing is per request and based on actual token usage, a small top-up is a perfectly reasonable way to test the connection before committing to a larger one.
Two details worth internalising now. First, there is no monthly fee attached to the balance, so you are not signing up for a subscription you have to remember to cancel. Second, the balance never expires, which means the money you add stays available until you spend it. Once the balance is topped up and the key is copied, the account side of the setup is done and the client side can begin.
Point Codex at the right URL and key
Here is the part developers search for, so here it is in full. Codex, OpenAI SDKs, cURL and OpenAI-compatible clients such as Cursor, Cherry Studio, Cline and OpenCode all talk to 59API through the same two settings:
- Base URL:
https://api.59api.com/v1 - Chat endpoint:
https://api.59api.com/v1/chat/completions
Set the base URL in your Codex configuration to https://api.59api.com/v1 and replace the placeholder YOUR_59API_KEY with the key you copied from your 59API account. The host itself is https://api.59api.com, and the /v1 suffix is what produces the chat endpoint above.
Do not add a trailing chat path to the base URL field. Codex builds the request path itself, so pasting https://api.59api.com/v1/chat/completions as the base URL is a classic way to produce a duplicated path and a confusing error. The base URL ends at /v1, and the endpoint above is what the client resolves to.
One boundary is worth stating plainly, because it saves a lot of debugging time. Claude models work only through the genuine Claude Code or Claude Desktop client (Claude Code 2.1.285 or newer), never through the OpenAI SDK, cURL or other clients. Gemini models use Google's native protocol only and do not work on /v1/chat/completions. So inside Codex, stay with GPT, DeepSeek and other non-Claude, non-Gemini models.
Choose a model Codex can actually call
With the connection in place, the next decision is which model to name in your Codex request. 59API bills per 1 million tokens, with USD figures shown at ¥7.2 = $1. A few models worth knowing for Codex work:
- GPT-6.1 Sol (
gpt-6.1-sol): input $0.1847 (¥1.33), output $0.9264 (¥6.67), cache read $0.0375 (¥0.27) per 1 million tokens. - 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). - Qwen3.7 Plus (
qwen3.7-plus): input $0.1389 (¥1), output $0.4167 (¥3), cache read $0.0417 (¥0.3).
Use the model id exactly as written, including the punctuation, because that string is what the API expects. If you are unsure where to start, gpt-6.1-sol is a sensible default for everyday Codex sessions, while qwen3.7-plus is a low-cost option when the task is mostly mechanical.
Because you are billed on real token usage rather than a seat, the model you pick changes the bill directly. That makes it worth checking the numbers before a long session rather than after it.
See what a real request costs
Let us make the pricing concrete with two worked examples, both without cache reads.
For GPT-6.1 Sol, a run of 5M input tokens plus 1M output tokens costs $1.85 (¥13.32) on 59API. The same run at official list price would be $20 (about ¥144), so 59API comes to about 9% of list price.
For GPT-5.6 Sol, 2M input tokens plus 0.5M output tokens costs $1.67 (¥12) on 59API. At official list price the same usage is $18 (about ¥129.6), which again puts 59API at about 9% of list price. Official list price here is only a reference point for comparison, not a claim of any partnership or authorisation.
Two habits make this predictable in practice. First, start a new session with a short test request rather than a large batch, so you confirm the model id and key before spending meaningful balance. Second, keep an eye on the prepaid balance in your 59API account, because it is the live view of what your Codex sessions are consuming.
Since 59API charges only for what is actually used, an abandoned or short session costs little. There is no monthly fee to keep paying while you evaluate a model, and your unused balance remains available.
Verify the setup, then keep going
Send one small request through Codex once the base URL and key are saved. If it returns a normal completion, the connection is working. If it fails, check the three things most likely to be wrong: the base URL should be https://api.59api.com/v1 with no chat path appended, the key should be your real 59API key rather than the YOUR_59API_KEY placeholder, and the model should be one of the non-Claude, non-Gemini models listed above.
Monthly and weekly cards are optional. If you prefer a card, it comes with 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 read as official prices.
For GPT, the entry card is G-PRO Standard (30 days) at $160.42 (¥1155), with quota $4500 and a weekly cap of $1700, draining at the card's metering price × 2.4. The weekly option is G-PRO $1100 (7 days) at $40.56 (¥292), quota $1100, weekly cap $1100.
That is the whole setup: one account, one key, one host, two URLs, and a model id. Try it on a small prepaid balance, confirm the numbers on your first real session, and let Codex do the work.
शुरू करने के लिए तैयार?
Claude, GPT और अन्य मॉडलों के लिए एक ही key, असली token उपयोग पर बिलिंग और कोई मासिक शुल्क नहीं। साइन अप करके अपनी API key बनाएं; हर मॉडल की दरें मूल्य पेज पर हैं।
मुफ़्त साइन अप मूल्य