Claude visitors: new accounts receive $1.00 in bonus API credit within 30 days. One per person; usage credits only.
OpenAI Codex Pricing: What the CLI Actually Costs in 2026
OpenAI Codex CLI is a free, open-source tool, but it sends every prompt to a model API that charges per token. Pointing Codex at RunAPI gives it GPT models through one key with pay-per-token billing and no other changes to your workflow. The table below lists current rates.
How much does OpenAI Codex cost?
The Codex CLI itself is free to download and run. The cost comes from API calls: every prompt, file read, and code generation goes to a model API that bills per token. RunAPI is OpenAI-compatible, so you change two environment variables and nothing else; the pricing table lists per-million-token rates for the GPT models Codex can use. Tip: run /compact during long sessions to free up context and stop burning tokens on conversation history.
The CLI itself has no subscription fee. You pay only for the API tokens consumed during each coding session.
Calling the OpenAI API directly bills each GPT model at OpenAI's published per-token rate.
RunAPI serves the same GPT models through an OpenAI-compatible endpoint. Set two env vars and Codex routes through RunAPI automatically.
Pay only for what you use. No monthly seat fee. No minimum spend. Bills stop the moment you stop coding.
What gets counted as a token?
Every message Codex sends to the API includes your prompt, the full context of files it has read, any tool results, and conversation history. That combined input is billed as input tokens. The model's response — edited code, explanations, next steps — counts as output tokens. Both directions are billed separately. Codex caches nothing between sessions, so a fresh session re-reads the same files and bills that context again.
- Input tokens
- Your prompt + file context + tool results + conversation history
- Output tokens
- Generated code, edits, and explanations from the model
- Session boundary
- Each new Codex session starts with zero cached context — full re-billing on file reads
How much does each GPT model cost per million tokens?
Codex CLI can run any GPT model on RunAPI. The table lists OpenAI's official rate next to the RunAPI rate for each one, from the current price list.
| Model | Official input /M | Official output /M | RunAPI input /M | RunAPI output /M |
|---|---|---|---|---|
| gpt-5.5 Higher rate on long prompts | $5.00 | $30.00 | $4.00 20% OFF | $24.00 |
| gpt-5.4 Higher rate on long prompts | $2.50 | $15.00 | $2.00 20% OFF | $12.00 |
| gpt-5.4-mini | $0.75 | $4.50 | $0.60 20% OFF | $3.60 |
How to use Codex CLI with RunAPI
Install Codex CLI
Install via npm globally. Node 22 or later is required.
npm install -g @openai/codex
Create a RunAPI account
Sign up at runapi.ai, go to Dashboard > API Keys, and generate a new key. Your key starts with `runapi_`.
Set your environment variables
Codex reads OPENAI_API_KEY and OPENAI_BASE_URL from your environment. Point both at RunAPI. Add these lines to your shell profile (~/.zshrc or ~/.bashrc) for persistence.
export OPENAI_API_KEY="runapi_your_key_here"
export OPENAI_BASE_URL="https://runapi.ai/v1"
Run Codex
Launch Codex from your project directory. It connects to RunAPI instead of OpenAI with no other changes.
codex
Verify the model
You can switch to any RunAPI-supported model using the /model command inside the Codex session, or pass --model on the command line.
codex --model gpt-5.4
Common questions about Codex pricing
Is OpenAI Codex CLI free to use?
The CLI itself is free to download and install. There is no subscription fee. However, every prompt Codex sends reaches a model API (OpenAI or RunAPI), which charges per token. The tool is free; the API calls are not. Your monthly cost depends on how many tokens your sessions use and the rates in the pricing table.
"Quota exceeded" — I'm already on a paid plan. Why?
Codex CLI works two ways: through a ChatGPT subscription (Plus or Pro) or through your own API key with pay-per-token billing. The subscription path gives you a usage quota — once it is exhausted, you see "quota exceeded" errors even on a paid plan. The API key path means you pay only for what you use, with no monthly floor.
Which model effort level should I use to keep costs down?
Codex CLI includes three reasoning effort levels selectable with the /model command: medium, high, and extra high. Medium is the cheapest and recommended for daily use — it saves a lot of tokens and handles most tasks well. High and extra-high effort produce better results on complex tasks but burn more tokens quickly.
How does RunAPI work with Codex CLI?
RunAPI is an OpenAI-compatible API. Codex reads the OPENAI_BASE_URL and OPENAI_API_KEY environment variables to find its API endpoint. Setting these to RunAPI values routes all Codex traffic through RunAPI instead of OpenAI. The request and response format is identical, so Codex behaves the same; billing follows the RunAPI rates in the pricing table.
Do I need an OpenAI account to use Codex with RunAPI?
No. When you route Codex through RunAPI, your requests go to RunAPI's infrastructure, not OpenAI directly. You create a RunAPI account, generate an API key there, and set that key in your environment. No OpenAI account, no OpenAI API key, and no OpenAI billing are required.
Which models can I use with Codex CLI through RunAPI?
RunAPI serves GPT models such as GPT-5.5, GPT-5.4, and GPT-5.4-mini, plus other LLMs including Claude Sonnet and Gemini Pro. You switch models with the --model flag or /model command in Codex. Each model is billed at its own rate, listed on the RunAPI pricing page.
Does redirecting Codex to RunAPI change how it behaves?
No. The only difference is which server processes the API request. Codex's file reading, code execution sandbox, approval modes, and MCP tool integrations all continue to work as normal. The request and response format RunAPI uses is identical to OpenAI's API, so Codex cannot tell the difference.
How do I stop burning so many tokens in a long Codex session?
Use the /compact command during long sessions — it summarizes the conversation to free up context and cuts the tokens you're burning on history. Also run /status to see your current token usage. For day-to-day work, stick to medium reasoning effort. For one-off tasks, use non-interactive mode (codex -q "your task") instead of an open session to avoid accumulating context.
Explore More
The full GPT lineup with official and RunAPI rates.
What Claude Code costs with API billing vs Max subscription.
Feature and cost comparison of the two leading AI coding tools.
Run any model from your terminal with a single command.
Run Codex through RunAPI
Set two environment variables and every Codex session runs through RunAPI. No subscription, no minimum spend — you pay only for tokens used.