ANTHROPIC_MODEL

Updated by

ANTHROPIC_MODEL sets the model a session starts on, as an alias such as opus or a full model ID; --model and /model override it. Default: unset, so the model setting, then the account default, applies. Values: an alias (opus, sonnet, haiku, fable, opusplan, opus[1m]) or a full model ID for your provider; an empty value is ignored. Its release history is not tracked here. It is listed in the official reference.

StatusPresent in v2.1.332
Defaultunset, so the model setting, then the account default, applies
Valuesan alias (opus, sonnet, haiku, fable, opusplan, opus[1m]) or a full model ID for your provider; an empty value is ignored
CategoryModels and thinking
Official docsListed
Checked againstv2.1.330

How to set it

For one session, export it in the shell that starts Claude Code:

export ANTHROPIC_MODEL=sonnet
claude

Sonnet starts every session launched from that shell on Sonnet, whatever /model saved.

To apply it to every session, add it to the env object of a settings file:

// ~/.claude/settings.json
{
  "env": {
    "ANTHROPIC_MODEL": "sonnet"
  }
}

Known issues

  • /model still saves a default, but while ANTHROPIC_MODEL is set every new launch returns to the variable's model; /model shows 'ANTHROPIC_MODEL is set to ... new sessions use that while it is set'. Source: docs: model config.
  • A mistyped value is not rejected at startup; the first request fails with 'There's an issue with the selected model'. A model your organization restricts is replaced at startup with a notice. Source: docs: model config.
  • The VS Code extension with Bedrock can ignore a value set in claudeCode.environmentVariables; setting it in the env block of ~/.claude/settings.json worked for one reporter. Source: issue #19011.

Release notes that mention it

Related variables

Frequently asked questions

What does ANTHROPIC_MODEL do?

Sets the model a session starts on, as an alias such as opus or a full model ID; --model and /model override it.

What is the default value of ANTHROPIC_MODEL?

Unset, so the model setting, then the account default, applies.

What values does ANTHROPIC_MODEL accept?

An alias (opus, sonnet, haiku, fable, opusplan, opus[1m]) or a full model ID for your provider; an empty value is ignored.

Which Claude Code version has ANTHROPIC_MODEL?

Its release history is not tracked here.

How do I set ANTHROPIC_MODEL?

Export it before starting Claude Code (export ANTHROPIC_MODEL=sonnet), or add it to the "env" object in ~/.claude/settings.json to apply it to every session. Sonnet starts every session launched from that shell on Sonnet, whatever /model saved.

All variables, searchable: Claude Code environment variables.