Skip to content
Ingrid Kovarová

Dec 5, 202615 min read

Install Codex CLI with npm i -g @openai/codex or Homebrew, confirm it with codex --version, then run codex in a project folder.

Codex CLI install on macOS, Linux and Windows

It takes about five minutes, much like wiring up a trigger in Activepieces, and the sign-in choice you make next decides how it bills.

What Codex CLI is and what it does

Codex CLI is OpenAI's open-source coding agent for the terminal. It reads your repository, proposes edits and runs commands from inside the folder where you start it.

According to OpenSourceStats, OpenCode leads with 231,072 stars. Claude Code has 158,138. Codex CLI sits third at 137,345, so you're adopting a tool with a large user base, not a niche one.

Codex CLI's GitHub following against rival terminal agents

Gemini CLI has 109,603, and Aider trails at 50,367, which still means a sizable community.

Install with npm or Homebrew

The steps are short. OpenAI's Codex docs list these commands as of 5 December 2026:

  1. Confirm Node.js with npm is present (node --version), or that Homebrew is (brew --version).
  2. Run the install command: npm i -g @openai/codex, or on macOS brew install --cask codex.
  3. Check the version with codex --version.
  4. Run codex inside a project folder.

If the first launch asks you to sign in, stop and read the next section before choosing. That prompt is where billing and rate limits get decided.

On Windows, OpenAI's docs treat native support as experimental and point to Windows Subsystem for Linux (WSL) as the steadier route. Install a Linux distribution under WSL, then run the same npm command inside it.

Windows laptop with a Linux terminal window inside it

Run codex --version and note the number it prints. Record it in your team's setup notes, because two people on different versions will report different behavior for the same prompt.

If the command isn't found, your npm global bin directory is probably missing from your PATH. Fix that before launching codex.

Everything below works on Activepieces' free plan. Start without code or a credit card.

Sign-in options, API key access and plan coverage

Choose the sign-in method before anything else: ChatGPT login suits one person working interactively, and an API key suits shared, scheduled or unattended runs.

The table shows who each method is for and what happens at the limit, which is what decides who gets paged when a job stalls at 2am.

ChatGPT plan sign-in OpenAI API key
Who can use it A person with a paid ChatGPT plan that includes Codex Anyone with an OpenAI platform account and a key
How it is billed Inside the plan's subscription Per use, to the platform account
Models available Those OpenAI offers to the plan Those enabled for the key's project
At the limit Usage pauses until the allowance resets or you upgrade Spend is capped by your budget settings, or requests fail on a quota error

Comparison of a plan login card and an API key

When the person whose ChatGPT login it is leaves, the access leaves with them. Use it for your own laptop, where the plan allowance is a budget you already own. Don't wire it into a shared job: nobody on the team owns that seat.

For anything automated, use an API key, because a key belongs to a project and a project is the right owner. To supply one:

  1. Sign in to the OpenAI platform and open its API keys page.
  2. Create a new secret key, preferably in a project dedicated to this use.
  3. Copy it once and store it in your secret manager, not in the repository.
  4. Export it as OPENAI_API_KEY in the shell or job environment.
  5. Launch codex.

API key placed in a vault, not in the repository folder

Anyone holding the key spends your money, so record who rotates it.

Pick ChatGPT sign-in when one developer is working interactively and a paused session is only an annoyance. Pick an API key when a pipeline, a scheduled job or several people share the access, because a failure there has an owner and a billing trail.

Per OpenAI's pages, Codex is included with the paid ChatGPT plans: Plus, Pro, Business, Edu and Enterprise (checked 2026-12-05). This article makes no claim about a free tier, so confirm it on OpenAI's pricing page before you rely on one.

Codex CLI commands and flags with examples

Before anyone else runs these, decide who owns the account codex login holds: ten commands and flags cover most daily use, and each runs under that account.

The list below shows each one with an example you can paste; take from it that most of the safety lives in three flags and two files.

  • codex: start an interactive session, as in codex "explain how this repo is laid out".
  • codex exec: run one prompt and exit, as in codex exec "list failing tests and likely causes".
  • --model: pick the model, as in codex --model "$CODEX_MODEL".
  • --ask-for-approval: set when it must ask you, as in codex --ask-for-approval on-request.
  • --sandbox: limit what it can touch, as in codex --sandbox workspace-write.
  • resume: reopen a prior session, as in codex resume --last.
  • login: choose the account, as in codex login.
  • Slash commands: type /status or /model inside a session.
  • config.toml: store defaults in ~/.codex/config.toml, such as sandbox_mode = "workspace-write".
  • AGENTS.md: put standing instructions in the repo root, such as "Run the tests before proposing a change."

Run codex from inside the repository, not your home directory, because the working directory is what it can read. Give it a small, checkable task first, such as finding why one test fails.

Nobody is watching a codex exec run, so the approval and sandbox settings below matter more here than in a terminal session.

It is the form a script or scheduled job calls, because it takes one prompt and returns. Decide who gets the failure notice before the job exists.

To choose a model, use --model; available choices depend on your plan or key. --ask-for-approval controls how often you are interrupted. --sandbox controls what a command can write. Start with workspace-write and approvals on request, and loosen them only where a person has signed off.

Put repeated flags in config.toml so every run starts the same way. Put team rules in AGENTS.md so the agent reads them each session, and review the file like any other change.

Try one real task that ties these together: from the repo, run codex --sandbox workspace-write "find why the date parser test fails and propose a fix". Read the diff it proposes, then run the tests yourself before committing.

Codex CLI models, pricing and rate limits

How Codex CLI bills a task

Run a task and Codex CLI bills it by tokens, with the model you pick setting the rate.

Pass a model at launch with codex --model <name>, or change it mid-session with /model. Pin the model in your scripts. Otherwise the default can shift under a scheduled job and change both the cost and the output nobody reviewed.

I could confirm prices for only one Codex model: GPT-5.3 Codex, from Jahanzaib. That older model cost $1.75 per 1M input tokens, $0.175 per 1M cached input tokens and $14 per 1M output tokens, in USD; current models such as GPT-6.2 Astra and GPT-6.2 Sol are priced separately, so check OpenAI's pricing page.

What each kind of token costs on GPT-5.3 Codex

At $1.75 per million, input is cheap, so a large repo pasted into context costs little to send.

Output is $14 per million, eight times that rate, so a verbose proposed diff costs more than the files it read.

Cached input is $0.175 per million, a tenth of the input rate, which means a long session that re-reads the same files costs mostly the cheap rate. Check the source before budgeting, since vendors reprice.

Output is $14 per million, eight times that rate, so a verbose proposed diff costs more than the files it read.

What a ChatGPT plan login changes

On a ChatGPT plan login, none of this pricing applies. It is a flat subscription with its own usage allowance, so there's no per-token invoice, and the person billed is whoever owns the plan. The prices above hold only for API-key sign-in.

Activepieces pricing page with four subscription tiers showing pricing, features, and plan recommendations.

Rate limits on an API key

With an API key, limits attach to the account's usage tier, and the OpenAI dashboard's limits page shows them.

I'm not quoting numbers here because they differ by tier and model and change over time. Look up your own tier before you put Codex in a pipeline.

When a key is shared, one noisy job can throttle everyone else, and the 2am failure is a 429 with no owner.

With a ChatGPT plan login, the cap is a usage window on the plan instead, so the same job stops for a different reason.

Codex already meters tokens inside every run, and the automation around it shouldn't add a second meter per step.

Activepieces exposes your team's apps to Codex CLI as tools through an MCP server (activepieces.com/mcp, cloud or self-hosted), and its meter is the run: 1 credit per flow run, whether the flow has two steps or ten.

A ten-step flow costs what the two-step workaround did, so splitting work into smaller, more reliable steps is never taxed, which is not the case on Zapier's per-task or Make's per-module pricing.

A minimal request, end to end:

  1. Export the key: export OPENAI_API_KEY=...
  2. Run non-interactively: codex exec "explain what this repo's main entry point does"
  3. Read the output, then check the usage in the dashboard against the prices above.

Easier to see it running than to read about it: set it up free, no card.

Common Codex CLI production errors and fixes

At 2am on a Tuesday, the errors that page someone are mostly sign-in errors. Each maps to a cause and a fix you can write down before the schedule runs. The table shows the six you'll meet, so assign an owner to each before launch.

Symptom Cause Fix
401 key error Wrong, expired or revoked key, or a plan login where the job expects a key Reissue the key, confirm which method the job uses
429 limit Plan usage cap or API rate and quota limit Slow the schedule, or move billing to the other method
Sandbox block A command or write outside the permitted sandbox Adjust the sandbox or approval setting deliberately
Headless login No browser on the server for interactive sign-in Use an API key for unattended runs
Unavailable model The account or sign-in method does not offer that model Pick a model the account lists
Full context A long session has filled the context window Start a fresh run with a narrower task

401, 403 and invalid key

When a 401 comes back, the server rejected the credential; a 403 means it accepted the credential but didn't permit the action. Check first that the job uses the method you intended.

A key exported in one shell is invisible to a scheduler running as another user, so the job fails while your terminal works. Whoever owns the key owns this failure, and rotation should be on their calendar.

Codex CLI 429 rate limit and quota errors

Of all these errors, the 429 is the clearest case of the sign-in choice mattering. A plan login draws on plan allowances, while an API key draws on per-token billing and its own limits.

The same retry loop therefore costs you differently depending on the method. Don't retry blindly: back off, and look at whether a schedule is overlapping its own previous run.

A sandbox block is the tool working as designed. Loosening it to make an error disappear moves the risk to whoever reads the diff later.

Widen permissions only for the specific path or command the task needs, and record the reason where the next owner will find it.

Headless login and CI runs

A CI runner has no browser, and interactive sign-in assumes one. For unattended codex exec runs, use an API key held in the runner's secret store, and let the job fail loudly if it's missing.

If you attach MCP servers so the agent can reach your other tools, treat each as another credential that can expire.

Unavailable-model and full-context errors usually surface here too. Choose a model the account actually offers, and keep each scheduled task small enough to finish inside one context.

Monday checklist:

  1. Write down which sign-in method each job uses and who owns its credential.
  2. Run one task by hand and read its cost before scheduling it.
  3. Confirm the scheduler's environment holds the key.
  4. Set the sandbox to the narrowest setting that works.
  5. Name who is paged when the job fails.

What Activepieces does about this

The problem in this article is ownership. A Codex job fails at 2am because nobody decided whose login or key it ran under, and then the tools around it add credentials nobody tracks. Activepieces handles the second half.

Your team's apps, such as Slack, GitHub, Google Sheets and a ticket queue, are connected once in Activepieces and exposed to Codex CLI as tools through its MCP server at activepieces.com/mcp. The agent never holds those app credentials.

Codex has one credential to own, the OPENAI_API_KEY you chose for unattended runs, and each app connection lives in one place with a named owner.

You can inspect that layer before you trust it. Activepieces is open source under the MIT licence for its community edition, and you can self-host it if the connections shouldn't leave your network.

The cloud and self-hosted servers expose the same MCP endpoint, so the choice changes where the credentials sit and not how Codex calls them.

The billing model matches the discipline of picking a sign-in method first. A run costs 1 credit per flow run, however many steps the flow has, so a codex exec job that triggers a ten-step flow is one run on that meter.

Activepieces pricing page with four subscription tiers showing features and costs

Codex's token spend stays on the OpenAI side, where the dashboard checks above already cover it.

A 429 or a failed run then points to one of two places, the OpenAI key's limits or a specific flow's run history, instead of a pile of per-step charges.

To try it, keep the Codex job on an API key and connect a single app in Activepieces.

Attach the MCP server to Codex, run one small codex exec task that calls it, and note in your setup file who owns each credential: the key, the Activepieces connection and the flow.

Modal dialog for enabling OpenAI as an AI provider in Activepieces Platform Admin, showing API key setup instructions and…

Frequently asked questions

Is Codex CLI free to use?

Installing it costs nothing, but running it does: every request is billed either against a ChatGPT plan's usage allowance or against an API key's per-token charges.

Check how you signed in before you hand the tool to a scheduled job, because that decides which billing applies. The person who owns that job's bill is the one who gets the surprise.

Read the current plan page rather than relying on an old answer, since whether a given plan includes Codex access, and how much, is set by OpenAI and can change.

Codex CLI is open source. OpenAI publishes the CLI's source in a public repository, so you can read how it handles sign-in, sandboxing and approvals before you give it access to a machine.

That covers the client only. The models it calls run on OpenAI's side and aren't part of what you can inspect or host.

Can Codex CLI run without a ChatGPT subscription?

Yes. Signing in with an API key is the alternative to a ChatGPT plan login, and it needs no subscription.

You pay per token instead of drawing on a plan allowance, and the limits that apply are those of the API account, not of a ChatGPT plan.

For unattended runs this is often the cleaner choice, because the spend is attached to a key someone owns and can rotate or revoke, rather than to one person's personal login.

Does Codex CLI work with other providers' models?

Partly. The tool is built around OpenAI's models and is easiest to run that way.

Its configuration allows pointing at a different model provider, but support for a given provider's features varies, so test your exact workflow before depending on it.

If you do switch, the plan-versus-key question changes too: billing and limits then come from that provider, not from OpenAI.

How do I update or uninstall Codex CLI?

Use the same package manager you installed it with. Update and remove through that tool, not by deleting files by hand, so nothing is left behind on the path.

After updating, run the version command to confirm which build is active, since a second copy installed another way can shadow the new one.

If the machine is being handed to someone else or retired, clear your configuration and stored sign-in details separately, since uninstalling the binary doesn't necessarily remove them.

Share

Get started

Automate this without code.

Cloud or your own servers.

Start free Talk to sales