OpenAI Codex vs Gemini CLI: Which Terminal AI Should You Use in 2026?
Both OpenAI Codex and Gemini CLI are open-source terminal coding agents, but one of them just lost its free tier for individual users. As of this writing, Codex still has a no-cost path for individuals (via the ChatGPT Free plan); the original Gemini CLI does not - since 2026-06-18, Google moved individual/free users to a new product, Antigravity CLI. This piece compares models, pricing, context window, sandboxing, and ecosystem - plus a two-branch router to help you decide fast.
- Pricing, free-tier terms, and default configs on both CLIs move fast; the figures below were cross-checked against official docs at the time of writing (August 2026) - verify the live docs before you depend on them.
Codex vs Gemini CLI at a glance
The table below lines up both CLIs on the criteria that matter most - read it first, then dig into the sections below for detail:
| Criterion | OpenAI Codex CLI | Gemini CLI |
|---|---|---|
| Maker | OpenAI | |
| Model | GPT-5.6 (Sol/Terra/Luna tiers) | Gemini 3 (Pro/Flash, selectable) |
| CLI license | Apache-2.0, written in Rust | Apache-2.0 |
| Context window | Effective default ~272K tokens (configurable, see below) | Fixed 1M tokens |
| Individual free tier (Aug 2026) | Yes, via ChatGPT Free plan | No longer (since 2026-06-18) - moved to Antigravity CLI |
| Sandbox | read-only / workspace-write / danger-full-access | Docker/Podman/Seatbelt + its own approval modes |
| Long-run autonomy | /goal (feature-flagged) | --yolo (auto-approve, no scheduler) |
| AgentKit (agentkit.best) | Official target | No target |
The models underneath: GPT-5.6 vs Gemini 3
Codex CLI runs on OpenAI's GPT-5.6, GA since 2026-07-09, with three speed/cost tiers called Sol, Terra, Luna (per the GPT-5.6 announcement page - that page occasionally blocks automated fetches, so verify it yourself if you need exact figures). The three tiers are basically a speed/cost-for-quality trade-off: Sol is fast and cheap for small stuff, Terra is the balanced everyday tier, Luna is slower but reasons harder for tough tasks. Gemini CLI runs on Google's Gemini 3, available as Pro or Flash, selectable via flag or config - Flash favors speed, Pro favors quality, the same trade-off pattern you'd expect from any vendor.
Both let you switch models mid-session, but Codex is anchored to the ChatGPT ecosystem while Gemini CLI is anchored to Google AI / Vertex. If you already pay for ChatGPT for something else (writing, research), Codex reuses that quota; if you're already inside Google Workspace/Cloud, Gemini CLI fits your existing flow more naturally.
Both are open source - but neither is free to run
The part that gets skipped when comparing these two: both CLIs are Apache-2.0 - you can read, fork, and audit the client code yourself. github.com/openai/codex and github.com/google-gemini/gemini-cli are both public with clear licensing, no ambiguity. But "open source" only describes the CLI you install on your machine - it says nothing about the cost of the model calls behind it.
The operating reality: Codex needs a ChatGPT plan (even the Free one) behind it for inference. Gemini CLI (post-2026-06-18) needs a paid Gemini API key or an enterprise Code Assist license for individual users - the original product no longer has a public free path for individuals. In other words: open source does not mean free to run. This is close to the one point no competitor comparison spells out clearly.
Install commands reflect the same reality. Codex CLI: curl -fsSL https://chatgpt.com/codex/install.sh | sh (Windows uses the matching .ps1 script). Gemini CLI: npm install -g @google/gemini-cli, or run it without installing via npx @google/gemini-cli. Once installed, both force a login before you can actually call a model - Codex via a ChatGPT account, Gemini CLI via a Google account or an API key.
Context window: 1M vs "it depends"
Gemini CLI advertises a flat 1M-token context - a fixed number from Gemini 3, nothing to configure. Codex CLI is messier: the GPT-5.6 spec is roughly 1.05M tokens, but Codex CLI's effective default context window was trimmed to about 272,000 tokens (as noted in CLI v0.144.6, dated 2026-07-18) for cost/latency reasons. You can raise it via the model_context_window key in config.toml, up to roughly 1M with auto-compaction kicking in as you approach the ceiling.
That 272K figure moves with each CLI release, and I did not re-verify it independently in this writing session - treat it as a starting point, not a final number. Check the changelog on github.com/openai/codex yourself before relying on it for anything important, like estimating the cost of a long task.
Why this matters in practice: on a large monorepo task where the agent has to read many files before writing anything, Gemini CLI's flat 1M ceiling means you rarely think about the limit at all. Codex CLI's smaller default means you'll hit auto-compaction sooner on the same task unless you raise model_context_window yourself - a small extra step, not a hard blocker, but worth knowing before you're mid-task and wondering why the agent suddenly summarized half your conversation.
Pricing & free tier: the 2026-06-18 shift
Codex has no standalone SKU - it's bundled into a ChatGPT plan: Free, Go ($8), Plus ($20), Pro ($100-200), Business (roughly $20/seat) per the official pricing page (prices move fast, re-check before deciding). No separate CLI fee - install it, use the ChatGPT plan you already have, and you're running.
Gemini CLI used to be entirely free via Google-account login with a generous quota. But on 2026-05-19 Google announced, effective 2026-06-18: Gemini CLI and the Gemini Code Assist IDE extensions stopped serving free requests and requests from Google AI Pro/Ultra for individual users. Individuals were pushed to a new product - Antigravity CLI, a different CLI with a different quota - per Google's official announcement. I checked antigravity.google live: the product currently lists itself as "available at no charge" for developers, but the exact quota/limits aren't spelled out on the landing page - don't assume it matches the old Gemini CLI quota, treat it as "different, and smaller" until an official number surfaces.
Code Assist Standard/Enterprise licenses and paid Gemini API keys are unaffected - organizations on those licenses keep running the original Gemini CLI unchanged, per the same announcement. To be blunt for anyone comparing right now: if you're looking for a free path today, Codex currently has one; the original Gemini CLI does not, for most individual users - unless you're willing to pay for an API key or switch entirely to Antigravity CLI.
Sandbox & approval modes
Both ship a sandbox + approval-mode system, just named differently:
| Codex CLI | Gemini CLI |
|---|---|
Sandbox: read-only / workspace-write (default) / danger-full-access | Sandbox: Docker (default image) / Podman / macOS Seatbelt |
Approval: untrusted / on-request / never | Approval mode: default / auto_edit / yolo |
A concrete example: workspace-write + on-request in Codex means the agent edits files inside your project directory freely but has to ask before running a network-touching command or touching a file outside scope. yolo in Gemini CLI skips nearly all of those prompts - faster, but riskier if you don't review the commit before pushing. For a deeper dive into Codex's sandbox levels and how to tune approval_policy, see Codex sandbox & approval modes.
Ecosystem: Skills, MCP, GitHub
Both are MCP clients - they connect to external MCP servers to extend their toolset. Codex adds two things: native GitHub Actions (openai/codex-action) for automated PR review, and Codex Skills (SKILL.md files, backward-compatible with Claude Code skills - see the official docs). Adding an MCP server in Codex is one line: codex mcp add <name> -- <cmd>, or declare it directly in the [mcp_servers.*] block of config.toml.
Gemini CLI has its own Extensions and Agent Skills (added in v0.23+), and is gradually folding into Antigravity's plugin system for the successor product - Gemini CLI's MCP syntax differs from Codex's, so check the live docs if you need exact steps, since that's not the focus here. To understand Codex Skills end-to-end, see what Codex Skills are.
Autonomy: Goal Mode vs YOLO Mode
Codex has /goal - a long-running mode, currently feature-flagged, for mechanical tasks with a verifiable stop condition (I wrote a separate piece on using it right, with three painful lessons from real use, in how to use Goal Mode effectively). Gemini CLI has --yolo / --approval-mode=yolo - auto-approves every tool call for the session, but there's no long-run scheduler equivalent to /goal; it speeds up a single session, it doesn't replace a multi-step loop with its own stop condition.
AgentKit works with Codex - not with Gemini CLI
Saying this plainly because it's a question I get from readers considering AgentKit: the ak CLI from AgentKit (agentkit.best) supports --target values claude-code, codex, plus experimental cursor/grok - there is no Gemini CLI target. If you're on Codex and want prebuilt skills/subagents/workflows instead of assembling your own review-ship process, that's exactly where AgentKit fits: ak kit init engineer --target codex, then open a new Codex session and run $ak:cook ... right there. Gemini CLI users don't have an equivalent option from AgentKit today - it's not a secret, the target simply doesn't exist yet.
Worth being honest about scope too: Codex's own free tier and /goal mode cost nothing extra - AgentKit is a separate, paid add-on on top of Codex, not a requirement to use Codex at all. It's only relevant if you specifically want prebuilt skills/subagents instead of writing your own.
More detail: using AgentKit inside Codex or the full AgentKit review.
On Codex and want prebuilt skills/subagents? AgentKit installs straight into Codex via ak kit init engineer --target codex - it won't work with Gemini CLI, since AgentKit doesn't support that CLI yet. Priced per the live pricing page at the time of writing; the Engineer Kit often carries a first-purchase discount.
Which one should you use?
Two quick branches:
- Already on a ChatGPT plan, want native GitHub PR review, or need a free path today? Pick Codex.
- Need the largest context window out of the box, work inside Google Cloud/Workspace, or already hold an enterprise Code Assist license? Pick Gemini CLI (the original, via an enterprise license - not the closed individual tier).
Neither branch fits - say you have neither a ChatGPT plan nor a Google enterprise license? It's worth comparing against Claude Code too, a third option competing directly in the same terminal/IDE coding-agent category, with its own free tier.
Frequently asked questions (FAQ)
Is Gemini CLI still free?
No, not for individual users since 2026-06-18. Google moved individual/free users to a new product, Antigravity CLI; enterprise Code Assist licenses and paid Gemini API keys are unaffected.
Is Codex CLI open source?
Yes, Apache-2.0, written mostly in Rust, source public at github.com/openai/codex. But open source only describes the CLI - running the model behind it still needs a ChatGPT plan.
Which has the bigger context window?
Gemini CLI is fixed at 1M tokens. Codex CLI's effective default is smaller (around 272K tokens per the most recent note), but configurable up to roughly 1M via model_context_window in config.toml.
Does AgentKit work with Gemini CLI?
No. AgentKit only has official targets for Claude Code and Codex (plus an experimental Cursor/Grok target) - there is no Gemini CLI target.
Which is safer to run unattended?
Both ship their own sandbox and approval-mode system, and neither is foolproof - real-world sandbox-bypass research exists for both categories of tool, so don't run the highest-privilege mode (danger-full-access / yolo) on a machine with sensitive data.
Which should you pick in 2026?
If you need a free path today or already have a ChatGPT plan, pick Codex. If you need a fixed 1M context or hold an enterprise Code Assist license, pick Gemini CLI. If neither applies, also consider Claude Code.
Conclusion
Both are solid open-source CLIs, but the 2026 story is no longer "both are free." The original Gemini CLI closed its free path for individuals on 2026-06-18, while Codex still keeps a no-cost path through the ChatGPT Free plan. If you're on Codex, AgentKit is an extra option for prebuilt skills/subagents; Gemini CLI has no equivalent yet. New to Codex? See what OpenAI Codex actually is, or compare the wider field in the best AI coding tools of 2026.