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 fromclaude 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:
- The
CLAUDE_CODE_OAUTH_TOKENenvironment variable. 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.- If o4 can’t run
claudeat all, for example because it isn’t installed:.credentials.jsonin the folder named byCLAUDE_CONFIG_DIR, if that variable is set, then~/.claude/.credentials.json. A file without a sign-in token is skipped.
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 readsCLAUDE_CODE_OAUTH_TOKEN directly for claude-code models, so you can skip the import. This suits CI and print mode:
/auth import claude takes precedence over the environment variable.
Models
Theclaude-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 claudeagain. - 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-coderequests 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:~/.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.
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
SetOPENAI_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).
Models
Runo4 --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 anopenai-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 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-codexrequests at $0. Cost totals 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-codemodel, sign in to Claude Code again, then run/auth import claude. - For an
openai-codexmodel, run/auth import codexto sign in with ChatGPT again.
Related
- Providers and API keys: API keys for every provider.
- Choosing a model: model references and the default model.
- Reasoning and prompt profiles: reasoning levels for Claude and Codex models.