Skip to main content
Watch: I Built an AI App Without Leaving Databricks

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 gpt-6.1-sol for complex coding and gpt-6-luna for focused, repeatable tasks.

Last verified 7 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.

    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 ChatGPT sign-in on October 14, 2026; it remains available through the OpenAI API and in Codex sessions authenticated with an API key.
  • With ChatGPT sign-in, GPT-6.1 Sol rollout covers Plus, Pro, Business, Enterprise and Edu; Free and Go are not included at launch, and Enterprise/Edu admins must enable it.
  • With API-key authentication, model availability follows your API organization and project and is billed at standard API rates; some ChatGPT workspace and cloud features are limited or unavailable.
  • gpt-6-astra is listed on the OpenAI API model catalog; the Codex models page names Astra in its guidance but its explicit config examples use gpt-6.1-sol and gpt-6-luna.
  • Current Codex releases do not support wire_api = "chat" or a Chat Completions-only endpoint for custom providers.
  • Codex docs at developers.openai.com/codex now serve from 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 gpt-6.1-sol for complex coding and gpt-6-luna for focused, repeatable tasks.

Which OpenAI model ids work in Codex CLI?

The official docs read for this guide list gpt-6.1-sol, gpt-6-luna, gpt-6-sol, gpt-6-astra 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 October 17, 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.