> ## Documentation Index
> Fetch the complete documentation index at: https://docs.open4rena.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude and ChatGPT subscriptions

> Use a Claude Code or ChatGPT/Codex subscription instead of an API key.

If you pay for a Claude plan that includes Claude Code, or a ChatGPT plan that includes Codex, o4 can send requests through that subscription instead of a pay-per-token API key. o4 doesn't sign you in itself. It reuses the credentials from the official Claude Code or Codex CLI.

Each subscription has its own provider ID, separate from the API-key provider:

| Subscription | Provider ID | API-key provider |
| - | - | - |
| Claude Code (Claude plan) | `claude-code` | `anthropic` |
| ChatGPT/Codex (ChatGPT plan) | `openai-codex` | `openai` |

Because the providers are separate, you always choose which account pays: `claude-code:claude-opus-5` uses your Claude plan, and `anthropic:claude-opus-5` uses your Anthropic API key.

## Claude Code subscription

### What you need

* A Claude plan that includes Claude Code.
* The Claude Code CLI (`claude`), signed in to that account, or a token from `claude setup-token`.

### Import your Claude Code sign-in

<Steps>
  <Step title="Sign in to Claude Code">
    Sign in with the Claude Code CLI if you haven't already, for example by running `claude` and following its login prompt.
  </Step>

  <Step title="Import the token into o4">
    In o4, run `/auth import claude`. You can also open `/config providers` and choose **Import Claude Code auth**.
  </Step>

  <Step title="Pick a Claude Code model">
    Switch to a model under the `claude-code` provider:

    ```text theme={null}
    /model claude-code:claude-opus-5
    ```
  </Step>
</Steps>

`/auth import claude` tries these in order:

1. The `CLAUDE_CODE_OAUTH_TOKEN` environment variable.
2. `claude setup-token`, which o4 runs for you. It waits up to 15 seconds and imports the token the command prints, a long-lived token for the account the Claude CLI is signed in to.
3. If o4 can't run `claude` at all, for example because it isn't installed: `.credentials.json` in the folder named by `CLAUDE_CONFIG_DIR`, if that variable is set, then `~/.claude/.credentials.json`. A file without a sign-in token is skipped.

If `claude setup-token` runs but prints no token, or doesn't finish within 15 seconds, the import stops with `Could not mint a Claude Code OAuth token: …`. o4 doesn't fall back to the credentials files then, because they may belong to a different account. Run `claude login`, then `/auth import claude` again. If no source has a token, the import fails with `Could not import Claude Code credentials: …` and lists what it tried.

o4 saves the token in `~/.o4/settings.json` under the `claude-code` provider. On success, the message names the source, for example `Imported Claude Code OAuth token from CLAUDE_CODE_OAUTH_TOKEN for provider 'claude-code'.` A token read from a credentials file is Claude Code's own session token, which o4 can't refresh. The message says so; when that token stops working, run `claude login` so that the next import can use `claude setup-token`.

<Note>
  On a machine without the Claude CLI, such as a remote server, run `claude setup-token` on a machine where you're signed in, and set the token it prints as `CLAUDE_CODE_OAUTH_TOKEN`, as shown in the next section.
</Note>

### Use a token without importing it

o4 also reads `CLAUDE_CODE_OAUTH_TOKEN` directly for `claude-code` models, so you can skip the import. This suits CI and [print mode](/guides/print-mode):

```bash theme={null}
export CLAUDE_CODE_OAUTH_TOKEN="$(cat ~/.secrets/claude-token)"
o4 -m claude-code:claude-sonnet-4-6 -p "Summarize the open TODOs in this repo"
```

A token saved by `/auth import claude` takes precedence over the environment variable.

### Models

The `claude-code` provider offers the same models as `anthropic`, with `(Claude Code)` after the display name. Run `o4 --list-models` and look under `Provider: claude-code` for the list. Whether a given model works depends on what your Claude plan includes.

If you have a Claude Code token and no Anthropic API key, and you haven't saved a default model, o4 starts on `claude-code:claude-fable-5`.

### Limitations

* **The token doesn't refresh itself.** o4 saves a copy of the token at import time and doesn't track later sign-ins in Claude Code. When the token expires or is revoked, requests fail with an authentication error (HTTP 401). Sign in to Claude Code again, then run `/auth import claude` again.
* **Plan limits apply.** Requests count against your Claude plan's usage limits, not an API budget.
* **Cost figures aren't your bill.** o4 prices `claude-code` requests with Anthropic's API prices, so [cost totals](/guides/context-and-cost) show what the tokens would cost on the API, not what your plan charges.

## ChatGPT/Codex subscription

### What you need

* A ChatGPT plan that includes Codex.
* The Codex CLI (`codex`), signed in with ChatGPT. o4 reads the sign-in it saves in `~/.codex/auth.json`.

### Sign in and import

<Steps>
  <Step title="Run the import">
    In o4, run `/auth import codex`, or open `/config providers` and choose **Import Codex auth**.

    This runs `codex login` for you, which opens your browser for the ChatGPT sign-in. o4 waits up to 180 seconds for it to finish. If `codex` isn't installed, o4 says so and uses any credentials already in `~/.codex/auth.json`.
  </Step>

  <Step title="Pick a Codex model">
    Switch to a model under the `openai-codex` provider:

    ```text theme={null}
    /model openai-codex:gpt-5.6-sol
    ```
  </Step>
</Steps>

After a successful ChatGPT sign-in, o4 reports that your Codex ChatGPT credentials are in `~/.codex/auth.json`. o4 doesn't copy the ChatGPT token into its own settings. It reads the token from `~/.codex/auth.json` on every request, so when the Codex CLI refreshes your sign-in, o4 picks it up without another import.

<Info>
  If `~/.codex/auth.json` holds an OpenAI API key instead of a ChatGPT sign-in, `/auth import codex` saves that key for the `openai` provider instead. That key is billed as normal API usage, not to your ChatGPT plan.
</Info>

### Use a token without the Codex CLI

Set `OPENAI_CODEX_ACCESS_TOKEN` to a ChatGPT access token and o4 uses it for `openai-codex` models instead of reading `~/.codex/auth.json`.

If you keep the Codex CLI's files somewhere else with `CODEX_HOME`, o4 still reads the token from `~/.codex/auth.json`. Only your account ID and the `/status` usage display come from `$CODEX_HOME/auth.json`. Set `OPENAI_CODEX_ACCESS_TOKEN` in that case (see [Environment variables](/reference/environment-variables)).

### Models

Run `o4 --list-models` and look under `Provider: openai-codex`. Models under this provider have a 272k-token context window and no fixed output limit. Which models work depends on your ChatGPT plan.

Some IDs, such as `gpt-5.5`, appear under both `openai` and `openai-codex`. Use the `openai-codex:` prefix to make sure the request goes through your subscription. If o4 finds ChatGPT credentials and no OpenAI API key, it prefers `openai-codex` for bare IDs, and it starts on `openai-codex:gpt-5.6-sol` when you haven't saved a default model.

### Check your usage

While an `openai-codex` model is active, `/status` shows your ChatGPT plan and your current Codex usage limits, as reported by your account. For other providers, including `claude-code`, `/status` says that account usage is unavailable.

### Limitations

* **Quota errors don't clear on their own.** When you hit a plan limit, o4 shows the service's error message. If the message doesn't say when to try again, o4 adds a note to wait for the limit window to reset. Like any HTTP 429 error, o4 retries it a few times within seconds, which rarely helps with a plan limit. Wait for the window to reset or switch models. The [model router](/models/router) can switch to another provider for you.
* **Plan limits apply.** Requests count against your ChatGPT plan's Codex limits.
* **No cost figures.** Subscription token prices aren't published, so o4 records `openai-codex` requests at \$0. [Cost totals](/guides/context-and-cost) don't reflect subscription usage.

## If a subscription model fails

`claude-code` and `openai-codex` models always appear in **Select Model** (`/model`), because o4 can't check ahead of time whether their credentials are present and valid. A missing or expired sign-in shows up as an error on the first request instead.

* For a `claude-code` model, sign in to Claude Code again, then run `/auth import claude`.
* For an `openai-codex` model, run `/auth import codex` to sign in with ChatGPT again.

See [Troubleshooting](/help/troubleshooting) for other errors.

## Related

* [Providers and API keys](/models/providers): API keys for every provider.
* [Choosing a model](/models/overview): model references and the default model.
* [Reasoning and prompt profiles](/models/reasoning): reasoning levels for Claude and Codex models.
