Repository navigation
Description
Summary
As a ChatGPT Pro user, I expected Codex CLI to work under my Pro plan without consuming API credits. However, the “Sign in with ChatGPT” flow auto‑creates an API key for my selected API org/project. If I revoke that key to avoid API charges, the CLI fails with 401 Incorrect API key provided and then forces me to sign in again, which creates a new API key. In short, there seems to be no way to use Codex CLI without an API key being generated and billed to the API account.
Environment
- Codex CLI:
0.19.0(output ofcodex --version) - Install method:
npm i -g @openai/codex - OS: Windows 11 (running in Git Bash / MINGW64; not using WSL for this repro)
- Organization:
Personal→Default project - Config directory:
~/.codex/(anauth.jsonfile appears after login)
Steps to Reproduce
-
Ensure no
OPENAI_API_KEYis set in the environment and remove any previous Codex state:- Delete
~/.codex/(or at least~/.codex/auth.json).
- Delete
-
Run
codexand select “Sign in with ChatGPT”. -
In the browser, select my API Organization and Default project, then click Continue.
-
Observe that an API key named “Codex CLI (auto‑generated)” is created in the API dashboard, and
~/.codex/auth.jsonnow holds credentials (including ansk-proj-...key). -
Revoke that auto‑generated key in the API dashboard.
-
Run
codexagain.
Actual behavior
-
The CLI shows:
system ⚠️ OpenAI rejected the request ... Error details: Status: 401, Code: invalid_api_key, Message: 401 Incorrect API key provided: sk-proj-***********... -
The CLI asks me to log in again; completing login creates a new API key. I cannot run Codex CLI without having an active API key, which leads to API charges.
Expected behavior
- As a Pro user using “Sign in with ChatGPT”, I expected a mode that does not create or require an API key and does not consume API credits, or at least a clear toggle (“use ChatGPT plan entitlements only”).
- If I “Disconnect” Codex CLI in ChatGPT settings or revoke the key, Codex CLI should not silently recreate a billable key.
What I tried (no change)
- Deleted
~/.codex/and re‑logged in. - Ensured
OPENAI_API_KEYis unset. - Revoked the “Codex CLI (auto‑generated)” key multiple times — CLI always re‑creates a new key after login.
Logs
From the CLI run after revoking the key (redacted):
system ⚠️ OpenAI rejected the request (request ID: req_19a4b978fff39e57e93e03f92d4c027a).
Error details: Status: 401, Code: invalid_api_key, Type: invalid_request_error,
Message: 401 Incorrect API key provided: sk-proj-***eZoA.
I can also provide ~/.codex/log/codex-tui.log with RUST_LOG=codex_core=debug,codex_tui=debug if needed.
Why I believe this is a bug/UX gap
- The official “Sign in with ChatGPT” docs say the flow creates a key automatically and that Disconnect only removes the OAuth grant, not the key itself. This appears to leave no path to run Codex CLI under a Pro plan without a billable API key.
- The README also instructs users migrating from API key billing to ensure
OPENAI_API_KEYis unset and re‑login; however, re‑login still auto‑creates a key, so billing remains tied to API.
Request
- Provide a “Pro/Plus entitlement” mode that does not rely on an API key (or at least a setting to not auto‑create one).
- Alternatively, clearly document that Codex CLI currently requires an API key and will bill the API account (even for Pro users), and outline how/when this will change.
- If a non‑API billing mode is planned, please share timelines or a beta flag we can test.

Activity
M1kEk1M commentedon Aug 8, 2025
I believe that we are shipped with older version of CLI for windows.
Tried to build codex-rs for windows, got error about "Keyboard progressive enhancement not implemented for the legacy Windows API." which is from crossterm.
Managed to build with commented lines (just to check my assumption)
In
codex-rs\tui\src\tui.rsAnd it worked - managed to make some requests to GPT. But the problem is that I can't pass login stage with this built version, so only worked for me because I logged in with my npm-shipped version and then launched this built one.
osichin commentedon Aug 8, 2025
same issue as: #1953
[-]Sign in with ChatGPT still generates & requires an API key (Pro user) → API charges; revoking key breaks CLI (Windows)[/-][+][Windows] Sign in with ChatGPT still generates & requires an API key (Pro user) → API charges; revoking key breaks CLI[/+]pakrym-oai commentedon Aug 8, 2025
I apologize for the inconvenience, login with ChatGPT is not fully working on Windows, we're working hard on fixing it.
Fix rust build on windows (#2019)
jacobhallgren commentedon Aug 8, 2025
Same problem here
bolinfest commentedon Aug 9, 2025
Very hot off the presses, but
0.20.0in npm https://www.npmjs.com/package/@openai/codex has some key fixes for Windows:optimikelabs commentedon Aug 9, 2025
Same problem on a pro account
osichin commentedon Aug 9, 2025
@bolinfest - thank you! confirm it works now.
bolinfest commentedon Aug 9, 2025
@mickahouan for good measure, can you delete
%USERPROFILE%\.codex\auth.jsonand try again to make sure you're doing a clean auth flow on 0.20.0?bolinfest commentedon Aug 9, 2025
Also, maybe unset
modelinconfig.tomlor perhaps other things?optimikelabs commentedon Aug 9, 2025
Ok, everything works. Thanks a lot @bolinfest
angeloc-dl commentedon Aug 9, 2025
on Windows with 0.20.0 I get: login_with_chatgpt subprocess failed
TheComplianceAide commentedon Aug 9, 2025
I'm a pro user, on windows. Using .19. I'm getting charged for API usage when I shouldn't be.
44 remaining items
bolinfest commentedon Aug 15, 2025
If you have been running into issues related to the Python stuff, please update to 0.22.0 as we migrated the Python code to Rust in the new release: https://github.com/openai/codex/releases/tag/rust-v0.22.0
As an added bonus, 0.22.0 now supports Markdown and streaming!
4erdenko commentedon Aug 15, 2025
Looks really great! Thank you.
And again, initial problem was solved too, earlier.
Fix rust build on windows (openai#2019)
docs: update the docs to explain how to authenticate on a headless ma…
Fix rust build on windows (openai#2019)
docs: update the docs to explain how to authenticate on a headless ma…
docs: update the docs to explain how to authenticate on a headless ma…
Fix rust build on windows (openai#2019)
docs: update the docs to explain how to authenticate on a headless ma…