# Every way to choose a model in Claude Code

Authors: AutoRouter
Published: 2026-10-23T02:20:01.017Z
Reading time: 7 min
Canonical: https://autorouter.com/blog/claude-code-model-settings
Publisher: AutoRouter, the Mac app for Codex and Claude Code (https://autorouter.com)

> 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. AutoRouter, the Mac app for Codex and Claude Code, adds one more choice to /model that picks a model for each turn while it is selected.

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. Each accepts an alias such as `sonnet` or `opusplan`, or a full model name such as `claude-opus-5-5`. [AutoRouter, the Mac app for Codex and Claude Code](https://autorouter.com), appears in `/model` as one more choice that picks a model for each turn, 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 October 22, 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`                   | `fable` where available, otherwise `opus`    | Fable 5.1 or Opus 5.5                              |
| `fable`                  | For "your hardest and longest-running tasks" | Fable 5.1                                          |
| `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, `sonnet` is Sonnet 4.5. Opus 5.5 needs Claude Code v2.1.280 or later, Sonnet 5.5 needs v2.1.284 and Haiku 5.5 needs v2.1.293.

## 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).

## 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.

```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`:

```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 AutoRouter fit in Claude Code's /model picker?

AutoRouter, the Mac app for Codex and Claude Code, adds 20+ models to Claude Code's `/model` picker beside the ones already there, plus one more choice, AutoRouter, which picks a model for each turn. Enabling Claude Code in AutoRouter adds AutoRouter to Claude Code's `settings.json` after saving a copy of the file, and disabling Claude Code in AutoRouter's settings switches it back.

While AutoRouter 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. AutoRouter 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 AutoRouter off?

Picking another model sends your turns straight to it, since AutoRouter routes only while it is the model selected. Pick AutoRouter 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 October 22, 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

## Read next

- [Try a new model in Codex or Claude Code without another API key](https://autorouter.com/blog/try-new-models-in-codex-and-claude-code.md): Every manual way to try a new model in Codex or Claude Code needs an API key: one per provider, or one gateway key such as OpenRouter's. Claude Code reaches another provider through environment variables, and Codex through a custom provider in config.toml. AutoRouter, the Mac app for Codex and Claude Code, adds 20+ models to both apps' model pickers with no keys or endpoints to set up, and new models show up there right away.
- [Which model to use for which coding task](https://autorouter.com/blog/which-model-for-which-task.md): Use a frontier model such as Claude Opus 5.5 or GPT-6 Astra for multi-file refactors, hard bugs and UI built from a design. Use a strong model such as Claude Sonnet 5.5 or GPT-6.1 Sol for tests and code review, and a fast model such as Claude Haiku 5.5 or GPT-6 Luna for renames, commit messages and one-line shell commands. AutoRouter, the Mac app for Codex and Claude Code, makes that choice on every turn.
- [Codex model providers and config.toml, explained](https://autorouter.com/blog/codex-model-providers.md): Codex picks its model from the model key and its endpoint from the model_provider key in ~/.codex/config.toml, and each custom provider is a [model_providers.<id>] table with a base URL, an environment variable for its API key and the Responses wire API. Profiles are separate files loaded with --profile, -c overrides one key for one run, and --oss runs a local Ollama or LM Studio model. Enabling AutoRouter, the Mac app for Codex and Claude Code, adds it to config.toml after saving a copy of the file, and disabling it switches Codex back.

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

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