Skip to main content
Watch: Anthropic Just Hit the Brakes on Its Next AI Model

Setup guide - From OpenAI and Codex CLI docs

Use OpenAI in Codex CLI

Codex CLI is OpenAI's own coding agent and uses OpenAI models natively. You sign in with ChatGPT (subscription) or an OpenAI API key (usage-based), then pick a model with --model or in config.toml. OpenAI's Codex docs recommend Astra for the most demanding workflows, GPT-6.1 Sol for near-Astra performance at a lower cost, GPT-6.1 Terra as a fast, efficient choice for writing, visual understanding and computer use, and Luna for focused, repeatable tasks.

Last verified 8 steps4 official sources

Steps

  1. Step 1.

    Install Codex CLI (Mac or Linux installer, or npm / Homebrew).

    Terminal
    curl -fsSL https://chatgpt.com/codex/install.sh | sh
    
    # or
    npm install -g @openai/codex
    
    # or
    brew install --cask codex
  2. Step 2.

    Option A, subscription access: run codex login and complete the browser flow (Sign in with ChatGPT).

    Terminal
    codex login
  3. Step 3.

    Option B, usage-based access: pipe an OpenAI API key (from https://platform.openai.com/api-keys) to codex login through stdin.

    Snippet
    printenv OPENAI_API_KEY | codex login --with-api-key
  4. Step 4.

    Check which authentication method is active.

    Terminal
    codex login status
  5. Step 5.

    Choose a model at launch with --model (or -m), or with /model inside an interactive session.

    Terminal
    codex --model gpt-6.1-sol
  6. Step 6.

    Non-interactive runs take the same option.

    Terminal
    codex exec -m gpt-6.1-sol "Review the current changes"
  7. Step 7.

    GPT-6.1 Terra requires Codex CLI 0.159.0 or later.

    Terminal
    codex -m gpt-6.1-terra
  8. Step 8.

    Set a default model in config.toml (shared by the ChatGPT desktop app, Codex CLI and IDE extension).

    TOML
    model = "gpt-6.1-sol"

Caveats

  • GPT-5.5 retired from Codex for users signed in with ChatGPT on October 14, 2026; the OpenAI API and Codex sessions authenticated with an API key are not affected.
  • For Codex with ChatGPT sign-in, the replacement is GPT-6.1 Sol (gpt-6.1-sol) on Plus, Pro, Business, Enterprise and Edu plans when available, and GPT-6 Luna (gpt-6-luna) in the desktop app on Free and Go plans when available. In Enterprise and Edu, an administrator must enable Luna first.
  • gpt-6-sol is named on the Codex models page as the replacement for the retired gpt-5.4 when available to your plan and client.
  • With API-key authentication, model availability follows your API organization and project, usage is billed at standard API rates, and some features that rely on ChatGPT workspace access or cloud services are limited or unavailable.
  • GPT-6.1 Sol uses a default context window of 500,000 tokens in Codex and ChatGPT Work.
  • Current Codex releases do not support wire_api = "chat" or a Chat Completions-only endpoint for custom providers; use a compatible Responses API endpoint.
  • Codex docs at developers.openai.com/codex now redirect to learn.chatgpt.com/docs.

FAQ

How do I use OpenAI in Codex CLI?

Codex CLI is OpenAI's own coding agent and uses OpenAI models natively. You sign in with ChatGPT (subscription) or an OpenAI API key (usage-based), then pick a model with --model or in config.toml. OpenAI's Codex docs recommend Astra for the most demanding workflows, GPT-6.1 Sol for near-Astra performance at a lower cost, GPT-6.1 Terra as a fast, efficient choice for writing, visual understanding and computer use, and Luna for focused, repeatable tasks.

Which OpenAI model ids work in Codex CLI?

The official docs read for this guide list gpt-6-astra, gpt-6.1-sol, gpt-6.1-terra, gpt-6-luna, gpt-6-sol and gpt-5.5.

Is this an official OpenAI and Codex CLI setup?

The steps draw on both OpenAI's and Codex CLI's docs. It was last checked against 4 official pages on November 8, 2026.

Sources

Last verified against 4 official pages.

Newsletter

New models, set up the day they ship

One email per week. New model releases, the coding tools that support them and how to wire them up.