Part ofWhat Is Claude Code? The Complete Guide
In This Article
7 sectionsQuick answer
How to change model in Claude Code: type /model to switch between Opus, Sonnet, and Haiku instantly, or set a permanent default with --model.
To change the model in Claude Code, type /model and pick from the list, or run /model opus (or sonnet / haiku) to switch instantly mid-session. To make a choice stick, launch with claude --model opus or set ANTHROPIC_MODEL in your shell. This guide covers how to change model in Claude Code every way — for one session and as your permanent default.
Commands, aliases, and model lineup verified 31 July 2026 against the Claude Code model configuration reference.
Switching models is one of the highest-leverage habits in Claude Code: Sonnet for the fast bulk of your work, Opus for the genuinely hard problems, Haiku for cheap throwaway tasks. We move between them constantly. The lineup currently spans Claude Opus 5, Claude Sonnet 5, and Claude Haiku 4.5, and the switch itself takes under 10 seconds — we review this guide regularly so the commands and aliases stay accurate. Below is exactly how to change model in Claude Code — mid-session with a keystroke, at launch with a flag, and permanently through config — plus which one to reach for and what to do when the switch won't take.
Key takeaway
To change the model in Claude Code, type /model or /model opus|sonnet|haiku to switch instantly for the session, or set the ANTHROPIC_MODEL variable or launch with --model to make Opus 5, Sonnet 5, or Haiku 4.5 your permanent default.
Step 1: See which model Claude Code is using
Type /model on its own — it prints the active model and opens the picker. /status also shows it alongside your account and version.
Before you switch, check what's active so you can confirm the change. Type this in an interactive session:
/model
Run on its own, /model shows your current model and opens the picker listing every model you can select. You can also type /status to see the active model alongside your account and version. Knowing the starting point makes the next step unambiguous.
Step 2: How to change model in Claude Code with the /model command
Run /model opus, /model sonnet, or /model haiku. The change applies immediately and lasts the rest of the session.
The /model command is the fastest way to switch, and it's the answer most people are looking for. Pass an alias to jump straight to a model without touching the menu:
/model opus # switch to the latest Opus
/model sonnet # switch to the latest Sonnet
/model haiku # switch to the fast, cheap Haiku
The change applies immediately and lasts for the rest of the session. This is the core of how to change model in Claude Code on the fly — start a task on Sonnet, hit a hard architectural decision, type /model opus, and drop back to /model sonnet when the tricky part is done.
Step 3: How to change model in Claude Code permanently
Three options: launch with claude --model opus, export ANTHROPIC_MODEL in your shell, or set the model key in settings.json.
/model only changes the current session. To set a default that every new session uses, you have three options — pick whichever fits your workflow:
- Launch flag — start Claude Code on a specific model for that run:
claude --model opus - Environment variable — set it once in your shell so every session inherits it. Add this to
.zshrcor.bashrc:export ANTHROPIC_MODEL="claude-sonnet-5" - Settings file — set the
modelkey in yoursettings.jsonfor a per-project or per-user default.
The environment variable is the cleanest permanent answer to how to change model in Claude Code for good, while --model is handy for one-off runs. All three are documented in the Claude Code model configuration reference.
Model aliases: opus, sonnet, haiku, and opusplan
Short aliases mean you never type a full model ID — sonnet, opus, haiku, plus best, opusplan, and the [1m] long-context variants.
Claude Code accepts short aliases so you never have to type a full model ID. These are the ones worth knowing:
| Alias | What it selects |
|---|---|
sonnet | Latest Sonnet — the balanced daily-driver default |
opus | Latest Opus — deepest reasoning and hardest refactors |
haiku | Latest Haiku — fastest and cheapest for simple tasks |
best | The most capable model available to your plan |
sonnet[1m] | Sonnet with a 1M-token context window |
opus[1m] | Opus with a 1M-token context window |
opusplan | Opus during plan mode, then Sonnet for execution |
opusplan is the power move: you get Opus's planning quality where it matters most and Sonnet's speed and price for the actual edits. Use sonnet[1m] or opus[1m] when you're working across a large codebase that needs the extra context.
Which model should you switch to
Default to Sonnet; escalate to Opus when a mistake is expensive to catch; drop to Haiku for mechanical bulk work.
Changing the model is only useful if you pick the right one. The rule of thumb: default to Sonnet, escalate to Opus when a mistake is expensive to catch.
| Task | Switch to |
|---|---|
| Everyday coding, tests, small fixes | sonnet |
| Large multi-file refactors, architecture | opus |
| Long autonomous agent runs | opus or opusplan |
| Bulk, simple, or throwaway work | haiku |
Sonnet now delivers most of Opus's coding quality at a fraction of the cost — Sonnet 5 runs $3/$15 per million tokens against Opus 5's $5/$25, while Haiku 4.5 drops to $1/$5 — so you'll stay on Sonnet more than you expect; we break down exactly where each wins in Claude Sonnet vs Opus. Model access also depends on your plan; Opus needs Max or API credits, which we cover in Claude Code cost.
Troubleshooting: the model won't change
Almost always one of three things: the model is not on your plan, a stale ANTHROPIC_MODEL is overriding you, or you edited settings mid-session.
If a switch doesn't take, it's almost always one of these:
- The model isn't on your plan. Opus requires Max or API access — on Pro,
/model opusmay be unavailable or capped. Anthropic's model configuration guide lists what each plan can select. - An environment variable is overriding you. A stale
ANTHROPIC_MODELin your shell config wins over expectations. Check withecho $ANTHROPIC_MODELand unset it if it's forcing the wrong model. - You edited settings mid-session. Config changes apply on the next launch — restart Claude Code after editing
settings.json.
Item 2 is the one that caught us out on our own machine. We run Claude Code against this site from a Windows PowerShell terminal, and after setting ANTHROPIC_MODEL once for a bulk Haiku job we forgot it was there — every new session silently opened on the wrong model until we ran the environment check and cleared it. Since then, whenever a /model switch appears to "not take," the first thing we check is a leftover environment variable rather than anything inside Claude Code itself. The tell is subtle: the picker reports the switch succeeded, so it looks like it worked, but the very next session quietly reverts because the environment variable wins on every fresh launch while an in-session pick only lasts until you close the window. Running the check above settles it in seconds, and clearing the variable restores the ordinary precedence where your launch flag and your session picks behave exactly the way the documentation describes.
That covers how to change model in Claude Code when the obvious command seems to do nothing. For the complete list of commands and config keys, see our Claude Code CLI documentation.
Model-switching workflows worth stealing
Knowing how to switch matters less than knowing when. Four patterns cover almost every session: plan-on-Opus, escalate-and-step-back, drop-to-Haiku, and pin-per-project.
Knowing switching models is one thing; knowing when is what saves time and money. These are the switching patterns we lean on every day, and they're the real reason the /model command matters:
- Plan on Opus, build on Sonnet. Type
/model opusplanand let Claude Code use Opus while it plans, then Sonnet while it edits — the single best default for any non-trivial feature. It pairs naturally with plan mode, where the planning quality pays off most. - Escalate mid-task, then step back down. Start on
sonnet, hit a gnarly bug or an architecture call, run/model opus, solve it, then/model sonnet. You pay Opus rates only for the few minutes you genuinely need them, which keeps your bill close to Sonnet's. - Drop to Haiku for grunt work. Bulk renames, log parsing, quick file summaries —
/model haikucosts a fraction of Sonnet and is plenty capable for mechanical tasks that don't need deep reasoning. - Pin a default per project. A repo that always needs deep reasoning can set
ANTHROPIC_MODELin a project-level config, so every session there opens on Opus without a manual switch.
The point of learning switching models isn't to fiddle with settings — it's to match the model to the moment. Most of your day lives comfortably on Sonnet; the real wins come from the deliberate jumps up to Opus for hard problems and down to Haiku for cheap, high-volume work.
| Situation | Command | Why |
|---|---|---|
| New feature, unsure of approach | /model opusplan | Opus plans, Sonnet executes |
| Sudden hard bug or design call | /model opus | Deepest reasoning, then switch back |
| Repetitive bulk edits | /model haiku | Cheapest, fast enough |
| Working across a whole codebase | /model opus[1m] | 1M-token context window |
Frequently Asked Questions

Written by
InnovateTechie
Writing about Claude and the Anthropic toolkit — models, Claude Code, pricing, features, and fixes, in clear, practical, hands-on guides tested by daily use.
View all posts →


