Skip to main content
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: 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

1

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

Import the token into o4

In o4, run /auth import claude. You can also open /config providers and choose Import Claude Code auth.
3

Pick a Claude Code model

Switch to a model under the claude-code provider:
/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.
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.

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:
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. When one of them is used up, o4 says which one and when it resets, in your local time, for example claude-code: the weekly limit is used up until it resets at 17:00 on 11 Nov. It names the 5-hour, weekly, Opus and Sonnet limits and a model’s own weekly limit, and adds Usage credits are turned off for your organization. when that is why the request couldn’t continue. o4 doesn’t send the request again, because it can’t succeed before the reset. It moves to another saved account or a router fallback model if you have one; otherwise the hint says use /model to switch to another model, or wait for the reset.
  • Cost figures aren’t your bill. o4 prices claude-code requests with Anthropic’s API prices, so cost totals 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

1

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

Pick a Codex model

Switch to a model under the openai-codex provider:
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. To keep more than one ChatGPT account, see Use several accounts.
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.

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 reads your sign-in from $CODEX_HOME/auth.json instead of ~/.codex/auth.json (see Environment variables).

Models

Run o4 --list-models and look under Provider: openai-codex, or see Supported models. Most models under this provider have a 272k-token context window, and none has a 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. If you have saved several accounts, o4 moves to the next one first. Otherwise, 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 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 don’t reflect subscription usage.

Use several accounts

If you have more than one Claude or ChatGPT subscription, save each one as a named account. When one account reaches its usage limit, o4 moves to the next, so you don’t have to sign in again. Automatic account rotation and background Codex renewal run only in interactive sessions, including sessions that run in the o4 daemon. Print mode uses the saved active account without automatically rotating through other accounts.

Save each account

Give each sign-in a name when you import it. Use 1–64 ASCII letters, digits, -, _, ., @ or +, without a leading ., for example work or me@example.com.
1

Save Claude accounts

The Claude Code CLI is signed in to one account at a time, so save your accounts one after the other. For each account, sign in to Claude Code as that account (claude login), then run /auth import claude <name> in o4.
2

Save ChatGPT accounts

Run /auth import codex <name> once per account. Each time, your browser opens for the ChatGPT sign-in; sign in with the account you want to save under that name.
When importing different Claude CLI logins, start o4 without CLAUDE_CODE_OAUTH_TOKEN; otherwise every import reads that environment token instead of the CLI login. To use saved ChatGPT accounts, start o4 without OPENAI_CODEX_ACCESS_TOKEN, because it overrides the selected account’s credentials.
/auth import claude or /auth import codex without a name saves the account as default. The first account you save for a provider becomes the one in use. Saving another doesn’t change that, and the message tells you how to switch. For ChatGPT, default is your normal Codex sign-in in ~/.codex (or $CODEX_HOME). Every other ChatGPT account gets its own folder, ~/.o4/accounts/codex/<name>/. o4 doesn’t copy ChatGPT tokens into its settings.
If you imported default in o4 0.3.21 or 0.3.25, its sign-in was stored in ~/.o4/accounts/codex/default/. From 0.3.26, o4 uses your normal Codex home instead; it doesn’t move that older sign-in. If you aren’t already signed in there, run /auth import codex once.

Switch accounts

Your choice is saved, so o4 starts on the same account next time. In one o4 window, each provider has one active account shared by all its tabs, rather than a separate account for each conversation. A session that runs in the o4 daemon uses the account its window has active, and when that account reaches its limit, only that session moves to the next one. Removing a saved Codex account does not delete its auth.json or revoke its ChatGPT sign-in.

When an account reaches its limit

In interactive sessions, when the account in use gets a retryable rate-limit or usage-limit error before any reply or tool call arrives, o4 switches to the next eligible saved account for the same subscription and sends the request again right away, with the same model and conversation. It does this even with the model router off. If a reply has already started, the turn ends with the error rather than repeating the request. The chat shows a notice such as claude-code: account 'work' hit its usage limit, switched to account 'personal'. o4 goes through your accounts in the order you saved them. It skips an account that reached its limit in the last 10 minutes and an account that isn’t allowed to use the model in use, and starts again from the first account when it gets to the end. This ten-minute waiting period is remembered only while that o4 is running. When it ends, the account becomes eligible for a later retry; o4 does not send a request just because ten minutes have passed. When no saved account is eligible, o4 handles the error as it would with one account: the model router switches to another provider, or o4 retries, except for a Claude limit that is used up until a known time, which it reports at once.

Keeping ChatGPT accounts signed in

ChatGPT access tokens expire and need renewal. In interactive sessions, o4 checks every saved ChatGPT account at startup and then every hour. If a token expires within a day or has already expired, o4 asks the installed Codex CLI to renew it and save the updated credentials. Keep codex installed for this to work. The default account shares the Codex CLI’s normal sign-in; named accounts keep their own sign-ins in separate folders. Closing o4 stops these background checks. An expired access token does not necessarily mean you need to sign in again: the Codex CLI can renew it if the account’s refresh credentials are still valid. If renewal fails and requests report an authentication error, run /auth import codex <name> with the same name, or switch to another saved account. These background checks do not run in print mode. Claude accounts imported through claude setup-token use long-lived tokens instead of this Codex renewal process. Tokens imported from a credentials file can expire sooner and o4 cannot refresh them. If a Claude token expires or is revoked, import that account again.

Where accounts are stored

Saved accounts are in the accounts section of ~/.o4/settings.json. A project’s own settings file can’t add, change or switch them. Claude tokens are stored in that section; ChatGPT accounts store only their name there, and their sign-in stays in the account’s folder.

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 valid. If o4 finds no sign-in when you switch to one, the notice says Switched to <name> (<id>), but claude-code has no API key (or openai-codex) and names the commands to sign in. An expired sign-in shows up only as an error on the first request.
  • For a claude-code model, sign in to Claude Code again, then run /auth import claude. Add the account’s name if it is a saved account.
  • For an openai-codex model, run /auth import codex to sign in with ChatGPT again. Add the account’s name if it is a saved account, or switch to another one with /auth use codex <name>.
See Troubleshooting for other errors.