Skip to content
InnovateTechie
Claude Code

How to Change the Model in Claude Code (Every Method)

InnovateTechieBy InnovateTechie8 min read
Share
How to Change the Model in Claude Code

Part ofWhat Is Claude Code? The Complete Guide

Quick answer

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.

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

Step 1: See which model Claude Code is using

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

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.

How to change model in Claude Code — the /model command switching between Opus, Sonnet, and Haiku

Step 3: How to change model in Claude Code permanently

/model only changes the current session. To set a default that every new session uses, you have three options — pick whichever fits your workflow:

  1. Launch flag — start Claude Code on a specific model for that run:
    claude --model opus
  2. Environment variable — set it once in your shell so every session inherits it. Add this to .zshrc or .bashrc:
    export ANTHROPIC_MODEL="claude-sonnet-4-6"
  3. Settings file — set the model key in your settings.json for 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.

How to change model in Claude Code to Opus, Sonnet, or Haiku

Claude Code accepts short aliases so you never have to type a full model ID. These are the ones worth knowing:

AliasWhat it selects
sonnetLatest Sonnet — the balanced daily-driver default
opusLatest Opus — deepest reasoning and hardest refactors
haikuLatest Haiku — fastest and cheapest for simple tasks
bestThe 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
opusplanOpus 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

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.

TaskSwitch to
Everyday coding, tests, small fixessonnet
Large multi-file refactors, architectureopus
Long autonomous agent runsopus or opusplan
Bulk, simple, or throwaway workhaiku

Sonnet now delivers most of Opus's coding quality at a fraction of the cost, so you'll stay on it 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.

Claude Code model aliases and where to set them — session, launch flag, and environment variable

Troubleshooting: the model won't change

If a switch doesn't take, it's almost always one of these:

  1. The model isn't on your plan. Opus requires Max or API access — on Pro, /model opus may be unavailable or capped. Anthropic's model configuration guide lists what each plan can select.
  2. An environment variable is overriding you. A stale ANTHROPIC_MODEL in your shell config wins over expectations. Check with echo $ANTHROPIC_MODEL and unset it if it's forcing the wrong model.
  3. You edited settings mid-session. Config changes apply on the next launch — restart Claude Code after editing settings.json.

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 change model in Claude Code 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 opusplan and 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 haiku costs 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_MODEL in a project-level config, so every session there opens on Opus without a manual switch.

The point of learning how to change model in Claude Code 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.

SituationCommandWhy
New feature, unsure of approach/model opusplanOpus plans, Sonnet executes
Sudden hard bug or design call/model opusDeepest reasoning, then switch back
Repetitive bulk edits/model haikuCheapest, fast enough
Working across a whole codebase/model opus[1m]1M-token context window

Frequently Asked Questions

Type /model in an interactive session to open the picker, or run /model opus, /model sonnet, or /model haiku to switch instantly. The change lasts for that session. To make it permanent, launch with claude --model or set the ANTHROPICMODEL environment variable.

Set ANTHROPICMODEL in your shell config (for example export ANTHROPICMODEL="claude-sonnet-4-6" in .zshrc), add the model key to settings.json, or pass --model at launch. Any of these makes every new session start on your chosen model.

Claude Code supports Opus, Sonnet, and Haiku via the opus, sonnet, and haiku aliases, plus best, opusplan, and 1M-context variants sonnet[1m] and opus[1m]. Which ones you can select depends on your plan — Opus generally needs Max or API access.

opusplan is a hybrid mode: Claude Code uses Opus while you're in plan mode for the highest-quality planning, then automatically switches to Sonnet for executing the edits. It gives you Opus reasoning where it matters and Sonnet speed and cost for the rest.

It can. Opus costs more per token than Sonnet, and Haiku costs less — so switching model changes your rate. On a subscription, usage counts against your plan limits rather than a per-token bill. See our Claude Code cost guide for the full breakdown.

Run /model sonnet (or /model default where available) to return to the standard model for the session. To reset a permanent default, unset ANTHROPICMODEL in your shell config or remove the model key from settings.json, then restart Claude Code.
InnovateTechie

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 →