Can You Turn a ChatGPT Account Into an API Key?
Not into a key: OpenAI issues API keys only on its separate API platform. But a ChatGPT account can become an endpoint, because plans include Codex and Codex runs from code.
No tool can turn a ChatGPT account into an API key, because OpenAI issues keys only on its developer platform, a separate product with separate per-token billing. What a ChatGPT account can become is an endpoint. Every plan includes Codex, Codex signs in with your account and runs non-interactively, and wrapping it in an OpenAI-compatible server gives your software a base URL and a key-shaped credential. The key your apps end up holding is a gateway key, and the work behind it bills to your flat plan.
That distinction sounds pedantic until you walk the mechanism, so let’s walk it.
Why the key version is impossible
OpenAI runs two products that do not see each other. API keys are objects of the developer platform: you create them there, and every call they authenticate draws on that platform’s metered balance. ChatGPT plans live in the other product and issue login sessions, not keys. Nothing converts one credential into the other, and OpenAI has never issued an API key against a ChatGPT plan.
So the literal answer to the title is no, permanently and by design. The useful question is what an account can become instead, which is the territory mapped in can you use your ChatGPT subscription as an API?
The conversion that does exist
Four documented pieces chain into something key-shaped:
your ChatGPT account
-> device-code sign-in OpenAI's documented headless auth
-> Codex CLI session running in a container, signed in as you
-> codex exec the CLI's documented non-interactive mode
-> OpenAI-compatible gateway speaks /v1/chat/completions
-> pllm_... gateway key the credential your apps actually hold
Each link is official surface: device-code auth is documented at developers.openai.com/codex/auth, non-interactive mode at developers.openai.com/codex/noninteractive, and Codex is included in ChatGPT plans. The gateway at the end is the third-party part, ours or one you run yourself.
Walking one request through it
Your app sends a normal POST /v1/chat/completions, authenticated with the gateway key. The gateway validates the key, queues the job, and writes the request log. Inside your isolated container, the official Codex CLI executes the prompt under your ChatGPT session, OpenAI bills the work to your flat plan, and the finished response returns to your app in standard OpenAI shape.
One behavioral note your code can observe: the Codex lane returns complete responses, not token streams. Streamed responses come from API-key lanes only.
What lands in your env file
The end state looks almost identical to the key you wanted:
export OPENAI_BASE_URL="https://api.proxyllm.ai/v1"
export OPENAI_API_KEY="pllm_your_key_here" # gateway key, not an OpenAI key
Your SDK cannot tell the difference. Your billing can: requests on the Codex lane consume plan window instead of metered tokens. Getting from a fresh account to this env block takes about five minutes, walked step by step in the setup guide.
About lifting session tokens directly
The Codex CLI stores its session in auth.json, and the DIY route builds on exactly that: tools like ChatMock re-implement or wrap the CLI’s auth on your own machine and expose a local OpenAI-compatible server. Self-hosting this way is legitimate, with real maintenance costs, and we compare it honestly in ChatMock and DIY Codex proxies.
The rule that keeps either path safe: treat auth.json like a password. Keep it on hardware you control or inside an isolated container signed in through OpenAI’s own flow. Never paste session tokens into services you cannot audit. With ProxyLLM, sign-in happens directly between you and OpenAI via device code, so there is no password for us to see and no token for you to hand over.
What a real key still does better
Keys win where the Codex lane stops: token streaming, the API’s full model catalog and parameters, embeddings, and fine-tunes. The setups that work in production hold both: bulk programmatic volume on the plan, a key for the rest and as the fallback lane when windows exhaust. And the terms in one line, since credentials are the subject: the account must be yours alone, never shared, and OpenAI has the final call over its services.
A ChatGPT account never becomes a key, but five minutes of setup makes the difference academic. If you want to know what the swap is worth first, the calculator prices your current bill against a plan.
Frequently asked questions
Can I get an OpenAI API key from my ChatGPT subscription?
No. OpenAI issues API keys only through its developer platform, which bills per token and is a separate product from ChatGPT. No plan, Plus or Pro, includes or generates a key, and no third-party tool can mint one.
What is the closest thing to an API key for a ChatGPT account?
An OpenAI-compatible endpoint backed by Codex. Every ChatGPT plan includes Codex, the Codex CLI signs in with your account and runs non-interactively via codex exec, and wrapping that in an HTTP gateway gives your apps a base URL plus a gateway key. The key authenticates to the gateway; the work bills to your flat plan.
Can my apps authenticate to the OpenAI API with my ChatGPT login?
No. ChatGPT sessions do not work as API credentials and never have. The documented way for software to use a ChatGPT plan is the Codex CLI's sign-in, which is exactly the mechanism subscription-backed endpoints are built on.
Is copying Codex session tokens into other tools safe?
Treat the Codex CLI's auth.json like a password. Keeping it on hardware you control, as local DIY proxies do, is a legitimate self-hosting choice. Pasting session tokens into services you cannot audit is how accounts get compromised.