ANTHROPIC_MODEL
Updated by Alex Sorokoletov
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.
| Status | Present in v2.1.332 |
|---|---|
| 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 |
| Category | Models and thinking |
| Official docs | Listed |
| Checked against | v2.1.330 |
How to set it
For one session, export it in the shell that starts Claude Code:
export ANTHROPIC_MODEL=sonnet
claudeSonnet 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
- Claude Code Version Tracker: Undocumented Env Vars, Feature Gates & Models
- claude-code-env-vars-v2-1-237
Related variables
ANTHROPIC_CUSTOM_MODEL_OPTIONANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTIONANTHROPIC_CUSTOM_MODEL_OPTION_NAMEANTHROPIC_CUSTOM_MODEL_OPTION_SUPPORTED_CAPABILITIESANTHROPIC_DEFAULT_FABLE_MODELANTHROPIC_DEFAULT_FABLE_MODEL_DESCRIPTIONANTHROPIC_DEFAULT_FABLE_MODEL_NAMEANTHROPIC_DEFAULT_FABLE_MODEL_SUPPORTED_CAPABILITIES
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.