Skip to content

Codex CLI

Codex CLI is OpenAI's official AI coding command-line tool. It's positioned similarly to Claude Code, but runs on OpenAI's own GPT-5 series models.

Key difference: The protocol uses OpenAI's Responses API (not the more common ChatCompletions), so when configuring you must specify wire_api = "responses" and the base_url must not include /v1. For models, choose coding-focused versions such as gpt-5.5-codex / gpt-5.3-codex — these are OpenAI's optimized builds for long-chain engineering tasks.

Who it's for: Developers comfortable in the OpenAI ecosystem, who prefer the stability of the GPT-5 model chain and don't mind configuring a toml file.

This tutorial: Point Codex CLI at claude-api.org to run the GPT-5 series without a ChatGPT Plus subscription.

OpenAI's official Codex command-line tool. Use it with the OpenAI Channel, running the Responses API protocol.

OpenAI — a single Channel that supports both the Responses API (used by Codex CLI) and ChatCompletions (used by other OpenAI-compatible tools) at the same time.

Installation

Requires Node.js 18+.

bash
npm install -g @openai/codex

Or download the binary from the GitHub release.

Configuration

Codex CLI configures the provider via ~/.codex/config.toml:

toml
model_provider = "OpenAI"
model = "gpt-5.4"

[model_providers.OpenAI]
name = "OpenAI"
base_url = "https://claude-api.org"
wire_api = "responses"
requires_openai_auth = true
bash
export OPENAI_API_KEY="sk-你的key"

Base URL must not include /v1

Codex uses OpenAI's Responses API (not ChatCompletions), where the path is /v1/responses, so the base_url should simply be https://claude-api.orgdo not add /v1.

Verification

bash
codex

Once you're in interactive mode, type Write a Python function to reverse a string. If it returns code, the setup succeeded.

Or use curl:

bash
curl -sS https://claude-api.org/v1/responses \
  -H "Authorization: Bearer sk-你的key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4",
    "input": "ping",
    "max_output_tokens": 32
  }'

Model Selection

ModelBest for
gpt-5.4Workhorse, balances capability and price (recommended starting point)
gpt-5.5Latest version
gpt-5.5-codexLatest coding-focused version
gpt-5.3-codexCoding-focused, strong at writing code
gpt-5.3-codex-sparkAccelerated Codex build, faster but slightly weaker
gpt-5.2 / gpt-5.2-proPrevious generation / long-chain reasoning

At startup:

bash
codex --model gpt-5.5-codex

Or change model = in config.toml.

Don't let Codex CLI use the default model

When model = is not explicitly set, Codex CLI defaults to sending gpt-5 (with no version number). We don't provide a short-name fallback on our side, so you'll get 503 No available accounts directly. Be sure to specify one of the exact names from the table above in config.toml.

FAQ

401 Invalid API key

  • The key is wrong / not bound to the OpenAI Channel. When creating a Key in the dashboard, select the OpenAI Channel.
  • Note that Codex CLI uses the Authorization: Bearer ... header, not x-api-key.

404 Not Found

  • wire_api was set to chat (the default) → Codex CLI defaults to ChatCompletions, but our Codex Channel uses the Responses API, so it must be changed to responses.
  • Or base_url has an extra /v1 → remove it.

tool calls failing / tool loops

The Responses API protocol has limitations on certain tool-call formats. If your Codex keeps getting stuck in a tool loop, consider switching to the ChatCompletions protocol (the same OpenAI Channel also supports it — change wire_api to chat and add /v1 to base_url), or switch to a Claude Channel (tool calls are more reliable there).

See the FAQ for more.

This site is an API reverse-proxy service, not affiliated with Anthropic / OpenAI / Google.