Skip to main content
kRouter
All posts
Save money

Codex CLI free: use your ChatGPT plan in every tool

Every ChatGPT plan includes Codex, yet your other tools still bill the OpenAI API. How to use the Codex models you already pay for in every tool.

Kodelyth · The team behind kRouter
· Updated
7 min read

If you pay for ChatGPT and also have Cline, Aider, or your own scripts configured with an OPENAI_API_KEY, you are almost certainly paying for OpenAI models twice. Once in the plan, and again per token everywhere else.

This is not a pricing complaint. It is a configuration problem, and it is fixable in about ten minutes.

What changed since this was first written

This post first ran in August around GPT-5.4, GPT-5.4 mini and GPT-5.3 Codex. OpenAI has moved on since:

  • Every ChatGPT plan includes Codex, from Free and Go ($8 a month) to Plus ($20) and Pro (from $100), with usage limits that depend on the plan and the model.
  • GPT-5.4 and GPT-5.4 mini left Codex for ChatGPT sign-ins on August 31, 2026, GPT-5.3 Codex Spark retired on September 14, and GPT-5.5 retires on October 14, 2026.
  • The current Codex models are the GPT-6 line: GPT-6 Astra, GPT-6.1 Sol, GPT-6 Sol and GPT-6 Luna.

The setup below is unchanged. The model names are not.

The double-billing pattern

Codex CLI uses your ChatGPT plan's allowance. That part is fine -- it is what you subscribed for.

Every other tool reads OPENAI_API_KEY and hits the OpenAI API directly. Cline, Continue, Aider, your own scripts. None of them know the plan exists, so none of them use it.

The result is a subscription that only pays off inside one CLI, while the tools you actually spend the day in bill separately. Most people never notice because the two charges arrive from different places.

What the plan carries

Model idWhat OpenAI says it is for
gpt-6-astraThe most capable model, for complex work
gpt-6.1-solNear-Astra performance at a lower cost
gpt-6-solOpenAI's suggested replacement for GPT-5.5 on paid plans
gpt-6-lunaThe most efficient model, for focused, high-volume tasks; the replacement on Free and Go
gpt-5.5Legacy, retiring October 14, 2026

The cheaper models go a lot further against your limits. OpenAI's own figures for a five-hour window on Plus are 5-45 local messages with GPT-6 Astra, 15-160 with GPT-6.1 Sol and 350-3,000 with GPT-6 Luna. Pro plans currently have no five-hour limit, and weekly limits can apply to all plans.

GitHub Copilot's model list carries the GPT-6 line as well. If you hold Copilot too, that is a second, independent pool for the same family of models, billed against Copilot's monthly credits.

The fix

Expose the ChatGPT plan as a normal endpoint that every tool can reach:

npm install -g @sifxprime/krouter
krouter -t

Open http://localhost:20128/dashboard, go to Providers, choose OpenAI Codex, and sign in with your ChatGPT account in the browser. kRouter shows a risk notice first: a ChatGPT login is not licensed for use through a router, and OpenAI can restrict the account.

kRouter's built-in model list for Codex has not caught up with OpenAI: it still shows gpt-5.5, gpt-5.4 and the gpt-5.3-codex variants. The provider page can fetch the live list from your account, and kRouter passes whatever id follows cx/ through to Codex, so cx/gpt-6-luna is the form to use. Send one test request (below) before you build anything on a GPT-6 id.

Then point everything at one URL:

export OPENAI_BASE_URL=http://localhost:20128/v1
export OPENAI_API_KEY=<your-krouter-key>

On the machine kRouter runs on, any value works for the key; calls from another machine need one from the dashboard's Endpoint page. Every tool on the machine now draws from the plan first.

Codex CLI itself does not need any of this. If you want the opposite direction -- Codex running Claude, GLM or Kimi through kRouter -- see Codex CLI with any model.

Verify it before you trust it

Config that looks right and does nothing is the normal failure mode here. From the same machine:

curl -s http://localhost:20128/v1/chat/completions \
  -H "content-type: application/json" \
  -d '{"model":"cx/gpt-6-luna","messages":[{"role":"user","content":"reply with the word ready"}],"max_tokens":16}'

A choices array means the plan is reachable. A 401 means the Codex connection needs signing in again. An error that names the model means your plan, or kRouter, does not serve that id; pick one from the provider page's live list. Then run a real request from your editor and watch the dashboard -- you want to see it land on cx, not fall through.

Then find the stray keys

This is the step people skip, and it is the one that actually saves the money.

grep -rn "OPENAI_API_KEY" ~/.zshrc ~/.bashrc ~/.profile ~/.config 2>/dev/null

A stale export tied to a real billing account will silently win over anything you set later in a session. Developers have paid direct-API rates for months because of one forgotten line in a shell profile. Check the tool-specific config too -- Cline and Continue each store their own key separately from the environment.

Chains worth running

Build these as a combo in the dashboard and use the combo's name as the model. kRouter tries the entries in order, cools down whatever is rate limited, and moves on.

If you have ChatGPT Plus:

1. cx/gpt-6-luna          # plan, goes furthest against the limits
2. cx/gpt-6.1-sol         # plan, for harder turns
3. kr/claude-sonnet-4.5   # Kiro free plan
4. ds/deepseek-v4-flash   # DeepSeek API, metered, last resort

Two plan positions before anything metered fires. The free tier catches the gap between exhausting the plan and paying per token.

If you have ChatGPT and Copilot:

1. cx/gpt-6.1-sol         # ChatGPT plan
2. gh/gpt-5.4             # Copilot credits, at that model's API rate
3. ds/deepseek-v4-flash   # cheap overflow

Two subscriptions you already hold, drawing on independent pools. Copilot's credits are spent at each model's API rate, so this costs nothing extra only until the month's credits run out.

If you have ChatGPT Pro:

1. cx/gpt-6-astra         # largest allowance
2. ds/deepseek-v4-flash   # overflow, probably never reached

Run this for a month and check the dashboard. If the overflow tier never fires, you may be over-provisioned, and Plus with a little metered overflow could cover the same usage. That is worth knowing before the next renewal.

The arithmetic

A developer on ChatGPT Plus with moderate multi-tool use:

BeforeAfter
Codex CLIplanplan
Clinedirect APIplan, small overflow
Continuedirect APIplan
Scriptsdirect APIplan

The saving is not from a discount. It is from the plan becoming load-bearing instead of decorative. Whatever your other tools were costing per month is most of what you stop paying. The same endpoint also works for a small home-made coding agent.

What breaks

Cursor cannot reach localhost. Its requests come from Cursor's servers, so a local router is not visible to it. kRouter's Endpoint page has a tunnel for this (the Cursor walkthrough); otherwise Cursor stays on its own billing. Cline, Continue and Aider run on your machine and have no such restriction.

Plan limits are real limits. A subscription is not unlimited, and agentic runs consume far more than chat. The fallback tier exists precisely for the end of the window.

Models retire. Three Codex models retired or are retiring between August and October 2026. A chain absorbs that better than a single pinned id, but check the live model list when requests start failing.

OAuth sessions expire. When Codex requires re-auth, requests start failing in ways that look like model errors. The dashboard shows connection health; check there first.

Terms are OpenAI's. Whether a subscription may be used through a third-party client is between you and them, and kRouter's risk notice exists for this reason. Read the plan terms, particularly if you are considering this across a team rather than for personal use. This is not legal advice.

Common questions

Does this give me free GPT access?

It gives you the access you already bought, in the tools that were not using it. The word "free" in searches around this usually means "not billed again", and that is what this does. Every ChatGPT plan includes Codex, Free and Go too, so for light use it can genuinely cost nothing -- within those plans' smaller limits.

Which Codex model should I put first?

The one that goes furthest against your limits for routine work. On Plus, OpenAI's figures give GPT-6 Luna hundreds to thousands of local messages per five-hour window against single or double digits for GPT-6 Astra. Put Luna first for routine traffic and a Sol or Astra model behind it for the turns that need more.

Can I use this for a team?

Technically it works the same way. Whether your plan permits it is a terms question, and team plans generally have stricter language than individual ones. Check before you scale it.

What if I do not pay for ChatGPT at all?

ChatGPT Free includes Codex with small limits, so the same setup works at low volume. Beyond that, start with the free tiers instead, which serve Claude and Gemini models without any subscription.

Kodelyth · The team behind kRouter

Published by Kodelyth, the team that builds kRouter. Posts are drafted with AI assistance and reviewed by a person before they go out. kRouter is free and MIT licensed.

Install kRouter