How to install and use OpenAI Codex CLI: auth and first repo task

Install Codex CLI, sign in with ChatGPT or an API key, then run one first task in a real repository.

You want a coding agent that can read the repo on your machine, edit files, and run local tools — without leaving the terminal.

This walkthrough covers how to install and use OpenAI Codex CLI: the official installer, ChatGPT or API-key sign-in, and a first task in a real repository. Steps follow developers.openai.com/codex/cli and developers.openai.com/codex/auth.

Install Sign in First repo task

Who it is for

Codex CLI works against a local repository: inspect files, make edits, and run tools you already installed. Use codex interactively; use codex exec for repeatable pipelines. It is not the ChatGPT web tab, and you do not have to install an IDE extension first.

01

Start in a real repo

cd into the project before you launch. Official onboarding is to ask “Tell me about this project”, then request one focused, reviewable change.

02

Two logins, two bills

ChatGPT sign-in uses Plus / Pro / Business / Edu / Enterprise plan credits. An API key bills OpenAI Platform rates — better for private CI, with some workspace cloud features limited.

03

Set permissions first

Use /permissions to see the sandbox and writable roots. Official guidance also says to create git checkpoints before and after a task so you can revert.

Install, sign in, first task

  1. 1

    Install the CLI

    macOS / Linux: curl -fsSL https://chatgpt.com/codex/install.sh | sh. Windows: the official PowerShell installer. You can also run npm install -g @openai/codex or brew install --cask codex. The same install command updates an existing copy.

  2. 2

    Sign in

    From a project directory run codex or codex login, choose Sign in with ChatGPT, and finish the browser flow. If you are headless or the localhost callback is blocked, use codex login --device-auth (enable device codes in ChatGPT security settings). For automation: printenv OPENAI_API_KEY | codex login --with-api-key. Check with codex login status; sign out with codex logout.

  3. 3

    Run a first repo task

    Enter the repository and run codex. Ask it to explain the layout, then request one focused change — a test, a typed fix, or a clear error. Use /review before you commit. /init can write an AGENTS.md if the team needs standing instructions.

0
Extra IDE required
2
Sign-in methods
1
First prompt
curl -fsSL https://chatgpt.com/codex/install.sh | sh
# Windows: irm https://chatgpt.com/codex/install.ps1 | iex
# npm install -g @openai/codex
# brew install --cask codex

codex login
# printenv OPENAI_API_KEY | codex login --with-api-key
# codex login --device-auth

cd ~/code/your-repo
codex
# Tell me about this project

What usually blocks a first run

Method Billing Best for
ChatGPT sign-in Plan credits Daily local work
API key Platform rates Private CI / scripts
Device code Same as ChatGPT Headless or SSH hosts
Treat auth.json as a password
Login is cached in ~/.codex/auth.json or the OS keyring. Do not commit it or paste it into tickets. The CLI and IDE extension share that cache; logging out of one signs you out of the other.
Headless login is a different path
If a remote host blocks the localhost callback, prefer device-code auth. Fallbacks are copying the cache from a machine with a browser, or forwarding localhost:1455 over SSH.
Corporate proxies need a CA
On a TLS proxy or private root, set CODEX_CA_CERTIFICATE before codex login. If unset, Codex falls back to SSL_CERT_FILE.

Official warning for API and CI use: do not expose Codex execution in untrusted or public environments.

When the diff needs a conversation

After the agent edits, teams often want one picture of what changed and why it can merge. No extra meeting suite. Open a short space on tidemeet or see how to create a space. Canvas basics: shared whiteboard. For an OpenAI eval-incident note on this site, see the METR report.

Questions

Do I have to install the IDE extension?

No. The CLI works on its own. The extension shares the login cache, but a first repo task only needs the terminal.

Can I mix ChatGPT login and an API key?

One active method per session. ChatGPT uses workspace permissions and plan credits; an API key uses Platform org settings and usage rates. Codex cloud requires ChatGPT sign-in.

Should the first task be a large refactor?

No. Official onboarding is understand the repo, then one focused change. Check /permissions and keep a git checkpoint so you can revert.

What does this have to do with a temporary meeting tool?

No product tie. If you only need to talk through a diff, temporary meeting tools says when a short browser space is enough.

Create a free space