Codex pricing: ChatGPT plan or pay-as-you-go API key?

Key takeaways
- You pay for Codex in one of two ways: out of a ChatGPT plan's allowance, or per token with an API key.
- A plan's allowance runs in five-hour and weekly windows, and credits cover what goes over.
- An agent resends its context on every call, so on token billing the input decides the bill.
- Codex CLI runs on FastMetal once its config file points there (tested in October 2026). It is prepaid, so spend stays inside the balance you topped up.
Codex comes as part of ChatGPT's plans, which is why a search for Codex pricing lands on the ChatGPT price list. This post compares the two ways to pay, based on OpenAI's pages as of October 2026, and ends with the configuration to run Codex CLI on a FastMetal key. Prices change often, so they are linked, not quoted.
Two ways to pay: a plan allowance or per-token API billing
Sign in with a ChatGPT account and Codex uses your plan's allowance. Sign in with an API key and usage is billed to your OpenAI Platform account at standard API rates.
| ChatGPT plan | API key | |
|---|---|---|
| Billing unit | Monthly fee; credits for overage | Per million tokens |
| Where it runs | App, web, CLI, IDE extension, depending on plan | CLI, SDK, IDE extension |
| Limits | Five-hour and weekly windows | Billed for the tokens you use |
| Cloud features | Plus and above | Not included |
| Good for | Day-to-day individual development | Automation such as CI |
Plan prices are on Codex pricing and API rates on OpenAI API pricing.
On a ChatGPT plan: five-hour windows and credits
What each plan includes
Codex is part of every ChatGPT plan, Free through Enterprise. Free and Go get the desktop app and the light GPT-6 Luna model (rolling out). Plus adds the web, the CLI, the IDE extension and cloud integration, and Pro comes in three tiers with different amounts of usage.
The allowance resets every five hours
On Plus and Business the allowance resets every five hours, and a weekly limit can apply on top. Pro currently has no five-hour limit. Usage depends on the model, the context length, reasoning, tool runs and how well caching works, and OpenAI says prompt length alone is not a reliable estimate.
When you reach the limit, the turn in progress still finishes. After that you can wait for the reset, buy credits (Plus and Pro), or carry on with an API key. Credits are consumed at a rate per million tokens for input, cached input and output. For what the limit message means and where to see the reset time, see Codex usage limit reached.
With an API key: per-token billing
An API key is billed per million tokens of input, cached input and output, at a rate set for each model. OpenAI recommends this route for automation in shared environments such as CI. There is no plan allowance to watch, but the longer the agent runs the higher the bill, so the real job is keeping a ceiling on spend.
Agent billing comes down to input tokens
A coding agent calls the model dozens of times on one task, and each call resends the instructions, the files, the conversation and the tool results. Send a 30,000-token context 40 times and that is 1.2 million input tokens. Output is mostly code diffs and comes to far less.
Three ways to cut the cost
- Pick models with prompt caching. Context that does not change is billed at the cheaper cached rate.
- Break work into small tasks, so there is less context to resend.
- Match the model to the work: routine fixes on a light model, design and hard debugging on a top-tier one.
Plan or API: which to choose
| How you work | Best fit |
|---|---|
| Hours of coding with OpenAI models every day | Pro or Plus |
| A few focused sessions a week | Plus |
| Automated runs in CI or overnight batches | API key, pay as you go |
| Usage that swings a lot from month to month | Pay as you go |
| Models beyond OpenAI's | Pay as you go through an AI gateway |
The more you use a flat plan, the better value it gets. Pay-as-you-go costs $0 in a month you do not use it, and your choice of model shows up directly on the bill.
Run Codex CLI on a FastMetal key
FastMetal is an AI gateway: models from many labs behind one API key. To point Codex CLI at it, add a provider to its config file.
The config.toml
Put the key in an environment variable:
export FASTMETAL_API_KEY="your-fastmetal-key"
Then define the provider in ~/.codex/config.toml:
model = "gpt-5.6-terra"
model_provider = "fastmetal"
web_search = "disabled"
[model_providers.fastmetal]
name = "FastMetal"
base_url = "https://api.fastmetal.ai/v1"
env_key = "FASTMETAL_API_KEY"
wire_api = "responses"
In October 2026 we ran a real Codex task to completion with this exact configuration, on Codex CLI v0.160.1 and gpt-5.6-terra.
wire_api = "responses"makes Codex talk to the Responses API. Do not leave it out.web_search = "disabled"turns off Codex's built-in web search. FastMetal does not offer provider-side web search, and without this line requests to non-OpenAI models are rejected.env_keytakes the name of the environment variable that holds the key, never the key.- Give the provider your own ID.
openai,ollamaandlmstudioare reserved.
Requests go to FastMetal and are paid from your FastMetal balance, separately from your ChatGPT plan's allowance. Run a small task first to check the setup.
Models beyond OpenAI's
The model line takes any FastMetal model ID. The example uses gpt-5.6-terra, and other labs' IDs go on the same line. In a one-call probe each, deepseek-v4.1-flash, kimi-k3, anthropic-claude-sonnet-5 and glm-5.3 returned tool calls through /v1/responses (October 2026). We have not run a full Codex task on them, so try a small one before you rely on any of them. This lists every ID:
curl https://api.fastmetal.ai/v1/models -H "Authorization: Bearer $FASTMETAL_API_KEY"
Rates for OpenAI's models are on the OpenAI models page, and each model page also shows its data policy: whether prompts are used for training and whether they are kept.
How FastMetal bills
- Prepaid, with each model's rate on the pricing page.
- Top up by card with a $5 minimum.
- Spend never goes past the balance you topped up. When it is used up, requests are refused.
- Each key can have its own daily or weekly spending cap, so teams and projects keep separate budgets.
Claude Code and Cline pricing
The same reasoning applies to the other coding agents. See Claude Code pricing, Use Claude Code with an API key and Cline pricing. One FastMetal key works in all of them.
FAQ
Is Codex free?
Codex is included in ChatGPT's Free plan, where you can try the light GPT-6 Luna model in the desktop app (as of October 2026, rolling out). OpenAI lists the CLI and the IDE extension for Plus and above.
Does Codex CLI itself cost anything?
Codex CLI is open source, published by OpenAI, and the tool is free. What you pay for is model usage.
What happens when I hit the five-hour limit?
The turn in progress finishes. Then you wait for the reset, buy credits (Plus and Pro), or switch to an API key.
Does signing in with an API key use my plan's allowance?
No. API key usage is billed at standard API rates to your OpenAI Platform account, separately from your ChatGPT plan's allowance.
What do I pay for when I run Codex on a FastMetal key?
The input and output tokens of the model you use, billed per million tokens from your prepaid balance.
Get started
Create an account, add a $5 top-up, then drop the config above into ~/.codex/config.toml.
Create an account | See pricing