# How to change or pin a model in Claude Code

Canonical: https://cwyn.com/pages/claude-code-guide-models.html
Last updated: 2026-11-27T06:24:45-05:00

Claude Code setup guide

Run `/model` in Claude Code to open the picker, or launch a session with `claude --model sonnet`. In the picker, press Enter to save it for new sessions or s to switch for this session only. Choose `opus` for reasoning, `haiku` for speed or `opusplan` for planning. [Pin a model](https://cwyn.com/pages/claude-code-guide-models.html#pin-version) with a full model name or an `ANTHROPIC_DEFAULT_*_MODEL` variable.

Last updated November 27, 2026 · Published November 23, 2026

By CWYN · Published Nov 23, 2026 · Checked against docs, not run · [Claude Code model configuration](https://code.claude.com/docs/en/model-config) and [environment variables](https://code.claude.com/docs/en/env-vars) (as of Nov 27, 2026)

## 1. Choose a model alias for the task

Claude Code model aliases and the default reset, as of Nov 23, 2026

| Alias or reset | What it does | When to use it |
| --- | --- | --- |
| `sonnet` | Tracks your provider's current Sonnet release. | Daily coding, such as adding a feature and its tests. |
| `opus` | Tracks your provider's current Opus release. | Complex reasoning, such as tracing a bug across several components. |
| `haiku` | Selects Haiku for a fast response. | A simple task, such as summarizing a short diff. |
| `opusplan` | Uses Opus in plan mode and Sonnet for execution. | You want Opus to work out a change and Sonnet to implement the approved plan. |
| `best` | Selects the same model as `opus` . | You want a saved preference that follows Opus releases. |
| `fable` | Selects Fable explicitly. | Your hardest, longest-running tasks. Check the picker for a usage-credit label first. |
| `sonnet[1m]` | Requests a 1 million token context window on Sonnet. | Daily coding that needs a large set of files in context. |
| `opus[1m]` | Requests a 1 million token context window on Opus. | A difficult investigation that needs the larger window. |
| `default` | Clears the model override. | You want to return to your account's runtime default. |

If the model already has a native 1 million token window, adding `[1m]` leaves its capacity unchanged. For a worked example of `opusplan`, see the [guide to planning with Opus and building with Sonnet](https://cwyn.com/pages/claude-code-guide-plan-mode.html) (as of Nov 22, 2026).

## 2. Look up the version your provider selects

The same alias can resolve to different releases. For example, a session launched with `claude --model sonnet` uses Sonnet 5.5 on the Anthropic API and Sonnet 4.5 on Amazon Bedrock.

Model versions by provider, as of Nov 23, 2026

| Provider | `opus` | `sonnet` | `haiku` |
| --- | --- | --- | --- |
| Anthropic API | Opus 5.5 | Sonnet 5.5 | Haiku 5.5 |
| Amazon Bedrock | Opus 5.5 | Sonnet 4.5 | Haiku 4.5 |
| Google Cloud's Agent Platform | Opus 5.5 | Sonnet 4.5 | Haiku 4.5 |
| Microsoft Foundry | Opus 4.6 | Sonnet 4.5 | Haiku 4.5 |
| Claude Platform on AWS | Opus 5.5 | Sonnet 4.6 | Haiku 4.5 |

For a specific release on Amazon Bedrock, supply the inference profile ARN. Microsoft Foundry takes a deployment name, and Google Cloud's Agent Platform takes a version name.

Check your Claude Code version before selecting a recent release. Opus 5.5 needs v2.1.280 or later, Sonnet 5.5 needs v2.1.284 or later, Haiku 5.5 needs v2.1.293 or later, and Fable 5.2 needs v2.1.321 or later. Run `claude update` to update the CLI.

## 3. Set the model in priority order

Claude Code uses the first applicable choice in this list. The shell examples use POSIX shell syntax.

1. During a session. Type `/model sonnet` at the Claude Code prompt to switch directly and save your choice. With `/model` alone, highlight a row. Press Enter to switch and write the `model` field in your user settings. Press s to switch for this session only.
2. At launch. Run `claude --model opus` in your terminal to start one session on Opus.
3. In the launch environment. Run `ANTHROPIC_MODEL=haiku claude` to use Haiku for that invocation.
4. In a settings file. To start on Opus across projects, add the `model` field to `~/.claude/settings.json`. Keep any other keys in the file.

```
{
  "model": "opus"
}
```
5. As the fallback for new sessions. Run `export ANTHROPIC_DEFAULT_MODEL=sonnet` in your shell. New sessions launched there use Sonnet when the choices above and your organization settings leave the model unspecified.

To retry an earlier request with the model you just selected, [rewind to the original prompt](https://cwyn.com/pages/claude-code-guide-rewind-checkpoints.html) and resend it.

## 4. Pin a model

An alias such as `opus` follows your provider's releases. To keep new sessions on one version, use a full model name in `~/.claude/settings.json`. For example, add `"model": "claude-opus-5-5"` for Opus 5.5 on the Anthropic API. To try it for one launch, run `claude --model claude-opus-5-5`.

To set the startup model from the environment, add `export ANTHROPIC_MODEL=claude-opus-5-5` to your shell profile. When launched from a new shell, Claude Code uses that value ahead of the saved `model` setting. To pin what the `opus` alias selects, add `export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-5-5` to the profile instead.

To try that alias mapping for one launch, run this in your terminal.

```
ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-5-5 claude --model opus
```

The corresponding `ANTHROPIC_DEFAULT_*_MODEL` variables for Sonnet and Haiku are `ANTHROPIC_DEFAULT_SONNET_MODEL` and `ANTHROPIC_DEFAULT_HAIKU_MODEL`. The Haiku variable replaces the deprecated `ANTHROPIC_SMALL_FAST_MODEL`.

## 5. Choose models for subagents and separate terminals

A subagent that inherits the main conversation's model follows a `/model` switch. To keep a README checker on Haiku while you reason through a bug on Opus, add `model: haiku` to the YAML at the top of its definition. See the [project subagent example](https://cwyn.com/pages/claude-code-guide-first-project-subagent.html) for the file layout. To use an existing definition, give the [reviewer subagent in the Claude Code Complete Setup Pack](https://cwyn.com/pages/pack-claude-code-complete-setup-pack.html) the model you want for reviews.

To run two independent conversations side by side, give each terminal its own launch flag. Both choices apply only to the session you start.

- In the first terminal, run `claude --model opus` to investigate the bug.
- In the second terminal, run `claude --model sonnet` to draft a regression test.

## 6. Troubleshoot model selection

### “There's an issue with the selected model”

A typo in `--model`, `ANTHROPIC_MODEL` or a settings file can let Claude Code start and then fail on the first request. Open `/model` and choose a listed model. If you meant to pin a version, correct the spelling and identifier type in the flag, variable or file that supplied it.

### The previous model comes back at startup

Check the startup header. When a project or managed settings file supplies the model, the header names that file. You can override it with `/model` now. A new session applies the file's setting again. See [which Claude Code settings file takes precedence](https://cwyn.com/pages/claude-code-guide-settings-json-precedence.html).

### Fable says “Requires usage credits”

Fable is an explicit choice on every plan. Depending on your plan and seat tier, Fable usage can bill to usage credits. Look for “Requires usage credits” on its picker row before selecting it with `/model fable` or launching `claude --model fable`.

### The picker shows no prices on Bedrock

Prices appear when Claude Code talks to the Anthropic API directly or through a gateway that proxies it. Bedrock and other third-party providers leave prices blank. The picker's price is a display label only.

If you switched because a request returned a 529, another model may have capacity. See [when switching models helps with a 529 overload](https://cwyn.com/pages/claude-code-guide-529-429-errors.html).

## 7. Claude Code models FAQ

### How do I restore my account's default model?

Run `/model default` to clear your override. Claude Code returns to the runtime default for your account.

### Does the best alias select Fable?

`best` resolves to the same model as `opus`. Choose `fable` explicitly if you want Fable.

### Will a model I try today become tomorrow's default?

Pressing Enter in the picker saves the model in your user settings. To try one temporarily, press s in the picker or start the session with `claude --model` followed by the alias or model name.

### Does ANTHROPIC_BASE_URL change the model?

`ANTHROPIC_BASE_URL` sets the endpoint that receives requests. Select the model for that endpoint with an alias or its provider-specific name.

## Next steps

- [All 34 Claude Code guides](https://cwyn.com/guides/claude-code/)
- [Claude Code setup walkthrough](https://cwyn.com/setup/claude-code/)
- [Free AI model comparison](https://cwyn.com/score/ai-model-comparison/)

Compare API costs before switching models

[Free AI cost calculator](https://cwyn.com/score/ai-cost-calculator/?tool=claude)

Keep session frequency and token counts the same when switching models to compare their monthly API costs.

[Claude Code Complete Setup Pack ($12.95)](https://cwyn.com/pages/pack-claude-code-complete-setup-pack.html)

Assign a model to the pack’s reviewer subagent for project setup reviews.

### Compare models for the same coding task

[Open the free AI model comparison](https://cwyn.com/score/ai-model-comparison/)

## Email me the CLAUDE.md + settings starter

Get the editable CLAUDE.md template and a project setting you can merge into .claude/settings.json.

Email address

Email me this file. Also send up to 4 short follow-up emails with tips and one related CWYN product. Unsubscribe any time. [Privacy policy](https://cwyn.com/pages/privacy.html)

### Set up a project reviewer

Get the reviewer subagent and permission rules in the [Claude Code Complete Setup Pack ($12.95)](https://cwyn.com/pages/pack-claude-code-complete-setup-pack.html).

Claude Code Complete Setup Pack $12.95

Set up project instructions, permission rules, hooks, a reviewer skill and subagent, and MCP connections for Claude Code.
