Contenox

Codex API key vs ChatGPT subscription — which account pays?

Updated

Codex: API key vs plan

Sign in to Codex with ChatGPT to use the coding allowance included in your subscription. Sign in with an OpenAI API key and your API organization pays for usage at API rates. Both sign-ins work locally in the desktop app, IDE extension and CLI. Cloud tasks require ChatGPT sign-in and a workspace with cloud access. OpenAI’s sign-in guide

Can I use my ChatGPT API credits in Codex?#

No. Eligible ChatGPT Pro and Business subscribers can claim promotional credits for one linked API organization. Those credits cover eligible API calls, such as an app calling the Responses API. OpenAI excludes Codex sessions signed in with an API key. Claiming the credits also leaves your signed-in Codex allowance unchanged. OpenAI’s credit terms

If a Codex request succeeds and you see a cost in API usage, that entry tells you how much usage the key generated. To check a promotional grant, an organization owner can select the linked organization in the API Platform and open Billing → Credit grants. To see when your signed-in Codex allowance resets, open the ChatGPT usage dashboard. OpenAI’s billing walkthrough · Codex usage dashboard

What changes between the two?#

ChatGPT sign-in API key
Who pays Your ChatGPT plan covers included usage. Eligible plans can buy additional ChatGPT credits. The API organization that issued the key, at API rates.
Which limits apply The usage limits for your plan or workspace. Your API organization’s billing and rate limits.
Where it works Desktop app, IDE and CLI locally. Cloud tasks and integrations depend on your plan and workspace permissions. Local desktop app, IDE extension, CLI, SDK and codex exec.
Models The plan’s model lineup The models your API key can access
Data handling Your ChatGPT workspace’s settings, retention and permissions Your API organization’s retention and data-sharing settings
Best for Daily work by one person CI, scripts, teams on one bill, days the plan runs out

How do I start in the desktop app or my editor?#

Where you are Use your ChatGPT plan Use your API account
ChatGPT desktop app, signed out Choose Continue to sign in and finish in the browser. Open a project folder, choose Codex and start a chat. Choose Sign in another way, enter your Platform key and select Continue.
Codex extension in your IDE, signed out Choose Sign in with ChatGPT and return to the editor after signing in. Choose Use API Key and enter your Platform key.

The same local project can be used with either billing method. Before starting a large task, open the profile menu and check which account or key is active. OpenAI authentication · Desktop quickstart

How do I sign in with my ChatGPT plan?#

codex login

Finish the sign-in in the browser. On a machine without a browser, or over SSH:

codex login --device-auth

Device code sign-in has to be turned on in your ChatGPT security settings first, or by an admin on a Business, Edu or Enterprise workspace. Until then, there’s no field for the code. Details are on the ChatGPT subscription page, with install steps for Windows, macOS and Linux.

How do I log in to Codex with an API key?#

Create a key in the OpenAI Platform dashboard under API keys. If your shell already has the key in OPENAI_API_KEY, pass it to Codex on standard input. On macOS, Linux or WSL:

printenv OPENAI_API_KEY | codex login --with-api-key

Windows PowerShell:

$env:OPENAI_API_KEY | codex login --with-api-key

Codex stores the key with its other credentials, in ~/.codex/auth.json or your system’s credential store, depending on cli_auth_credentials_store in config.toml. The CLI and the IDE extension share that login. Treat the file like a password.

For a single non-interactive run, such as a CI job, set CODEX_API_KEY instead. It works for codex exec, review, the TypeScript SDK and the remote exec-server, not for the interactive CLI. Codex’s docs say to set it inline for the one command, not for the whole job, when the job runs code from the repository.

CODEX_API_KEY="$OPENAI_KEY_SECRET" codex exec "run the tests and fix what fails"

OpenAI’s docs also warn against running Codex with API key auth in untrusted or public environments.

How do I switch between them?#

In the CLI, check your login and then sign in with the billing method you want:

codex login status
codex logout
printenv OPENAI_API_KEY | codex login --with-api-key

To go back to the plan, codex logout and then codex login.

codex login status shows which method is active. Check it before a long task, so you know which bill the task goes to.

The managed-machine gotcha: if an admin set forced_login_method = "chatgpt" or "api" in a managed config, Codex logs you out and exits whenever your credentials don’t match. If Codex keeps signing you out after a switch, that setting is the reason.

How do I check my Codex usage?#

  • On a ChatGPT plan: the usage dashboard shows your current limits and reset times. In the CLI, /usage shows your ChatGPT token activity, with /usage daily, /usage weekly or /usage cumulative to go straight to a view. It’s also where you redeem an earned rate-limit reset, if you have one. /statusline can put the rate limits in the footer.
  • With an API key, select the key’s project and the dates of your session in Analytics → Usage on the API Platform. Organization owners and users with dashboard permission can see usage and costs there. OpenAI’s usage dashboard guide
  • Either way: /status shows the active model and the current session’s token usage.

What happens when the subscription runs out?#

OpenAI lets a turn that’s already running finish, within fair use. After that, you have three options:

  1. Wait for the window to reset. Plus and Business have a short recurring window; weekly limits can apply on top.
  2. Buy credits, on Plus and Pro, or as workspace credits on Business, Edu and Enterprise with flexible pricing.
  3. Log in with an API key and keep working, billed per token.

Fast and Ultrafast modes use your allowance faster than Standard, so turn them off when you’re close to the limit.

Which is cheaper for me?#

If you already pay for ChatGPT and the work fits within your included allowance, a Codex task adds nothing to that subscription bill. If you sign in with a key, estimate the API cost using the model’s rates for uncached input, cached input and output. OpenAI API pricing

cost of a task = (uncached input × input price
                + cached input   × cached input price
                + output         × output price) / 1,000,000

How big the token counts get, from one solo developer’s use in 2026:

  • One month on the DeepSeek API, in Contenox’s own use: 23,815 requests and 7.86 billion tokens, about 330,000 tokens per request.
  • One agentic coding session of eight prompts: about 300 million input tokens.

Agents can send the same context on successive steps. Check how much input was actually cached before using the discounted rate. How prompt caching works

To compare on your own work:

  1. Sign in with a key from a dedicated API project so you can distinguish the trial from other traffic. Run three tasks you do often.
  2. Read session tokens from /status and check the project’s cost in the Platform usage dashboard.
  3. Multiply by how often you do that kind of task in a month.
  4. Compare the total with your ChatGPT plan on the Codex pricing page.

If you would buy a plan just for Codex, compare your estimated monthly API spend with the subscription price plus any extra ChatGPT credits you would need. If you already keep the plan for other work, compare only what you would spend beyond it. AI coding costs

Contenox#

Contenox keeps both side by side: the ChatGPT subscription, signed in with a one-time code, and an OpenAI API key as a separate provider. You pick one per session in the Model chip, so when the plan’s window closes, you switch the session to the key without logging out of anything.