OpenAI Codex CLI is an open-source, Rust-based coding agent that runs in your terminal — the software is free, but the model calls behind it are metered. The cheapest legitimate path is signing in with a free ChatGPT account, which includes limited Codex access at no cost. For heavier or sustained usage, routing Codex through OpenRouter's free model pool with automatic provider failover is the most reliable zero-dollar setup. You can also bring your own API key to any OpenAI-compatible provider, or run a local model via Ollama. Each method trades convenience for capability differently, and the crossover point where free stops being enough is lower than most people expect.
Last verified: 2026-08-01 · Volatile facts: model availability, pricing, and rate limits change frequently — re-check before relying on specific numbers.
- Best for trying Codex: Free ChatGPT tier (zero setup, tight caps)
- Best for sustained free builds: OpenRouter routing with
:freemodels (auto-failover, 50–1,000 req/day)- Best for control: BYOK through your own provider key (not free, but cheapest per-token)
- Best for offline: Local model via Ollama (no tokens, heavy hardware)
What Is OpenAI Codex CLI?
Codex CLI is OpenAI's open-source command-line coding agent, first released in May 2025 and written in Rust for speed. You install it on your machine, point it at a project directory, and give it a task in natural language. It then reads your files, plans multi-step changes, writes code, and runs shell commands — all inside a sandboxed environment with an approval system you control. The tool itself is free and open-source under the Apache-2.0 license, maintained on GitHub at openai/codex.
The catch is what happens behind the interface: every plan, file read, and command decision requires a round-trip to a language model. Out of the box, Codex expects either a ChatGPT account sign-in (which draws on your plan's usage allowance) or an OpenAI API key (which bills per token). A single complex build — where Codex reads dozens of files, plans, iterates, and tests — can consume hundreds of thousands of tokens, which is why the "free" label on the CLI itself can be misleading if you don't understand the two layers.
How Much Does Codex CLI Actually Cost?
The CLI software costs nothing. The model inference it depends on is what you pay for, and there are two billing models:
ChatGPT plan billing: When you sign in with a ChatGPT account, Codex draws on a usage allowance bundled into your plan. As of 2026, the plans are:
| Plan | Price | Codex Access | Usage Caps |
|---|---|---|---|
| Free | $0/mo | Yes (limited time) | Tightest; 5-hour rolling window + weekly limits |
| Go | $8/mo | Yes (limited time, 2× Free) | Small |
| Plus | $20/mo | Yes | Mid |
| Pro | $200/mo | Yes | Highest for solo users |
| Business | Seat-based | Yes | High per seat |
Sources: OpenAI Codex CLI documentation, OpenAI Codex pricing.
On April 2, 2026, OpenAI moved Codex from per-message pricing to token-based (credit) pricing aligned with API token usage, applying to Plus, Pro, and Business plans. Plus and Pro users can also purchase additional credits when they hit their allowance — each credit is worth roughly $0.04 (Inventive HQ, 2026-05-29).
API key billing: If you use an OpenAI API key instead of a ChatGPT sign-in, you pay per million tokens at the API rate. For example, GPT-5.3-Codex costs $1.75 per million input tokens and $14 per million output tokens (per the OpenRouter Codex tutorial). A long, chatty build session can rack up significant costs fast.
Is There a Free Tier for Codex CLI?
Yes, but with important limitations. OpenAI rolled Codex out to every ChatGPT plan including Free and Go for what it explicitly called a "limited time" (Apidog, 2026-04-24). The free tier gives you:
- Local coding tasks only — no cloud features like GitHub code review or Slack integration (those start on Plus)
- A 5-hour rolling usage window with the smallest allowance of any plan
- Weekly limits on top of the rolling window
- The plan caps and exact message counts are not published, but the /status command inside Codex shows your remaining quota in real time
OpenAI does not publish an exact free-tier number. The allowance is "the smallest of any plan" per the Codex pricing page. For a developer kicking the tires or prototyping a single small task, it's enough. For any sustained work — building a full app, refactoring a module — you will hit the wall quickly.
The honest framing is: free Codex is a try-before-you-buy tier, not a production plan. When you start hesitating to use the tool because you're worried about running out, that's your signal you've outgrown free (eesel.ai, 2026-06-18).
How to Set Up Codex CLI for Free: Method 1 — ChatGPT Free Tier
The simplest zero-cost path: install Codex CLI and sign in with a free ChatGPT account.
- Create a free ChatGPT account at chatgpt.com if you don't already have one. This account is your free Codex access — no separate registration.
- Install Codex CLI using one of three methods:
# Standalone installer (macOS/Linux)
curl -fsSL https://chatgpt.com/codex/install.sh | sh
# npm (cross-platform)
npm install -g @openai/codex
# Homebrew (macOS/Linux)
brew install codex
- Run Codex for the first time — it will prompt you to sign in:
# Browser OAuth (local machines)
codex
# Device code flow (headless boxes, remote servers)
codex login --device-auth
Check your quota at any time with the
/statuscommand inside Codex — it shows remaining weekly message budgets and the current context window.Pick your model — on Free or Go you may need to switch manually:
/model gpt-5.5
Practical limit: The free tier works for one well-scoped task at a time — fixing a bug in a single file, writing a small utility function, or generating a single component. "Fix the date formatting bug in utils/date.ts" goes a lot further than "refactor the whole app." Scope precision is your primary lever for making the free tier last.
Source: OpenAI Codex CLI documentation; setup instructions verified against primary docs.
Method 2 — Route Codex Through OpenRouter's Free Model Pool
This is the most reliable path for sustained free usage. OpenRouter is an API gateway that sits between Codex and the model providers — you point Codex at OpenRouter's single endpoint, and OpenRouter routes your requests across hundreds of models from dozens of providers, including a rotating pool of free models. When one provider caps out, OpenRouter silently falls over to the next.
Why this works
Codex CLI supports custom model providers through its config.toml file. OpenRouter speaks the same OpenAI-compatible API that Codex expects, so the integration is a configuration block — no code changes, no new tool. You still get the same agent experience: planning, file editing, command execution, sandboxing, approvals. Only the model behind it changes (OpenRouter Codex CLI integration docs).
The 5-step setup
Create an OpenRouter account and API key at openrouter.ai/keys. The key starts with
sk-or-. No credit card required for free-tier models.Open
~/.codex/config.toml(create it if it doesn't exist) and add:
model = "nvidia/nemotron-3-ultra-550b-a55b:free"
model_provider = "openrouter"
model_reasoning_effort = "high"
[model_providers.openrouter]
name = "OpenRouter"
base_url = "https://openrouter.ai/api/v1"
env_key = "OPENROUTER_API_KEY"
wire_api = "responses"
- Set your API key in your shell profile:
export OPENROUTER_API_KEY="sk-or-v1-..."
- Run Codex in your project directory:
cd /path/to/your/project
codex
- Verify routing — open the OpenRouter Activity dashboard and confirm your requests show up with the right model name and token count.
Two gotchas that trip people up
Model ID must include the provider prefix. A bare nemotron-3-ultra will throw model_not_found. The slug must be the exact OpenRouter ID, like nvidia/nemotron-3-ultra-550b-a55b:free. Copy it from openrouter.ai/models.
wire_api must be "responses". Codex originally supported both the Chat Completions API (wire_api = "chat") and the Responses API (wire_api = "responses"). OpenAI deprecated the chat path and removed it in February 2026 — a custom provider with wire_api = "chat" or no wire_api at all now fails on startup (OpenRouter blog, 2026-06-17).
Also note: model_provider and model_providers only take effect in your user-level ~/.codex/config.toml. Codex ignores them in a project-local .codex/config.toml and prints a startup warning.
What "free" means on OpenRouter
OpenRouter's free tier has two rate tiers, and the threshold is whether you've ever purchased credits:
| Credits Purchased (All Time) | Requests Per Minute | Requests Per Day |
|---|---|---|
| Less than $10 | 20 | 50 |
| At least $10 | 20 | 1,000 |
Source: OpenRouter API Limits documentation.
The 20 RPM limit applies regardless of credit balance. The daily cap is the real constraint — 50 requests per day on a completely free account is enough for prototyping but runs out fast during a chatty build. A one-time $10 credit purchase lifts the daily limit to 1,000, which is dramatically more headroom. This is technically no longer "free" in the strictest sense, but it's the cheapest way to make Codex usable for real work.
Free model options
OpenRouter's free model pool rotates, but as of August 2026 includes strong coding-capable models:
| Model | Context Window | Best For |
|---|---|---|
nvidia/nemotron-3-ultra-550b-a55b:free |
1M tokens | Long-running agentic workflows, coding agents |
poolside/laguna-s-2.1:free |
262K tokens | Software engineering, agentic coding |
cohere/north-mini-code:free |
256K tokens | Code generation, terminal tasks |
meta-llama/llama-3.3-70b-instruct:free |
128K tokens | General-purpose chat and code |
qwen/qwen-2.5-coder-32b-instruct:free |
— | Code-focused tasks |
Source: OpenRouter Free Models collection.
These models are genuinely free — $0 per million input and output tokens — but they have limits. Free tiers get rate-limited by the underlying providers, especially during peak times. The advantage of routing through OpenRouter rather than hitting a single free provider directly is the automatic failover: if one provider returns a 429 (rate limited) or is down, OpenRouter retries against another provider for the same model. You don't have to manage this yourself.
The routing trick that keeps builds going
The combination that makes this setup practical for long builds is pairing OpenRouter's auto-failover with a model slug. Instead of pinning a single model, you can use OpenRouter's free model router (openrouter/free), which selects from available free models based on your request's requirements. Or you can specify a fallback chain. When one provider caps out mid-build, the request silently hops to the next available one — the build continues instead of freezing.
This is the key insight most people miss: no single free provider is bottomless, but a pool of them with automatic failover means you never lean on just one. The build gets written either way.
Method 3 — Bring Your Own Key (BYOK) Through Any OpenAI-Compatible Provider
Codex CLI's custom provider framework isn't limited to OpenRouter. Any model service that speaks the Responses API can be wired in as a custom provider in config.toml. This includes:
- Direct OpenAI API (pay-per-token at published rates)
- Azure OpenAI (enterprise endpoint with different billing)
- Google Vertex AI (via command-based auth using
gcloud) - Amazon Bedrock (multi-cloud model access)
- Any self-hosted OpenAI-compatible endpoint (vLLM, LiteLLM, etc.)
This is not a free method — you pay the provider's per-token rate directly. But it's the cheapest per-token path if you already have a relationship with a specific provider, and OpenRouter's BYOK feature routes through your own key for 5% of what the provider would bill (waived for the first 1M requests each month) (OpenRouter Codex tutorial).
For teams, this path provides centralized budget management — you can set spending limits, allocate credits, and prevent unexpected cost overruns across developers using Codex.
Source: Codex CLI Advanced Configuration, OpenAI Developers; Daniel Vaughan, Codex CLI Custom Model Providers Guide.
Method 4 — Run a Local Model via Ollama or LM Studio
Codex CLI ships with built-in support for local model providers — ollama and lmstudio are two of its three default providers alongside openai. You can point Codex at a locally-running model with zero API costs and no network round-trips.
Why this is harder than it sounds
Running a capable coding model locally has two real tradeoffs:
Output quality — small local models (7B–14B parameters) produce noticeably rougher code than cloud models. The results may work for simple tasks but require more manual correction. For a framework on catching these quality issues before they compound, see our guide on stopping AI coding from creating technical debt.
Hardware cost — a model large enough to be useful for agentic coding (30B+ parameters) needs significant RAM and GPU memory. On a basic laptop without a dedicated GPU, inference is slow enough that the agent's multi-step planning loop becomes painful to use. Everything else on your machine slows down while the model runs.
When local makes sense
If you already have a workstation with a strong GPU (24GB+ VRAM) or an Apple Silicon Mac with unified memory, running a model like Qwen 2.5 Coder 32B locally through Ollama is genuinely free — no tokens, no rate limits, no network dependency. For offline work or sensitive codebases that can't leave your machine, this is the only acceptable path.
For most developers on standard hardware, the cloud-based OpenRouter approach (Method 2) provides better output quality without tying up your machine's resources.
Source: Codex CLI built-in providers (openai, ollama, lmstudio) — GitHub openai/codex.
How Do These Methods Compare?
| Method | Setup Difficulty | Cost | Usage Limits | Output Quality | Best For |
|---|---|---|---|---|---|
| ChatGPT Free tier | Easiest (sign in) | $0 | Very tight (5-hr window) | Highest (GPT-5.x) | Trying Codex out |
| OpenRouter free models | Easy (config.toml) | $0–$10 one-time | 50–1,000 req/day | Good (varies by model) | Sustained free builds |
| BYOK (own API key) | Medium | Per-token | Provider-dependent | Highest | Production / teams |
| Local model (Ollama) | Hard | $0 (but hardware) | Unlimited | Lower | Offline / sensitive code |
How to Stretch Free Codex Further
Turn on token compression early. Tools like prompt caching and context compression cut the tokens each build consumes, making your free tiers go further. Codex itself supports prompt caching on certain models — check your provider's documentation for cache-read pricing.
Let auto-failover do its job. When a provider caps out, don't panic and restart. If you're on OpenRouter, the request is already hopping to the next provider. Restarting wastes the context you've built up.
Be realistic about limits. Free tiers have hard ceilings. No single provider is bottomless — the trick is never leaning on just one. Free-model rate limits apply "regardless of account status" per OpenRouter's limits documentation.
Scope tasks precisely. "Fix the date formatting bug in utils/date.ts" costs fewer tokens than "refactor the whole app." On any free tier, precision is your primary lever.
For a deeper dive on cutting token consumption across coding agents, see our guide on free tools that cut Claude Code tokens by up to 80% — the same principles apply to Codex.
What This Means for You
If you're an individual developer or a small team evaluating coding agents, start with the free ChatGPT tier to learn what Codex can do, then move to OpenRouter routing when you need sustained builds without hitting a paywall. The $10 one-time credit purchase on OpenRouter is the single highest-leverage move — it lifts the daily request cap from 50 to 1,000, which is enough for most real coding sessions.
If you're already on a ChatGPT Plus or Pro plan, Codex is included — you don't need any of this. Your sign-in already gives you access with higher caps than the free tier.
If you're running a whole AI agent stack and want to understand how Codex fits alongside other free AI tools, our roundup of the 13 best free AI agent tools in 2026 covers the broader landscape, and our guide on building a free AI agent operating system shows how to wire multiple agents together at no cost. For a parallel approach with Claude's CLI, see our guide on how to use Claude Code for free in 2026 — the same open-routing strategy works there too.
FAQ
Q: Is OpenAI Codex CLI actually free?
A: The CLI software is free and open-source (Apache-2.0). But the model inference it depends on is metered. You can use it at no cost by signing in with a free ChatGPT account (limited-time access with tight caps) or routing through OpenRouter's free model pool. Neither path requires a credit card.
Q: Can I use Codex CLI without a ChatGPT account?
A: Not with OpenAI's default setup — Codex requires either a ChatGPT sign-in or an OpenAI API key. However, if you configure a custom provider like OpenRouter in config.toml, you bypass OpenAI entirely and authenticate with OpenRouter's API key instead. No ChatGPT account is needed in that configuration.
Q: What is wire_api and why does it matter?
A: wire_api controls which API protocol Codex uses to talk to a provider. As of February 2026, Codex removed support for the older chat value — custom providers must set wire_api = "responses" or Codex errors on startup. This is the most common setup failure when routing through OpenRouter.
Q: How many free requests do I get on OpenRouter?
A: Free models are limited to 20 requests per minute. The daily cap is 50 requests on a completely free account, or 1,000 requests per day if you've purchased at least $10 in credits at any point. The $10 credit purchase is a one-time threshold — it permanently lifts your daily limit.
Q: Are OpenRouter's free models good enough for coding?
A: Several free models on OpenRouter are specifically optimized for coding, including Poolside Laguna S 2.1 (70.2% on Terminal-Bench 2.1) and Cohere North Mini Code. Quality varies by model — for complex multi-file refactoring, you'll notice the difference versus GPT-5.x. For prototyping, generating standalone components, and routine coding tasks, the best free models are more than adequate.
Q: What happens when a free provider rate-limits me mid-build?
A: If you're routing through OpenRouter, the platform automatically retries against another provider for the same model (auto-failover). Your build continues without freezing. If you're hitting a single provider directly (not through OpenRouter), the request fails with a 429 error and you have to retry manually.
Q: Should I just run a free model locally instead?
A: You can — Codex CLI has built-in Ollama and LM Studio support. But local models on standard laptops are slow and lower quality for agentic coding than cloud models. Local makes sense for offline work, sensitive code, or if you already have a high-end GPU. For everyone else, the cloud-based OpenRouter approach is lighter on your machine and produces better results.

Discussion
0 comments