TL;DR: 5 minutes to point Codex CLI at CodeGateway, call GPT-5.3 Codex through the OpenAI Responses API, pay as you go without an overseas credit card.
We tested this flow on our own machines and recommend running through all 5 steps before customizing — every step ships with a copy-paste command.
This tutorial walks through using Codex CLI with CodeGateway as the access layer for the GPT-5.3 Codex model. Codex CLI is OpenAI's command-line coding assistant; it speaks the OpenAI Responses API protocol. CodeGateway exposes a /v1/responses endpoint that implements the same protocol contract, so Codex CLI works with CodeGateway by setting the base URL accordingly.
Reference: OpenAI Codex CLI repo | Responses API docs for protocol parameters and endpoint definitions.
1. Prerequisites
Sign up for CodeGateway (bind a card and get free credit) and generate an API key in the Dashboard. Codex CLI needs Node.js 18+.
2. Install Codex CLI
npm install -g @openai/codexRequires Node.js 18+. winget install openai.codex and Homebrew work too. If codex is not recognized afterwards, the npm global bin directory is missing from PATH — the full Codex CLI guide's install section covers PATH fixes and the ~/.codex/config.toml basics.
3. Configure environment
Codex CLI locates its upstream via the OPENAI_BASE_URL and OPENAI_API_KEY environment variables. Point the base URL at CodeGateway:
export OPENAI_BASE_URL="https://api.codegateway.dev/v1"
export OPENAI_API_KEY="<your CodeGateway API Key>"4. Verify the connection
The following command should return the model list (including gpt-5.3-codex):
curl https://api.codegateway.dev/v1/models \
-H "Authorization: Bearer $OPENAI_API_KEY"5. Start coding
Run codex in any project directory and let GPT-5.3 Codex write code. All requests are routed through CodeGateway edge nodes and billed per token with flat 1.07x markup (see Flat markup pricing).
codex "Add a TypeScript function that returns Hello World under src/"FAQ
Q: How do I install Codex CLI? A: Run npm install -g @openai/codex on Node 18+ (macOS / Linux / Windows); winget install openai.codex and Homebrew also work. Then run codex login, or set OPENAI_API_KEY directly on headless / CI machines.
Q: Where is the Codex CLI config file? A: ~/.codex/config.toml — model, provider base URL, approval policy and MCP servers all live there. Credentials are stored separately at ~/.codex/auth.json, so config.toml never holds your API key.
Q: Can I point Codex CLI at a custom API base URL? A: Yes. Set OPENAI_BASE_URL (step 3) or the provider base URL in ~/.codex/config.toml — e.g. https://api.codegateway.dev/v1 — and put your gateway key in OPENAI_API_KEY.
Q: Codex CLI installed without errors but `codex` is not recognized as a command? A: The npm global bin directory is missing from PATH. Run npm config get prefix, add the returned directory to PATH, reopen the terminal, and verify with codex --version.
Note: regional restriction on GPT-series models
GPT-series models such as GPT-5.3 Codex can be affected by upstream regional policy: affected requests are rejected with unsupported country/region/territory. This is usually transient — retrying recovers it (the one controlled retry we ran succeeded after 94 s; across 10 such rejections in 48 h the median recovery was ~3 min, an upper bound). The gateway therefore returns 503 (retryable) with Retry-After, and the SDK / Codex retries automatically.
First: retry after a few seconds (one retry is usually enough).
If it keeps failing: use a model without that limit (DeepSeek / Kimi / GLM / Qwen series, e.g. deepseek-v4-pro, kimi-k2.7-code), or route traffic from a supported region (e.g. run Codex CLI on a machine in a supported region).
See the Agent CLI overview for the full model routing rules.