Codex CLI Quickstart

5-minute setup: route OpenAI Codex CLI (gpt-5.3-codex) through CodeGateway — install, configure base_url, verify, start coding.

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 $2 of free credit) and generate an API key in the Dashboard. Codex CLI needs Node.js 18+.

2. Install Codex CLI

bash
npm install -g @openai/codex

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:

bash
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):

bash
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 tiered markup (see Tier pricing).

bash
codex "Add a TypeScript function that returns Hello World under src/"

Note: regional restriction on GPT-series models

GPT-series models such as GPT-5.3 Codex can be affected by upstream regional policy: when the upstream judges our egress region, it answers 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.

Turn this doc into a real API call

Create an sk-cg- key after signing up, point your base URL at CodeGateway, and keep your existing SDK or CLI unchanged. Pay per token; binding a card adds $2 of credit.

Sign up free
Author:CodeGateway TeamReviewed on:2026-09-05