# ChatGPT plan (/docs/providers/chatgpt)

The ChatGPT account answers with the visitor's ChatGPT subscription, through the Codex backend of the plan. The wallet lists it as ChatGPT under "With your plan", with the id `chatgpt`. An OpenAI API key is a separate account, described on the [OpenAI API key](/docs/providers/openai-key) page.

## What the visitor needs [#what-the-visitor-needs]

A ChatGPT plan. The answers come from the plan's Codex backend and count against the plan.

## Sign in [#sign-in]

1. In the wallet, the visitor picks ChatGPT under "With your plan".
2. The wallet asks OpenAI for a device code and shows the code in the side panel.
3. It opens a window on `https://auth.openai.com/codex/device`.
4. The visitor signs in to ChatGPT there and approves the code.
5. The wallet asks OpenAI for the approval each time a page finishes loading in the window, when the window closes, and when the visitor presses "I approved it". OpenAI answers 403 or 404 until the visitor approves.
6. Once approved, the wallet trades the authorization code for tokens, reads the workspace of the token (`chatgpt_account_id`), and the account is connected.

The code lasts fifteen minutes. The wallet renews the access token with the refresh token from one minute before it expires.

## Models [#models]

The wallet lists the models Codex shows, from `https://chatgpt.com/backend-api/codex/models` for the Codex release `0.166.0`: the models OpenAI marks for the list, in OpenAI's order of priority. It keeps the list for a day. The visitor picks the account's default model in its settings, and a model per site with the buttons of the side panel. Without a choice, the account answers with `gpt-6-luna`.

## Usage and limits [#usage-and-limits]

The wallet reads `x-codex-primary-used-percent` and `x-codex-secondary-used-percent` on each answer, the percent used of the plan's two windows. The room left is one minus the higher of the two, as a share.

When ChatGPT returns `x-codex-rate-limit-reached-type`, the account reads as spent. Auto then tries it last.

## Calls [#calls]

Answers come from `https://chatgpt.com/backend-api/codex/responses` in OpenAI's Responses protocol. Each call carries the token and the workspace in a `ChatGPT-Account-ID` header, and asks the backend to store nothing (`store: false`).

The Codex backend refuses the sampling settings and the output limit, so the wallet leaves `maxTokens`, `temperature` and `topP` out of its calls. The Responses protocol has no stop sequences, and the wallet leaves `stop` out as well.

## Known issues [#known-issues]

- The sign in borrows the OAuth client of Codex, OpenAI's command line tool.
- The calls present themselves as Codex, with `originator: codex_cli_rs` and `User-Agent: codex_cli_rs/0.0.0`.
