Changing the model during a Claude Code session with /model

Coding with AIClaude Code·· 19 views· 3 min read

Claude Code starts with the model in ANTHROPIC_MODEL, but you can switch in the middle of your work: a strong model for a big change, a light one for short questions. You do it with the /model command, inside the session.

Switching with /model

Type /model followed by the catalogue id, exactly as it is, with the slash:

/model zai-org/glm-5.2

The switch is immediate. If you type /model on its own, the Claude Code list opens. In that list, Enter switches and saves as your default, and the s key switches for this session only. The catalogue ids may not show in the list: in that case, type the id after /model.

This session only, or the next ones too

How you switch What happens
/model zai-org/glm-5.2 Switches now and saves the model as your default: Claude Code writes it to model, in ~/.claude/settings.json.
claude --model zai-org/glm-5.2 Opens a new session with that model, without changing the default. It also lets you run different models in different terminals.

Why the next session goes back to the old model

If you have ANTHROPIC_MODEL set, in the terminal or in the env of settings.json, that variable wins over the model saved by /model. That is what the Claude Code documentation says. So every new session goes back to the model in the variable. To change the starting model for good, change the value of ANTHROPIC_MODEL.

Before you switch

1 Check the id in the Models tab or in GET /v1/models. A misspelt name gives no error in Claude Code: we use moonshotai/kimi-k2.7-code and charge its price. See which model answers a name that is not in the catalogue.
2 Check the context of the new model. Claude Code only reads CLAUDE_CODE_MAX_CONTEXT_TOKENS at start. If you move to a model with less context, close it and open it again with the right value. See context and output in Claude Code.
3 Use a model that supports tools (function calling): Claude Code needs them to read files and run commands. The models recommended in the docs all support them.

Each model has its own cache. According to the Claude Code documentation, the first request after a switch reads the whole conversation again, without the cache. Switch models between tasks, not on every question.

Checking the model in use

/status shows the session model. With the Coding Plan, the models in the plan spend points and the others are paid with credits. The list is in the Plan tab.

A mix that works well: moonshotai/kimi-k2.7-code for everyday work, deepseek-ai/deepseek-v4-pro for big changes and hard bugs, and deepseek-ai/deepseek-v4-flash for short questions.

Want to code with AI in Claude Code? Visit the Coding with AI page.

See Coding with AI

SEE ALSO

Using Claude Code with All in One AI: the variables, the model and common errors

Context and output in Claude Code: CLAUDE_CODE_MAX_CONTEXT_TOKENS and CLAUDE_CODE_MAX_OUTPUT_TOKENS

Claude Code asks for a claude-sonnet model: which model answers and what you pay

Coding Plan: which plan to choose, what it costs and how to subscribe

Coding with AI in All in One AI

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from $5.36/mo (3-year plan, with coupon)

See plans
Was this answer helpful? Your answer helps us improve this article.