# How to change the model in Claude Code

> Claude Code takes its model from, in order of priority, the /model command, the --model flag, the ANTHROPIC_MODEL environment variable, the model key in settings.json and the ANTHROPIC_DEFAULT_MODEL variable. Aliases such as opus, sonnet, haiku, fable and opusplan stand for the current model in each family, and subagents take their model from their own model field, CLAUDE_CODE_SUBAGENT_MODEL or the main session. Auto, the Mac app for all your coding agents, adds one more choice to /model that picks a model for each turn while it is selected.

Author: Tyler J. Cagle (https://x.com/tjcages)
Published: 2026-10-09T17:45:00.000Z
Updated: 2026-11-20T15:20:00.000Z
Reading time: 9 min
Canonical: https://auto.sh/blog/claude-code-model-settings
Part of: How to choose and change models in Codex and Claude Code (https://auto.sh/blog/models-in-codex-and-claude-code.md)
Publisher: Auto (https://auto.sh)

## Key facts

- Claude Code takes its model from five settings, in this order of priority: `/model` in a session, `claude --model` at launch, the `ANTHROPIC_MODEL` environment variable, the `model` field in a settings file and `ANTHROPIC_DEFAULT_MODEL` ([Anthropic, October 22, 2026](https://code.claude.com/docs/en/model-config#setting-your-model)).
- `/model` saves your pick as the default for new sessions, while `--model` and `ANTHROPIC_MODEL` apply only to the session they launch.
- On the Anthropic API, `default` and `opus` resolve to Claude Opus 5.5, `sonnet` to Sonnet 5.5 and `haiku` to Haiku 5.5, and `opusplan` plans on Opus 5.5 and carries out the plan on Sonnet 5.5.
- Because `default` is Opus 5.5, small jobs run on the most expensive model unless you change it: in Auto's measurement on October 28, 2026, a commit message cost $0.082 on Opus 5.5 and $0.0024 on Haiku 5.5 at list prices ([data](/blog/claude-code-task-costs-measured)).

![The highest model setting that's set wins. Where it's set, highest first: 1. /model, Now, saved as your default; 2. claude --model, That session; 3. ANTHROPIC_MODEL, Sessions launched with it; 4. model in a settings file, You or your project; 5. ANTHROPIC_DEFAULT_MODEL, New sessions, if nothing else is set. Source: Claude Code model configuration docs, checked October 22, 2026.](https://auto.sh/blog/images/claude-code-model-settings/1-model-priority.png)

As of October 22, 2026, [Anthropic's model configuration docs](https://code.claude.com/docs/en/model-config#setting-your-model) list five ways to set Claude Code's model, in order of priority: `/model` during a session, `claude --model` at startup, the `ANTHROPIC_MODEL` environment variable, the `model` field in a settings file, and `ANTHROPIC_DEFAULT_MODEL` for new sessions. [Claude Code environment variables and where to set them](/blog/claude-code-environment-variables) covers the other variables Claude Code reads. Each accepts an alias such as `sonnet` or `opusplan`, or a full model name such as `claude-opus-5-5`. For the larger choice between Claude Code and Codex, see our [side-by-side comparison](/blog/codex-vs-claude-code). Auto, the Mac app for all your coding agents, appears in `/model` as [one more choice that picks a model for each turn](https://autorouter.com/), and it routes only while it is the model selected.

## Which setting decides Claude Code's model?

The highest item on that list that is set decides the main session's model. `/model` also saves your pick: it "saves your choice as the default for new sessions by writing the `model` field in your user settings." In the picker, `Enter` switches and saves, and `s` switches "for this session only." The `--model` flag and `ANTHROPIC_MODEL` "apply only to the session you launch with them." The table lists every other place Claude Code takes a model from.

| Option                                                                                                                                                                                                   | Where you set it                     | What it covers                                  | Example                                               |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | ----------------------------------------------- | ----------------------------------------------------- |
| `/model`                                                                                                                                                                                                 | In a session                         | Now, saved as your default                      | `/model sonnet`                                       |
| [`--model`](https://code.claude.com/docs/en/cli-reference)                                                                                                                                               | Command line                         | That session                                    | `claude --model opus`                                 |
| `ANTHROPIC_MODEL`                                                                                                                                                                                        | Environment                          | Sessions launched with it                       | `ANTHROPIC_MODEL=sonnet claude`                       |
| [`model`](https://code.claude.com/docs/en/settings-reference#model)                                                                                                                                      | User, project or local settings file | You, your project, or you in one project        | `"model": "opus"`                                     |
| [`ANTHROPIC_DEFAULT_MODEL`](https://code.claude.com/docs/en/model-config#set-a-default-model-for-new-sessions)                                                                                           | Environment                          | New sessions, if nothing above sets a model     | `export ANTHROPIC_DEFAULT_MODEL=sonnet`               |
| [`ANTHROPIC_DEFAULT_OPUS_MODEL`](https://code.claude.com/docs/en/model-config#environment-variables), `ANTHROPIC_DEFAULT_SONNET_MODEL`, `ANTHROPIC_DEFAULT_HAIKU_MODEL`, `ANTHROPIC_DEFAULT_FABLE_MODEL` | Environment                          | What each alias resolves to                     | `export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-5-5` |
| [`model` frontmatter](https://code.claude.com/docs/en/sub-agents#choose-a-model)                                                                                                                         | `.claude/agents/<name>.md`           | That subagent                                   | `model: haiku`                                        |
| `CLAUDE_CODE_SUBAGENT_MODEL`                                                                                                                                                                             | Environment or settings `env`        | Subagents with no other model set               | `"CLAUDE_CODE_SUBAGENT_MODEL": "haiku"`               |
| `CLAUDE_CODE_SUBAGENT_MODEL_FORCE`                                                                                                                                                                       | Environment or settings `env`        | Every subagent, teammate and workflow agent     | `"CLAUDE_CODE_SUBAGENT_MODEL_FORCE": "1"`             |
| [`model` frontmatter](https://code.claude.com/docs/en/skills)                                                                                                                                            | `.claude/skills/<name>/SKILL.md`     | The rest of the current turn                    | `model: opus`                                         |
| `--agent` or `agent`                                                                                                                                                                                     | Command line or settings             | Main thread runs as that subagent, on its model | `claude --agent code-reviewer`                        |
| [`--fallback-model` or `fallbackModel`](https://code.claude.com/docs/en/model-config#fallback-model-chains)                                                                                              | Command line or settings             | One turn, when the primary model is unavailable | `claude --fallback-model sonnet,haiku`                |
| [Organization default model](https://code.claude.com/docs/en/model-config#organization-default-model)                                                                                                    | claude.ai admin console              | What Default resolves to (Enterprise)           | Set by an admin                                       |
| [`availableModels`](https://code.claude.com/docs/en/model-config#restrict-model-selection)                                                                                                               | Managed settings                     | Which models people can select                  | `"availableModels": ["sonnet", "haiku"]`              |

## What do the Claude Code model aliases mean?

Aliases "point to the recommended version for your provider and update over time," according to [the docs](https://code.claude.com/docs/en/model-config#model-aliases), while a full model name such as `claude-opus-5-5` pins one version. On the Anthropic API, as of November 9, 2026, they resolve like this:

| Alias                    | What it does                                 | Anthropic API model                                |
| ------------------------ | -------------------------------------------- | -------------------------------------------------- |
| `default`                | Returns to your account's default            | Opus 5.5 on Pro, Max, Team, Enterprise and the API |
| `best`                   | The same model as `opus`                     | Opus 5.5                                           |
| `fable`                  | For "your hardest and longest-running tasks" | Fable 5.2                                          |
| `opus`                   | For "complex reasoning tasks"                | Opus 5.5                                           |
| `sonnet`                 | For "daily coding tasks"                     | Sonnet 5.5                                         |
| `haiku`                  | For "simple tasks"                           | Haiku 5.5                                          |
| `opus[1m]`, `sonnet[1m]` | 1 million token context window               | No change, since both models already have one      |
| `opusplan`               | `opus` in plan mode, `sonnet` for execution  | Opus 5.5, then Sonnet 5.5                          |

Other providers can resolve an alias to an older model. On Amazon Bedrock, Google Cloud's Agent Platform and Microsoft Foundry, `haiku` is still Haiku 4.5 and `sonnet` is Sonnet 4.5, so a subagent set to `model: haiku` there runs a model a generation older than it does on the Anthropic API ([provider table](https://code.claude.com/docs/en/model-config#model-aliases)). Pin a version with `ANTHROPIC_DEFAULT_HAIKU_MODEL` if that matters. Opus 5.5 needs Claude Code v2.1.280 or later, Sonnet 5.5 needs v2.1.284, Haiku 5.5 needs v2.1.293 and Fable 5.2 needs v2.1.321. Fable 5.1 is no longer reached through an alias: select it with `/model claude-fable-5-1`.

## How does opusplan split planning and coding?

`opusplan` runs `opus` in plan mode and switches to `sonnet` to carry out the plan, pairing "Opus's reasoning for planning with Sonnet's efficiency for execution," as [the docs](https://code.claude.com/docs/en/model-config#opusplan-model-setting) put it. Start a session on it, then enter plan mode with [`/plan`](https://code.claude.com/docs/en/commands):

```bash
claude --model opusplan
```

`ANTHROPIC_DEFAULT_OPUS_MODEL` and `ANTHROPIC_DEFAULT_SONNET_MODEL` set the model for each phase. Each plan-mode toggle is a model switch and [starts a fresh cache](https://code.claude.com/docs/en/prompt-caching#switching-models). The split runs against Anthropic's own advice in its November 9, 2026 guide [Which Claude model should you build with?](https://claude.dev/blog/which-claude-model-should-you-build-with/), which keeps code edits and judgment calls on the main model and moves side work such as log reading and file search to smaller ones. That guide calls `opusplan` the reverse of its advice and suggests measuring it on your own tasks before adopting it.

## How do you set a default model in settings.json?

Add a `model` key to `~/.claude/settings.json` for all your projects, `.claude/settings.json` for everyone in a project, or `.claude/settings.local.json` for you in one project. The [local file applies over the shared one](https://code.claude.com/docs/en/settings#keep-personal-settings-out-of-a-repository), so you can run Opus where your team's file sets Sonnet. For the same settings in Codex, see [How to choose and change models in Codex and Claude Code](/blog/models-in-codex-and-claude-code).

```json
{
  "model": "sonnet"
}
```

`ANTHROPIC_MODEL` outranks every settings file and returns at each launch, whatever you saved with `/model`. [`ANTHROPIC_DEFAULT_MODEL`](https://code.claude.com/docs/en/model-config#set-a-default-model-for-new-sessions) (v2.1.236 or later) applies only when no `--model` flag, `ANTHROPIC_MODEL`, settings `model` or organization default picks a model, and Claude Code ignores it when it is set to `default`, `inherit`, `opusplan` or `haiku`. The family variables take a full model name:

```bash
# Sessions launched from this shell start on Sonnet
export ANTHROPIC_MODEL=sonnet

# Keep the opus alias on one version
export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-5-5
```

## How do you choose a model for Claude Code subagents?

A subagent's model comes from, [in order](https://code.claude.com/docs/en/sub-agents#choose-a-model): the model Claude passes when it starts the subagent, the `model` field in its frontmatter, `CLAUDE_CODE_SUBAGENT_MODEL`, and then the main conversation's model. The field accepts `sonnet`, `opus`, `haiku`, `fable`, a full model ID or `inherit`:

![A subagent takes the first model it finds. Where its model comes from, in order: 1. The model Claude passes; 2. model in its frontmatter; 3. CLAUDE_CODE_SUBAGENT_MODEL; 4. The main conversation's model. Set CLAUDE_CODE_SUBAGENT_MODEL_FORCE to 1 to run every subagent on the variable's model. Source: Claude Code docs on subagents, checked October 22, 2026.](https://auto.sh/blog/images/claude-code-model-settings/2-subagent-order.png)

```markdown
---
name: code-reviewer
description: Reviews code for quality and best practices
tools: Read, Glob, Grep
model: sonnet
---
```

`CLAUDE_CODE_SUBAGENT_MODEL` is only a default. To [run every subagent on one model](https://code.claude.com/docs/en/sub-agents#run-every-subagent-on-one-model), also set `CLAUDE_CODE_SUBAGENT_MODEL_FORCE` to `1` (v2.1.257 or later):

```json
{
  "env": {
    "CLAUDE_CODE_SUBAGENT_MODEL": "haiku",
    "CLAUDE_CODE_SUBAGENT_MODEL_FORCE": "1"
  }
}
```

One setup, worked from the docs: the main session on `opus`, `CLAUDE_CODE_SUBAGENT_MODEL=haiku` without the force variable, and the `code-reviewer` above. A model Claude passes when it starts a subagent would override any row.

| Subagent                   | Runs on    | Why                                                              |
| -------------------------- | ---------- | ---------------------------------------------------------------- |
| `code-reviewer`            | Sonnet 5.5 | Its frontmatter outranks the variable                            |
| General-purpose (built in) | Haiku 5.5  | Nothing else sets a model, so the variable applies               |
| Explore                    | Opus 5.5   | It uses the main model, and the variable alone doesn't change it |
| Plan                       | Opus 5.5   | It inherits the main model unless the force variable is set      |

Inheriting subagents follow `/model` switches too. [The docs](https://code.claude.com/docs/en/model-config#setting-your-model) put it this way: "Switch to Opus before Claude delegates research or test runs to one of them, and that work runs on Opus too."

## How do you check which model Claude Code is using?

Run [`/status`](https://code.claude.com/docs/en/commands), which shows "version, model, account, and connectivity," or add a [status line](https://code.claude.com/docs/en/statusline) that prints `model.display_name`, as in this example from the docs:

```json
{
  "statusLine": {
    "type": "command",
    "command": "jq -r '\"[\\(.model.display_name)] \\(.context_window.used_percentage // 0)% context\"'"
  }
}
```

[`/tasks`](https://code.claude.com/docs/en/sub-agents#choose-a-model) names each subagent's model (v2.1.242 or later). When project or managed settings set the model, the startup header names the file that set it.

## Where does Auto fit in Claude Code's /model picker?

Auto, the Mac app for all your coding agents, adds models from different providers to Claude Code's `/model` picker beside the ones already there, plus one more choice, Auto, which picks a model for each turn. Enabling Claude Code in Auto adds Auto to Claude Code's `settings.json` after saving a copy of the file, and disabling Claude Code in Auto's settings switches it back. [Auto for Claude Code](/integrations/claude-code) lists the setup steps.

While Auto is selected, your own rules decide a turn first. Otherwise hard work goes to the most capable model your plans cover, and everything else goes to the model that costs you least among those that clear the quality bar. Claude models run on your Claude plan, and every turn shows its model, what it cost and why. [How AutoRouter picks a model for each turn](/blog/how-autorouter-picks-a-model) covers the full order.

Picking any other model in `/model` sends turns straight to it, because AutoRouter routes only while it is the model selected. The built-in options fit when you want one model, or a fixed split such as `opusplan`, with nothing else installed. For a pick on every request, [the best Claude Code routers](/blog/model-routers-claude-code-codex) are ranked by use case. Auto is in beta and needs macOS 14 or later, and Node 22.18 or later for Claude Code.

## Questions

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

Something with higher priority usually sets the model again at launch: a `model` value in project or managed settings, `ANTHROPIC_MODEL` in your shell, or an organization default set to override user choices. A pick made with `s` or `--model` lasts one session, and a resumed session usually keeps its old model. [The docs list every cause](https://code.claude.com/docs/en/model-config#a-new-session-starts-on-a-different-model-than-you-picked).

### Does switching models mid-session cost more?

The first request after a switch costs more, because each model has its own prompt cache and that request "reads the entire conversation history with no cache hits," according to the [prompt caching docs](https://code.claude.com/docs/en/prompt-caching#switching-models). Claude Code asks you to confirm a `/model` switch while the cache is still warm.

### Can I run different models in two terminals at once?

Yes. Launch each terminal with its own `--model` flag, as [the docs advise](https://code.claude.com/docs/en/model-config#setting-your-model), because `/model` saves your pick as the default for new sessions.

### Which alias should I use for a task?

Anthropic describes `sonnet` as the model for daily coding, `opus` for complex reasoning, `haiku` for simple tasks and `fable` for the hardest and longest-running work. [Which model for which coding task](/blog/which-model-for-which-task) breaks this down by task, and [how Claude Code usage limits work](/blog/claude-code-usage-limits) covers plan limits.

### Does picking a model in /model turn Auto off?

Picking another model sends your turns straight to it, since AutoRouter routes only while it is the model selected. Pick Auto again with `/model` to go back to a model chosen for each turn.

## Sources

- [Model configuration](https://code.claude.com/docs/en/model-config), checked November 9, 2026
- [Create custom subagents](https://code.claude.com/docs/en/sub-agents), checked October 22, 2026
- [Settings files and precedence](https://code.claude.com/docs/en/settings), checked October 22, 2026
- [All settings](https://code.claude.com/docs/en/settings-reference), checked October 22, 2026
- [CLI reference](https://code.claude.com/docs/en/cli-reference), checked October 22, 2026
- [Commands](https://code.claude.com/docs/en/commands), checked October 22, 2026
- [Environment variables](https://code.claude.com/docs/en/env-vars), checked October 22, 2026
- [Customize your status line](https://code.claude.com/docs/en/statusline), checked October 22, 2026
- [How Claude Code uses prompt caching](https://code.claude.com/docs/en/prompt-caching), checked October 22, 2026
- [Extend Claude with skills](https://code.claude.com/docs/en/skills), checked October 22, 2026
- [Which Claude model should you build with?](https://claude.dev/blog/which-claude-model-should-you-build-with/), Claude blog, Anthropic, November 9, 2026

## Read next

- [How to choose and change models in Codex and Claude Code](https://auto.sh/blog/models-in-codex-and-claude-code.md): To give each task the right model, use Auto, the Mac app for all your coding agents: it adds models from every leading provider to the picker you already use (Claude Code, Codex, Cursor, etc.) and can pick one for each turn. To choose yourself, give hard, multi-file work a frontier model such as Claude Opus 5.5 or GPT-6.2 Astra and quick edits a fast one such as Claude Haiku 5.5 or GPT-6 Luna. Switch with /model in either app, a launch flag for one session, or a settings file for every session.
- [How to use MiniMax in Claude Code and Codex](https://auto.sh/blog/minimax-in-claude-code-and-codex.md): Use Auto, the Mac app for all your coding agents: it puts MiniMax M3.1 Flash in each one's model picker (Claude Code, Codex, Cursor, etc.) with no MiniMax key or config. Natively, set Claude Code's `ANTHROPIC_BASE_URL` to `https://api.minimax.io/anthropic` with your M Plan key and `MiniMax-M3.1-Flash[1m]` model variables in `~/.claude/settings.json`, and add `https://api.minimax.io/v1` as a provider in Codex's `config.toml`.
- [How to use Kimi in Claude Code and Codex](https://auto.sh/blog/kimi-in-claude-code-and-codex.md): Use Auto, the Mac app for all your coding agents: it puts Kimi K3.1 Pro in each one's model picker (Claude Code, Codex, Cursor, etc.) with no Kimi account, key or config. Natively, set Claude Code's `ANTHROPIC_BASE_URL` to Moonshot's `https://api.moonshot.ai/anthropic` (or `https://api.kimi.ai/coding/` with a Kimi Code plan) with your key and model variables in `~/.claude/settings.json`, and add `https://api.moonshot.ai/v1` as a provider with `kimi-k3.1-pro` in Codex's `config.toml`.

Tags: [Claude Code](https://auto.sh/blog/tags/claude-code.md), [Models](https://auto.sh/blog/tags/models.md), [Guides](https://auto.sh/blog/tags/guides.md)

Drafted with AI from the sources linked above, then checked and edited by the Auto team.

Auto is a Mac app for AI model routing in Codex, Claude Code, Cursor and other supported coding agents. It uses eligible connected subscriptions first. See [setup](https://auto.sh/setup.md) and [pricing](https://auto.sh/pricing).
