# 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.

*Published 2026-06-12 · https://proxyllm.ai/blog/turn-chatgpt-account-into-api-key*

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?](/blog/can-you-use-your-chatgpt-subscription-as-an-api)

## The conversion that does exist

Four documented pieces chain into something key-shaped:

```text
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:

```bash
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](/blog/codex-hosted-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](/blog/chatmock-vs-hosted-codex).

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 on your own machine, directly between you and OpenAI, so there is no password for us to see; you hand over one session file, knowingly and once, and it is stored encrypted, isolated to your container, and revocable from your OpenAI account at any time.

## 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](/calculator) prices your current bill against a plan.
