Codex CLI

Codex CLI
OpenAI's Terminal Coding Agent

Codex CLI is OpenAI's open-source terminal coding agent, written in Rust: as of 2026-10-20 the official docs give macOS/Linux install scripts, a Windows install.ps1, npm and Homebrew; the recommended model is gpt-6.1-sol, while current models like gpt-5.6-sol are still supported (verified 2026-10-20 in the model docs), running locally with MCP integration.

Point this tool at the QCode endpoint — one key for Claude, GPT and Chinese models.

Updated 2026-10-30

#CodexCLI #OpenAI #AICoding #2026

What Is Codex CLI

Codex CLI is OpenAI's open-source terminal coding agent. It runs on your own machine, reads your code, edits files and executes commands. Written in Rust, installed with the official standalone scripts, npm or Homebrew, and it works inside your project directory once you sign in (official repository checked 2026-10-20).

You steer a session with slash commands: /model sets the model and reasoning effort, /permissions decides what it may do, /init writes an AGENTS.md for the repo, /review checks your changes (command names taken from the official CLI docs snapshot archived 2026-10-20).

By 2026 it is no longer terminal-only: the official repository also links the IDE extension, the desktop app and the cloud-based Codex, and the whole repo is open under the Apache-2.0 license (checked 2026-10-20).

Check the dates first

Model names, install steps and the feature list here were checked on 2026-10-20 against the official repository and an archived CLI docs snapshot. The official repository and docs change fast, so re-read the official page before you rely on it.

Written in Rust
Apache-2.0 licensed
Runs locally
MCP server support

Installation Guide

1

Step 1: Install

Install methods from the official docs: a standalone script for macOS and Linux, a standalone script for Windows in a fresh PowerShell window, or npm and Homebrew; the @openai/codex package on npm is currently 0.163.0 (released 2026-10-15).

npm install -g @openai/codex
2

Step 2: Authenticate

Sign-in options: run codex login in the terminal and complete the browser flow with your ChatGPT account, or sign in with an API key; codex login status shows the active method.

export OPENAI_API_KEY=sk-...
3

Step 3: Launch

Run codex in your project directory and describe the task in one sentence; use codex exec for non-interactive runs in scripts and pipelines.

codex "explain this project"
4

Step 4: Select Model

Use /model in a session to pick the model and reasoning effort, or pass --model (or -m) at launch (for example gpt-6.1-sol or gpt-6-sol); the official docs' default model example is gpt-6.1-sol, written as the model entry in ~/.codex/config.toml.

Key Features

Sessions and images

Reopen a recent chat from this repository, dig through older local sessions, or paste a screenshot into the prompt.

MCP tool access

Add local or remote MCP servers, check which tools the session can reach, then let Codex use them.

Live web search

Switch to live web search when a task depends on fresh releases, docs or external behavior; the search stays in the transcript.

Project instructions

Run /init to generate an AGENTS.md, then keep build commands and code conventions there for later sessions.

Sandbox and approvals

Decide when it may edit files or run commands without asking, and inspect the active sandbox and writable roots first.

Non-interactive mode

Non-interactive commands fit repeatable workflows, so you can wire them into scripts and pipelines.

Codex CLI vs Claude Code

How the two terminal coding agents differ, row by row (checked 2026-10-20).

Dimension Codex CLI Claude Code
Architecture Rust, runs locally Terminal, IDE, desktop, web
Model Model set via /model Alias or full model name
Context Follows model and effort Extended context, auto-compact
Pricing Part of ChatGPT plans Subscription or token billing
Execution Local terminal plus sandbox Reads, edits, runs commands
Agent features Delegates to sub-agents Sub-agents and agent teams
Voice mode Not verified Built-in /voice dictation
Open source Open source, Apache-2.0 Under Anthropic terms of service

Codex CLI leans on open source and local runs, Claude Code on more clients and parallel agents; the real gap is collaboration.

Use AI Coding Tools via QCode.cc

On-sale ids like gpt-5.6-sol and claude-opus-5 share one API key.

Both ids come from the models page we checked on 2026-10-20.

Released models share one key

On-sale (released) models share one key, switching means editing a name; announced or rumored ids may not answer yet.

Switching is a config edit, not a code change

Switch between gpt-5.6-sol and claude-opus-5 on one account; the models page sets the parameters.

Billed per token, rates on the pricing page

Use the pricing page for the billing model and rates.

One model catalog

On-sale ids sit on one models page, gpt-5.6-sol and claude-opus-5 included; confirm it is still listed before you buy.

Practical tips

Start read-only, run one pass, then allow edits. Keep build commands and conventions in AGENTS.md, and run /review before you commit.

Where it fits

Reworking existing repos

For renames at scale, dependency bumps and test backfill: let it read the layout, propose a plan, then approve each step.

Repeatable pipeline steps

Non-interactive runs fit scripts and pipelines: produce change summaries, run routine checks, replay the same steps.

Checking external behavior

When the answer depends on current version numbers or third-party APIs, live search beats an answer from stale memory.

Codex Ecosystem Expansion

From the CLI to a desktop app and then into the ChatGPT desktop app, Codex kept expanding in 2026.

Launched 2026-02-02

Codex Desktop App

The Codex desktop app launched for macOS on 2026-02-02 and for Windows on 2026-03-04, running agent threads in parallel across projects and reviewing results in one interface.

  • macOS + Windows dual platform
  • Parallel management of multiple Agent instances
  • Visual task queue and execution status
Since 2026-07-09

Part of the ChatGPT desktop app

Since July 9, 2026, Codex has been part of the ChatGPT desktop app on macOS and Windows; existing Codex app users keep their projects, settings and workflows after updating.

  • Chat, Work and Codex in one app
  • Codex can be the default view
  • Keep the Codex app icon on macOS

Latest Model Lineup

GPT-6.1 Sol

OpenAI recommends it for complex coding and agentic workflows and says it offers near-Astra performance at a lower cost; GPT-5.3-Codex-Spark retired on 2026-09-14 (as of 2026-10-20).

GPT-6 Sol

OpenAI names gpt-6-sol as the replacement for gpt-5.4, which retired from Codex with ChatGPT sign-in on 2026-08-31 (as of 2026-10-20).

GPT-5.5

OpenAI gives 2026-10-14 as the date GPT-5.5 retires from ChatGPT, ChatGPT Work and Codex on all plans; as of 2026-10-20 that has taken effect, while the OpenAI API and Codex sessions authenticated with an API key aren't affected.

Codex CLI in practice: install, sign-in, QCode setup and troubleshooting

Four ways to install (official docs as of 2026-10-20)

As of 2026-10-20, OpenAI's official Codex CLI docs list four install methods: the standalone installer on macOS and Linux, the standalone installer on Windows run from a new PowerShell window, and npm or Homebrew. To update, run the same install command again; with Homebrew, use brew upgrade --cask codex.

After installing, open a project directory and run codex. On first launch, choose Sign in with ChatGPT or another available sign-in method, then describe the task in a sentence. OpenAI recommends creating Git checkpoints before and after a task so you can revert changes.

  • macOS / Linux: curl -fsSL https://chatgpt.com/codex/install.sh | sh
  • Windows (PowerShell): powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
  • npm: npm install -g @openai/codex
  • Homebrew: brew install --cask codex
  • WSL: the official docs say WSL1 was supported through Codex 0.114; starting in 0.115 the Linux sandbox moved to bubblewrap, so use WSL2.

Two sign-in methods and the official usage limits

OpenAI's authentication docs describe two ways to sign in to Codex CLI: Sign in with ChatGPT for subscription access, or an API key for usage-based access. You can pipe a key to codex login --with-api-key, and codex login status shows the active method. Login details are cached in ~/.codex/auth.json or your OS credential store, and the CLI and IDE extension share the same cached login.

With ChatGPT sign-in, your plan's limits apply: OpenAI's pricing page (as of 2026-10-20) estimates local messages per five-hour period for Plus and Standard Business, says Pro plans currently have no five-hour limit, and notes that weekly limits may also apply; type /status in a session to see your remaining limits. With an OpenAI API key, Codex uses OpenAI's official price (standard API pricing) instead of included ChatGPT plan credits.

Connecting Codex CLI with a QCode API key

The QCode Codex guide uses the OpenAI Responses protocol: in your user-level ~/.codex/config.toml, add a custom model provider (any name you like), point model_provider at it, and fill in the fields below. After signing up for QCode, create an API key starting with cr_ in the dashboard and you are ready.

This setup serves GPT models only: the overview in the QCode docs states that the Responses endpoint Codex uses does not serve Claude or Chinese models. For Claude models such as claude-sonnet-5-5 or claude-opus-5-5, set up Claude Code with the same key. Billed per token; per-model rates are listed on /models.

  • base_url: https://api.qcode.cc/openai (the QCode docs say it must be exactly this); the Asian backup address is https://asia.qcode.cc/openai.
  • wire_api: responses, with requires_openai_auth set to true. OpenAI's docs state that current Codex releases support neither wire_api = chat nor a Chat Completions-only endpoint.
  • Pick one: for an environment variable, drop requires_openai_auth and set env_key = "QCODE_API_KEY" (the name is up to you), then export that variable; for a file, keep requires_openai_auth = true and put the key in ~/.codex/auth.json (permission 600). The docs state that Codex ignores env_key when requires_openai_auth = true.
  • model: a GPT model listed in the QCode docs, such as gpt-6-sol, gpt-6.1-sol, gpt-6-astra, gpt-5.6-terra or gpt-5.6-sol; model_reasoning_effort can be low, medium or high.
  • Prefer not to edit files by hand? The QCode docs offer a one-line setup script: curl -fsSL https://qcode.cc/install/codex.sh | bash (on Windows, irm https://qcode.cc/install/codex.ps1 | iex). It installs the CLI, writes the ~/.codex config and checks connectivity.

Common errors and fixes

Start with codex doctor: the official docs say it generates a local diagnostic report covering installation, configuration, authentication, runtime, Git and terminal health. Inside a session, /status confirms the active model, approval policy and remaining context, and /debug-config prints how each config layer applies.

  • 401 or an invalid API key: make sure the key starts with cr_ and has no stray spaces or line breaks; if you use an environment variable, its name must match env_key in config.toml exactly; then check the key's status in the QCode dashboard.
  • Connection timeouts or network errors: confirm base_url is https://api.qcode.cc/openai, test with curl -I https://api.qcode.cc, and try https://asia.qcode.cc/openai if the main address does not respond.
  • Config changes have no effect: OpenAI's docs state that project-level .codex/config.toml files ignore keys such as model_provider and model_providers, so the provider must live in your user-level ~/.codex/config.toml.
  • Profile errors: since Codex 0.134.0, --profile no longer reads [profiles.name] tables from config.toml and the top-level profile selector is no longer supported; move those settings into a separate ~/.codex/name.config.toml file.
  • Model not available: OpenAI's docs state that GPT-5.3-Codex-Spark retired on 2026-09-14, and that gpt-5.4 retired from Codex with ChatGPT sign-in on 2026-08-31 (the GPT-5.5 retirement is covered in the model cards above), so replace old model names in scripts and config.
  • EACCES during a global npm install: the QCode docs suggest moving npm's global directory to your user directory; the official standalone installer above is another option.

More Codex CLI questions

How do I install Codex CLI?

As of 2026-10-20, the official docs give four options: on macOS or Linux run curl -fsSL https://chatgpt.com/codex/install.sh | sh; on Windows run the official install.ps1 script from PowerShell; or use npm install -g @openai/codex or brew install --cask codex. Then run codex in your project directory and sign in.

Can Codex CLI run several agents together?

Yes. The official CLI docs describe subagents delegating focused work to specialized agents and bringing their findings back into the main terminal session; the [features] table in the official config.toml has a multi_agent flag, true by default and marked Stable, which enables the subagent collaboration tools. For Windows users: the official docs provide a standalone installer to run in a new PowerShell window, and you can also use Codex in WSL2. The official docs say that since Codex 0.115 the Linux sandbox switched to bubblewrap and WSL1 is no longer supported.

Can Codex CLI use Claude models?

Not through QCode. Codex speaks the OpenAI Responses protocol, and the QCode docs state that this endpoint serves GPT models only. For Claude models, use Claude Code with the same QCode API key.

What is the Codex five-hour limit?

It is the plan limit that applies when you sign in with ChatGPT. OpenAI's pricing page (as of 2026-10-20) estimates local messages per five-hour period for Plus and Standard Business, says Pro plans currently have no five-hour limit, and notes that weekly limits may also apply; use /status to see what is left. With an API key, OpenAI's official price (standard API pricing) applies instead of plan credits; with a QCode key, usage is billed per token and per-model rates are listed on /models.

How do I switch Codex CLI to gpt-6.1-sol?

Three ways: type /model in a session to pick a model and reasoning effort; pass it at launch, for example codex -m gpt-6.1-sol; or set model = "gpt-6.1-sol" in ~/.codex/config.toml as the default. When you connect through QCode, the GPT models you can use are those in the QCode docs and on /models.

How do I use different models or reasoning effort per project?

Use profiles. OpenAI's docs say codex --profile name layers ~/.codex/name.config.toml on top of ~/.codex/config.toml. The example in the QCode docs keeps the provider in the main config and adds work.config.toml and personal.config.toml with different model and model_reasoning_effort values, selected with codex --profile work.

How do I pay for QCode and get started?

Sign up, top up your balance, pick a plan, then create an API key in the dashboard. In CNY you can pay with Alipay or WeChat Pay; in USD with Visa / Mastercard credit cards, Apple Pay or Google Pay; crypto is accepted across many coins and networks, and everything is self-service. Billed per token; per-model rates are listed on /models.

Start Using AI Coding Tools

Once connected, run the same task on two models and see which one you keep. To run Codex in the background for hours, open a QCode cloud server (qcode.cc/en/cloud): usually online within minutes, full root access, then install Codex CLI and call models with your QCode key; one balance is shared by AI services and cloud servers.

UPDATE · 2026-05

2026 Q1-Q2 Major Updates

OpenAI's official Codex changelog records that GPT-5.3-Codex was released on 2026-02-05. OpenAI called it the most capable agentic coding model to date for complex, real-world software engineering, said it runs 25% faster for Codex users and responds to steering in real time while it works. A research preview, GPT-5.3-Codex-Spark, followed on 2026-02-12. Since 2026-05-26, GPT-5.3-Codex is no longer user-selectable in Codex for users signed in with ChatGPT (API-key workflows are not affected), and GPT-5.3-Codex-Spark was deprecated on 2026-09-14. China users reach Codex and GPT models such as gpt-6.1-sol through one QCode API key, billed per token with per-model rates listed on /models (as of 2026-10-13; the official OpenAI documentation gives 2026-10-14 as the date GPT-5.5 retires from ChatGPT, ChatGPT Work and Codex and states that the OpenAI API is not affected).

Read the GPT-5.3-Codex complete guide

Create a QCode account

One key across Claude, GPT and Chinese models, billed per token — live rates on /models.

Not sure where to start?

Try it for a week

Small Pack: $4 for $30 of quota, valid 7 days

Use it every day

Starter: $9.00/month with $5 of quota every day — just $0.060 per $1 of quota, vs about $0.113 for the Medium Pack