How to Choose and Use a Codex Relay
A complete decision path from selection to setup
Codex CLI is OpenAI’s terminal coding tool. Accessing the official API directly from China is expensive and hard, so relay services become the practical choice. But relay quality varies widely: a bad pick means rate limits and lag at best, a vanished service at worst. This guide is not about coding tips, it is about how to choose and how to set up.
// Why a Relay
1. Why Codex Needs a Relay
Connecting Codex CLI directly to OpenAI’s official API has three real obstacles in China: unstable network requiring a VPN, official support for overseas credit cards only, and higher cost at official pricing. A relay solves all three at once.
| Aspect | Official Direct | Relay |
|---|---|---|
| Network | Needs VPN, drops often | China direct, no VPN |
| Payment | Overseas credit card | RMB / WeChat / Alipay |
| Price | Official rate | Usually 0.8–1.5x, some lower |
| Onboarding | Signup + card binding | Instant, most give free credit |
💡 A relay is not piracy. Legit relays resell and meter the official API. The key is picking a stable, transparent one.
// Selection Criteria
2. Six Dimensions for Picking a Codex Relay
Do not judge by price alone. A cheap relay that rate-limits and throws 502s constantly costs more in practice than a slightly pricier stable one. Judge by the priority below.
1. Model Support: Does It Actually Support Codex / GPT-5
This is the first hard requirement. Some relays claim OpenAI support but only offer GPT-4o, not the models Codex CLI needs. Confirm it explicitly supports codex or GPT-5 and provides /v1/responses or a Codex-compatible endpoint.
2. Stability: Availability and Latency
Check whether it publishes availability (99.9% is the top standard) and has a status page. Poor stability shows as peak-hour 502s, rate limits, and slow responses. Prefer relays with multi-route failover.
3. Price Multiplier: Not Just the Number
Multiplier = relay price / official price. 1.0x is the official rate; below 1.0x, be wary of downgraded models. A reasonable range is 0.8–1.5x.
| Multiplier | Meaning | Judgment |
|---|---|---|
| < 0.7x | Well below cost | Suspect downgrade / fake model |
| 0.8–1.2x | Normal range | Focus on stability |
| 1.3–1.5x | Slightly pricey | OK if stability is excellent |
| > 1.5x | Expensive | Needs extra value (invoice / SLA) |
4. China Direct & Payment
Confirm it connects without a VPN and supports RMB payment. This is a must for developers in China.
5. Free Credit: Try Before You Pay
Legit relays usually give a small free credit. Always test that Codex works end-to-end with the free credit before topping up. Never make a large deposit upfront.
6. Invoicing & Compliance
For reimbursement, confirm it can issue invoices and has a stable company entity. Individual developers can skip this.
// Pitfalls
3. Common Pitfalls
- Fake Codex support: the page says "supports OpenAI" but Codex CLI cannot connect — always test with free credit first.
- Silent downgrade: claims GPT-5 but returns GPT-4o-mini quality; be especially wary of absurdly cheap relays.
- Deposit-and-vanish: new relays with no reputation pushing large deposits / bonus tiers. Test small for 1–2 weeks first.
- Opaque rate limits: no stated concurrency or rate limits, then frequent 429s in practice.
- No status page: when things break you cannot tell if it is your config or their outage.
⚠️ The simplest reliability test: run a real Codex task on the free credit, watch for downgrades and rate limits, then decide how much to deposit.
// Setup
4. After Choosing: Codex CLI Setup
Once you pick a relay, connecting Codex CLI takes three steps: get the Base URL and API Key, set environment variables, and verify.
1. Install Codex CLI
npm install -g @openai/codex
# or
brew install codex2. Configure Base URL and Key
Get the Base URL and API Key from the relay dashboard and set env vars:
export OPENAI_BASE_URL="https://your-relay-host/v1"
export OPENAI_API_KEY="sk-your-key"Or write to Codex’s config file ~/.codex/config.toml:
[model_providers.relay]
name = "relay"
base_url = "https://your-relay-host/v1"
env_key = "OPENAI_API_KEY"
[profiles.default]
model_provider = "relay"
model = "gpt-5-codex"3. Verify
codex "write a Python function for the Fibonacci sequence"If it returns code, you are connected. A 401 means check the Key, a 404 means check the Base URL includes /v1, and a 429 means you are rate-limited.
💡 If you use multiple relays, pair with CC Switch to one-click switch instead of editing env vars each time.
// Decision Checklist
5. One-Line Decision Checklist
- Trying it out / budget-sensitive: pick a relay with free credit and 0.8–1.0x multiplier, get it working first
- Daily main development: stability first — pick a top relay with published 99.9% availability and a status page
- Enterprise / team: must issue invoices, have a company entity, and support team management
- Always: test Codex end-to-end on free credit, confirm no downgrade or rate limit, then top up
Choosing a relay is a balance of stability × price × compliance. Do not be lured by the lowest price — the relay that runs your tasks reliably long-term is the real bargain.
Already picked a relay?
Jump straight to the detailed Codex CLI install and setup steps
View Codex Setup Guide