Can Codex use your ChatGPT subscription?
Yes. Codex CLI signs in with your ChatGPT Plus or Pro plan and no API key. Here is what the plan covers, and why the unofficial bridge tools keep breaking.
Yes, Codex uses your ChatGPT subscription
Codex can use your ChatGPT subscription, and that is the supported way to run it. Run codex login, finish the browser step, and the CLI charges your ChatGPT plan instead of an API key. As of October 2026 the plans that include Codex are Free, Go, Plus, Pro, Business, Edu and Enterprise. OpenAI added Free and Go "for a limited time" when the Codex app launched in February 2026 and still lists both today, Free for quick coding tasks and Go for lightweight ones, so on those plans the CLI does not need an API key either.
npm install -g @openai/codex
codex login
codex login statuscodex login status reports which account the CLI is holding and which auth method it will use. On macOS you can install the same binary with brew install --cask codex. If the status output names an API key when you wanted the subscription, unset CODEX_API_KEY if it is set, run codex logout and log in again.
So the short answer is yes, for Codex. The question usually arrives from the other direction: you installed some other agent, it demanded a key starting with sk-, and you want to know why the plan you already pay for is not enough. That has a real mechanism behind it, and it is worth understanding before you go looking for a workaround.
Why a coding agent asks for a separate API key
A ChatGPT plan and the OpenAI API are two products with two billing systems. The plan is a subscription to ChatGPT. The API is a metered service with its own balance under platform.openai.com. They do not share a wallet, and they do not share a credential. Eligible Pro and Business subscriptions now offer API credits after activation for a linked API organization, but those credits do not cover Codex usage through API keys.
What codex login stores is not an API key. It is an OAuth (open authorization) token, cached in ~/.codex/auth.json or your operating system's credential store. First-party clients accept it: the CLI and the IDE extension. api.openai.com does not accept it as a bearer key. An agent using the public OpenAI API needs API credentials, which is why aider asks for an API key. The public API also supports short-lived access tokens issued through workload identity federation.
OpenCode and Cline both document ChatGPT subscription sign-in, so a third-party agent does not always need an API key. OpenAI also supports ChatGPT plan usage in participating apps and sites, subject to plan and administrator controls.
This split is not specific to OpenAI. The same subscription login versus API key decision in Claude Code works the same way for the same reason, and comparing the major coding agents on how they bill includes checking which subscription sign-ins each tool supports.
What the ChatGPT plan actually covers
The data behind this chart
[
{
"plan": "Free",
"usd_per_month": 0,
"codex_cli": "yes"
},
{
"plan": "Go",
"usd_per_month": 8,
"codex_cli": "yes"
},
{
"plan": "Plus",
"usd_per_month": 20,
"codex_cli": "yes"
},
{
"plan": "Pro",
"usd_per_month": 100,
"codex_cli": "yes"
},
{
"plan": "Business",
"usd_per_month": 25,
"codex_cli": "yes"
}
]Those are published list prices as of October 2026, for the 5 individual and small-team plans. The Business figure is per user on monthly billing, and it is lower on annual billing. Plus costs 20 dollars a month, and Pro starts at 100 with higher Pro tiers available for larger limits. Read the pricing page before you buy, because these numbers move.
How usage is metered depends on the plan. Plus and standard Business plans have a five-hour window. Pro currently has no five-hour limit, and OpenAI says weekly limits may also apply on top. Inside a Codex session, /status shows remaining limits; the usage dashboard shows current limits and reset times. On Plus or Business, check them before you start a long refactor, because the five-hour window is the one that ends a working session early.
One detail catches people out. Local CLI sessions and cloud Codex tasks draw on the same plan allowance, and so does ChatGPT Work. Ordinary chat in the app does not: OpenAI meters it separately. A heavy afternoon in the terminal leaves less for cloud tasks and Work that day, but it does not eat your chat limits. On Plus and Pro you can buy extra credits when you reach the cap instead of moving up a plan.
What the trending ChatGPT bridges actually do
A bridge is a small local server. It signs into the consumer web product using your account, then exposes an endpoint shaped like /v1/chat/completions on localhost. You point your agent at that address, the agent believes it is talking to the API, and the bridge replays the browser session's own requests underneath. Some variants skip the browser and call an internal endpoint directly, which is the same idea with fewer moving parts.
Automating a consumer web session this way is against OpenAI's terms of use, and the account it can cost you is your own. This guide does not cover installing these tools, handling session credentials, extracting cookies, or any other step involved in making one work.
The engineering problem is separate from the terms problem, and it is just as decisive. The interface a bridge imitates is internal. Nothing promises it will stay the same. You are maintaining an unpaid integration against a target that has no reason to hold still.
Route 1: the subscription login the vendor ships
When the vendor ships its own CLI, this route uses the subscription you already pay for. For Codex that is codex login. Two situations need more than the bare command.
On a server with no browser, enable device code login in your ChatGPT security settings or workspace permissions, then use:
codex login --device-authThat prints a code you type into a browser on your laptop. The alternative is to forward the callback port over SSH and run the normal flow on the server:
ssh -L 1455:localhost:1455 user@remote
codex loginYou can also copy ~/.codex/auth.json from a machine that is already signed in and uses file-based credential storage. Treat that file like a password, because it holds live access tokens. Mode 600, owned by the user that runs the agent, and never inside a git repository or a synced folder.
If a machine keeps picking the wrong credential, pin it in ~/.codex/config.toml:
forced_login_method = "chatgpt"Set it to "api" for the opposite behaviour. Exporting OPENAI_API_KEY alone does not override a stored ChatGPT login. The current authentication loader checks CODEX_API_KEY for its environment-key override, then falls back to stored authentication. Pinning restricts the allowed login method; check codex login status to confirm the credential in use.
Route 2: an API key with a hard spend cap
An API key buys two things the plan does not: access outside Codex's subscription usage windows, and a credential for agents that support the OpenAI API. It is not a universal agent credential: Gemini CLI requires Google authentication or Google-issued credentials. It also charges per token, so an agent stuck in a retry loop spends real money at machine speed. Cap it before you paste the key anywhere.
Prepay a small balance and turn auto recharge off, but do not treat that balance as an instantaneous spending cutoff. API access can continue after credits run out, creating a negative balance that is deducted from your next purchase. Set a monthly organization or project spend limit, turn on Enforce a hard limit, and add spend alerts. Alerts alone do not stop requests, and hard-limit enforcement can also lag slightly.
Once prepaid exhaustion is enforced, requests fail with HTTP 429 and a credit_balance_exhausted error. That stops further requests, but it does not guarantee the agent stops at exactly the balance you loaded.
Create one project and one key per machine. Platform usage then shows you which box spent what, and revoking the key on a laptop you no longer use does not break the server. Sign Codex in by piping the key, so it never becomes a command argument or a shell history line:
printenv OPENAI_API_KEY | codex login --with-api-keyKeep the export in a file only your own user can read. If you run agents on a server, running OpenCode on a VPS covers key handling for an agent that also supports ChatGPT Plus or Pro subscription sign-in, and tracking coding agent spend helps you work out whether metered billing is really cheaper for you than a flat plan.
Route 3: a local model for the bulk, a hosted model for the hard parts
Most of what a coding agent does is mechanical: reading files, renaming symbols, writing a test that looks like three existing ones, summarising a diff. A local model handles that at no marginal cost. Keep the hosted model for the work that needs judgement.
Codex supports this directly. codex --oss uses a local model provider, selected through --local-provider, your configured oss_provider, or a prompt offering LM Studio and Ollama. Choose Ollama for these commands:
ollama pull gpt-oss:20b
codex --oss -m gpt-oss:20bTo make it permanent, declare the provider in ~/.codex/config.toml:
model = "gpt-oss:20b"
model_provider = "ollama"
[model_providers.ollama]
name = "Ollama"
base_url = "http://localhost:11434/v1/"
wire_api = "responses"Two constraints decide whether this is practical for you. Ollama's own Codex page asks for a context window of at least 64k tokens, and an agent fills context quickly because it pastes whole files into the prompt. That means memory. Ollama uses MXFP4 quantization at 4.25 bits per parameter for the model's expert weights and says gpt-oss:20b runs with as little as 16 GB of memory; a larger context window needs more. The larger gpt-oss:120b download is 65 GB. Sizing RAM and CPU for a coding agent VPS has the working numbers.
Switching between local and hosted by hand works fine. Automating the choice is what a gateway is for. A self-hosted LiteLLM gateway gives every agent one endpoint and one place to read spend, and routing cheap work to a local model and hard work to a hosted one covers where to draw that line without making the agent worse at its job.
Picking a route
If you already pay for ChatGPT and you work from one machine, use codex login and keep an eye on /status. That is the whole answer, and it costs nothing extra.
If you drive several agents, or run unattended jobs, or use tools with no first-party login, buy an API key, prepay a small balance, and turn auto recharge off. Enable a hard spend limit as well, allowing for enforcement delay. Add a local model for the bulk work once the metered bill starts to bother you.
What failure looks like on each route
Subscription at the cap: Codex refuses further included usage until a limit resets or you use available credits. Check the usage dashboard for the exhausted limit and reset time. Nothing is broken. Wait for the reset, buy credits, or move that session to a local model.
API key with an empty balance: HTTP 429 with credit_balance_exhausted once exhaustion is enforced. Top up the balance deliberately. A hard spend limit instead returns organization_spend_limit_exceeded or project_spend_limit_exceeded; topping up does not raise that limit. If you never want a subscription usage window to stop you mid-task, the key avoids that window, but API rate limits, spend limits and available credits still apply.
Wrong credential in use: codex login status names the auth method in force. If it reports an API key with an empty balance while your ChatGPT allowance sits untouched, that is the entire bug. Unset CODEX_API_KEY if it is set, run codex logout, then codex login, then pin forced_login_method so it cannot drift back.
A bridge: a 401 or 403 from your local proxy, or a stream that dies halfway through a reply. Check the bridge's logs and maintenance notes to identify the cause.
FAQ
Can Codex use my ChatGPT Plus subscription instead of an API key?
Yes. Run codex login, finish the browser step, and Codex bills your ChatGPT plan. As of October 2026 Codex is included with Free, Go, Plus, Pro, Business, Edu and Enterprise, so none of those plans needs an API key for the CLI. Confirm which credential is active with codex login status.
Why does my other coding agent still want an OpenAI API key?
Because its public OpenAI API connection needs API credentials, not the OAuth token stored by codex login. Aider documents this API-key route. OpenCode and Cline also offer subscription sign-in, so check the agent's authentication options before buying API credits. Eligible Pro and Business plans offer API credits after activation, but those credits do not cover Codex usage through API keys.
Is it against the rules to route a coding agent through my ChatGPT web session?
Yes. Automating a consumer web session is against OpenAI's terms of use, and it can cost you the account. These bridges depend on an internal interface with no compatibility promise. OpenCode's and Cline's documented subscription sign-ins are separate from replaying a consumer browser session.
Does Codex CLI usage eat into my ChatGPT app limits?
Not your chat limits. Local CLI sessions, cloud Codex tasks and ChatGPT Work share one allowance, but ordinary chat in the app is metered separately. Plus and standard Business plans have a five-hour window, Pro currently has no five-hour limit, and weekly limits may also apply. Run /status inside a Codex session to see remaining limits, and check the usage dashboard for reset times.
How do I stop an API key from running up a large bill?
Prepay a small balance and turn auto recharge off. Set an organization or project monthly spend limit and enable Enforce a hard limit, with spend alerts as a second layer. Neither prepaid exhaustion nor hard-limit enforcement is instantaneous. Requests processed after prepaid credits run out can create a negative balance deducted from your next purchase. Once exhaustion is enforced, requests fail with HTTP 429 and credit_balance_exhausted.