Key takeaways

  • Type /model in a session, or launch with claude --model <alias>, to switch models.
  • A model set with --model, ANTHROPIC_MODEL or the model setting follows a fixed priority, and project or managed settings can override your choice.
  • Aliases include opus, sonnet, haiku, fable, best and opusplan, and the 1M-context variants sonnet[1m] and opus[1m].

Claude Code how to change model: type /model during a session and pick one, or start Claude Code with claude --model <name>. Both are documented in the Claude Code model configuration docs, which also cover the environment variable and settings file routes. Which one wins depends on where you set it, and that is where most people get stuck.

This guide is for anyone who uses Claude Code in a terminal and wants to switch between models like Opus, Sonnet and Haiku, or make a choice stick. The details below were read from the official docs on October 29, 2026. Model names and defaults change, so check the docs if something here looks off. If you haven't set Claude Code up yet, start with how to install it.

The five ways to set the model

The docs list them from highest priority to lowest:

Priority Method How long it lasts
1 /model <alias or name> in a session Switches now. Also saved as your default, unless you choose otherwise
2 claude --model <alias or name> That session only
3 ANTHROPIC_MODEL=<alias or name> Sessions launched with the variable set
4 The model field in a settings file Every session that reads the file
5 ANTHROPIC_DEFAULT_MODEL=<alias or name> Default for new sessions, only if nothing above picks a model

ANTHROPIC_DEFAULT_MODEL needs Claude Code v2.1.236 or later.

How to change the model during a session

Run /model with no argument to open the picker, or give it a name:

/model sonnet

In the picker, Enter switches and saves the choice as your default for new sessions, by writing the model field in your user settings. Press s instead to switch for this session only.

You can also switch without clearing what you've typed. The interactive mode docs list Option+P on macOS and Alt+P on Windows and Linux for this. On macOS, your terminal must treat Option as Meta for that shortcut to work.

One cost to know about: each model has its own prompt cache, so the first request after a switch re-reads the whole conversation without the cache, according to the settings docs.

How to start Claude Code on a specific model

Use the --model flag. It takes an alias or a full model name, and it overrides both the model setting and ANTHROPIC_MODEL:

claude --model opus

To pin an exact version, use the full name, such as claude --model claude-sonnet-5. The flag applies only to the session you start with it.

How to set a default model

For a default that survives restarts, use one of these.

Settings file. Add a model field to a settings file:

{
  "model": "opus"
}

The file you pick sets who it applies to:

File Applies to
~/.claude/settings.json You, in every project
.claude/settings.json Everyone in the project, if committed
.claude/settings.local.json You, in this one project

The docs give an example of the local file at work. If your team's shared file sets one model and you want another, put yours in .claude/settings.local.json and only your sessions change.

Environment variable. Export it before launching:

export ANTHROPIC_MODEL=opus
claude

ANTHROPIC_MODEL beats the model key in any settings file. ANTHROPIC_DEFAULT_MODEL does the opposite: it applies only when no file sets model.

One session without saving. Pass settings inline:

claude --settings '{"model": "claude-opus-5-5"}'

Model aliases you can use

As of October 29, 2026, the docs list these aliases:

Alias What it gives you
default Clears your override and returns to the default for your account
best The model fable resolves to where available, otherwise the same as opus
fable Fable, for the hardest and longest-running tasks
sonnet The latest Sonnet, for daily coding
opus The latest Opus, for complex reasoning
haiku Haiku, fast and light, for simple tasks
sonnet[1m], opus[1m] Those models with a 1M token context window
opusplan Opus in plan mode, then Sonnet when it executes

On the Anthropic API, opus maps to Opus 5.5, sonnet to Sonnet 5.5 and haiku to Haiku 5.5. On Amazon Bedrock and Google Cloud's Agent Platform, sonnet maps to Sonnet 4.5 and haiku to Haiku 4.5. On Microsoft Foundry, opus maps to Opus 4.6. To change what an alias points to, set ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL or ANTHROPIC_DEFAULT_HAIKU_MODEL.

The docs say Fable is not the default on any plan. Pick it with /model fable or claude --model fable. Its usage may bill to usage credits, and interactive sessions show a consent prompt first.

Change the effort level too

Effort is separate from the model. Set it with /effort, claude --effort <level> or the CLAUDE_CODE_EFFORT_LEVEL variable. Levels run from low to max, depending on the model. According to the docs, the default is high on most models and medium on Opus 5.5, Sonnet 5.5 and Haiku 5.5. Run /effort auto to clear a level you saved.

Why your model keeps changing back

If a new session starts on a model you didn't pick, check these, all from the docs:

  • A project or managed setting is overriding your /model choice. Project and managed settings reapply on each launch.
  • ANTHROPIC_MODEL is exported in your shell and beats the settings file.
  • Your organization restricts models with availableModels. A blocked choice is rejected in /model, or replaced at startup with a warning.
  • You pressed s in the picker, so the choice was for one session only.
  • Your user settings file is read-only, so /model could not save. The change applies now and is gone next session.

Run /status to see which settings files loaded, and claude doctor to list entries Claude Code rejected.

Where to go next

If you are comparing tools before you commit to one, see Claude Code vs Codex. For what usage costs, see Is Claude Code free.

Frequently asked questions

How do I change the model in Claude Code?

Type /model in a session to open the picker, or /model sonnet to switch directly. To start on a model, run claude --model opus.

How do I set a default model in Claude Code?

Add a model field to ~/.claude/settings.json, for example "model": "opus". Picking a model with Enter in the /model picker also saves it there.

What does ANTHROPIC_MODEL do in Claude Code?

It sets the model for sessions launched with it and applies over the model key in any settings file. The --model flag overrides it.

Why does Claude Code start on a different model than I picked?

A project or managed setting, an exported ANTHROPIC_MODEL, an organization allowlist, or a session-only choice made with s in the picker can all override it. Run /status to see which settings files loaded.

Sources

  1. Model configurationAnthropic
  2. Settings files and precedenceAnthropic
  3. CLI referenceAnthropic
  4. Interactive modeAnthropic