Run Codex through SoleAPI by changing one base URL
SoleAPI natively supports the OpenAI Responses protocol Codex uses — including the /v1/responses/compact and input_tokens endpoints Codex calls. 6 OpenAI models, automatic failover on rate limits and 5xx. Alipay top-ups, pay as you go, no monthly fee.
# ~/.zshrc / ~/.bashrc
export OPENAI_BASE_URL="https://api.soleapi.com/v1"
export OPENAI_API_KEY="sk-sole-..."
codex --model gpt-6-astraWhy a gateway instead of the official endpoint
Not a replacement for OpenAI — a layer on top: reliability, payment and billing, three things the vendor does not solve for you.
Automatic failover on 5xx / rate limits
Each model has several upstream channels. When OpenAI returns 500, overloaded or rate-limited, the gateway switches to a backup before the first frame, so Codex never sees the error.
Alipay top-ups, pay as you go
No overseas card, no subscription. 1 Credit = ¥1, billed per use; spend is split per model and per key in the console.
Native protocol, zero-buffer streaming
OpenAI Responses passes straight through with no translation; every SSE frame is forwarded as it arrives, so Codex streams exactly like a direct connection.
Connect Codex in three steps
Three steps, no changes to Codex itself.
Sign up for free credits
Register with an email and receive trial Credits — enough to wire up a real project.
Create an API key
Console → API Keys → New. Give the key a budget, restrict models or channels if you like.
Point at SoleAPI and start Codex
Swap the base URL for SoleAPI and the key for the one you just created; everything else stays.
# ~/.zshrc / ~/.bashrc
export OPENAI_BASE_URL="https://api.soleapi.com/v1"
export OPENAI_API_KEY="sk-sole-..."
codex --model gpt-6-astraModels and pricing for Codex
SoleAPI default channel price in Credits (1 Credit = ¥1); struck-through is the list price. Click a model for full pricing, protocols and uptime.
| Model | Context | Input (prompt) / M | Output (completion) / M | 7-day uptime |
|---|---|---|---|---|
| GPT-5.6 Lunagpt-5.6-luna | 1.05M | 98.7% | ||
| GPT-5.6 Terragpt-5.6-terra | 1.05M | 99.5% | ||
| GPT-5.5gpt-5.5 | 1.05M | — | ||
| GPT-5.6 Solgpt-5.6-sol | 1.05M | 99.5% | ||
| GPT-Image-2gpt-image-2 | — | — | — | |
| GPT-6 Astragpt-6-astra | 1.05M | 100.0% |
Same data as the model catalog, refreshed every 5 minutes. All 6 OpenAI models →
Common Codex errors and how the gateway handles them
These errors come from the official OpenAI API. Through SoleAPI the gateway retries and fails over before the first frame, so Codex usually never shows them.
stream disconnected before completionStream closed before completion
The official side closed the connection or stopped sending frames. SoleAPI: a disconnect before the first frame is retried on another channel; every upstream frame is forwarded as it arrives, unbuffered.
429 Too Many RequestsOfficial rate limit
One account ran out of RPM / TPM, or the Codex plan quota is exhausted. SoleAPI: several upstream keys share the quota; when one returns 429 the next takes over.
insufficient_quotaOfficial quota exhausted
The OpenAI account balance or plan quota is zero. SoleAPI: your balance lives on SoleAPI and tops up via Alipay any time; you get an email before it runs out.
401 Incorrect API key providedKey does not match the base URL
The base URL points at SoleAPI but the key is still the official one, or vice versa. SoleAPI: base URL and key come as a pair — api.soleapi.com/v1 goes with a key starting with sk-sole-.
FAQ
Is a Codex gateway safe? Can anyone see my code?
Keys, emails and other sensitive strings are masked before forwarding; transport is encrypted end to end; your requests are never used to train any model. Keys can be limited to models and budgets and revoked in one click.
How is this different from calling OpenAI directly?
Same protocol (Responses passed through natively, including compact and input_tokens), same models, plus three things: automatic failover when the official API fails, Alipay top-ups with CNY billing, and per-key usage and budget control.
Does it work with Claude Code and Gemini CLI too?
Yes. Anthropic Messages and Gemini generateContent are supported as well — point each tool at the SoleAPI base URL. All tools share one API key and one balance.
How do I top up, and is there a minimum?
Console → Wallet, Alipay accepted; 1 Credit = ¥1, billed per use, no monthly fee or minimum. You get an email before the balance runs out.
One base URL change and Codex runs reliably
Free credits on sign-up, pay as you go, no monthly fee.