Switch AI models with a click
The previous three chapters explained why you might connect several AI providers, when each of the six providers is useful, and what reasoning models are. This chapter puts that knowledge into practice: how to switch to another model midway through a conversation and keep going. You will learn workflows such as “draft quickly with a low-cost model → ask an advanced model for a code review” in the same Session. You will also learn what stays and what disappears when you switch.
Why switching models is an everyday skill
Chapter 10 explained why one provider may not be enough. Chapter 11 compared six providers at a glance. Chapter 12 explained why some models “think first.” That is the theory. Putting AI to work requires action: you need to be able to hand the same conversation to another model and keep talking.
Consider an everyday example. You ask GLM-4-Flash, “Write an automation that turns off the lights at night,” and it produces YAML in 30 seconds. You look at it and wonder, “This seems a little rough. Is it really reliable?” You do not need to start a new Session or copy everything into another tool. Find the model button in the composer toolbar, select Anthropic Claude Sonnet, and ask, “Please review the automation above for problems.” Claude will use the entire conversation, including GLM’s answer, as context and respond directly. This “draft quickly with a low-cost model, then review with an advanced model” workflow is a common way to control costs. Whether it actually saves 60-80% depends on your prompt length and model choice; that range reflects practical experience, not a guarantee.
By the end of this chapter, you will know how to switch, what happens when you do, and when to switch instead of starting a new Session.
Where the model selector is and when a switch takes effect
Chapter 4 showed you where to find the model selector: in the toolbar below the composer (the text box). It looks like a button with a small arrow and normally displays the current model name, such as “GLM-4-Flash” or “Claude Sonnet 4.5.” If you have not selected a model, it displays a prompt instead. The exact position varies by version and theme. The order of controls in the upstream pi-web toolbar (attachments, model, Skill, voice, and send) is configurable, so the button may be on the left or closer to the center. Look for the model name. Select the button to open a popover listing the currently available models under every provider you added in the Models panel. You can also type in the list’s search field to filter it.
Two details are essential:
- The switch takes effect immediately, but it does not rerun anything. After you select a new model, that model answers the next message you send. Messages you sent before the switch are not submitted again, and earlier AI responses do not disappear. In other words, switching models does not charge you again for earlier turns in the conversation.
- The new model receives the whole conversation. When the new model handles its first message, it reads the entire Session, from the first message through the one you just sent, as input tokens. That lets it follow the existing topic, but it also means another round of input-token charges. The “Hidden cost” section below explains this in detail.
Try it: switch from GLM-Flash to Claude for a review
Assume that you connected GLM by following the API-key workflow in Chapter 5 and added Anthropic (Claude) as another provider by following Appendix B. Now try a draft-then-review workflow.
-
Start a new Session and select GLM-4-Flash
Select + New session in the upper-left corner; the exact button text depends on your interface language. The screen clears. Find the model button in the toolbar below the composer, open it, find the GLM group, and select
glm-4-flash(or another fast, low-cost model you know). The button label changes to “GLM-4-Flash.” -
Ask about a real household need and get a draft
Enter: “Write a Home Assistant automation that turns off every light in the living room at 11:30 p.m. If someone is still in the living room at that time, wait 10 minutes before turning them off.” Send the message. GLM-4-Flash will typically produce YAML in about 20-40 seconds, possibly using
triggers,conditions, andactions. -
If you are unsure whether it is reliable, switch to Claude Sonnet
Do not clear the screen or start a new Session. Stay in the current conversation, open the model selector, and choose
claude-sonnet-4-5(or the latest Sonnet version) under Anthropic. The button label changes to “Claude Sonnet 4.5.” -
Ask it to review the earlier answer
Enter: “Please review the automation above. Does it have any logic errors or common HA pitfalls, such as the device_id trap, the wrong mode, or failure to detect a nonexistent entity_id?” Send the message. Claude reads the entire conversation, including your question, GLM’s YAML, and this review request, then provides specific feedback.
-
Compare the two responses and decide what to use
Claude will often identify issues such as GLM using
device_idinstead ofentity_id(a pitfall covered in Chapter 8), whethermodeshould berestartrather than the defaultsingle, and whether triggers, conditions, and actions use the newer plural form. At the end, you have a complete package: a low-cost model’s draft plus an advanced model’s review. Revise it as needed before using it. -
(Advanced) Switch back to GLM to apply Claude’s feedback
After Claude reviews the draft, you can switch back to
glm-4-flashand ask, “Rewrite the YAML using Claude’s feedback above.” GLM is inexpensive and capable enough to revise YAML, so you do not need to keep paying for Claude during this step. This is the three-stage workflow: draft (Flash) → review (Sonnet) → rewrite (Flash). Experienced users rely on it every day.
Three common reasons to switch
Do not switch models at random. Most switches fit one of the following three patterns. Identify which one you need before switching; it can make a major difference in both efficiency and cost.
| Scenario | How to switch | When to use it | Typical cost |
|---|---|---|---|
| Draft-then-review (draft first, then review) | Use a fast, low-cost model for the first draft → switch to an advanced model for code review → optionally switch back to the low-cost model for revisions | Automations, scripts, email, and any output with a generally correct answer whose details still require care | Much less than using an advanced model throughout (a common observed range is 50-80%, depending on conversation length), with much greater reliability than using a low-cost model throughout |
| Explore one point (zoom in) | Use a low-cost model for everyday conversation → reach a point that needs deeper analysis, such as calculating air-conditioner capacity or wire ampacity → switch to a reasoning model and follow up → switch back to the low-cost model afterward | A branch of the conversation requires serious thought, but the whole conversation does not require an advanced model | Pay more for only those 2-3 in-depth messages; keep the conversation before and after them inexpensive |
| Compare the same question (A/B) | Ask a question and receive answer A → fork the Session (as shown in Chapter 8) → switch the fork to another provider → send the same question and receive answer B → compare the two windows side by side | Important home-buying or remodeling decisions, academic questions, or checking whether different models show different biases | Pay once for each provider, but save the time you would otherwise spend on trial and error |
The hidden cost of switching: input tokens are counted again
This surprises many people when they receive their first month’s bill. Switching models looks like a simple click, but when a new model handles its first message, it reads the entire conversation from the beginning as input tokens. The reason is simple: the new model has not seen the conversation. To continue it, you must provide the context first.
Consider an example. Your conversation has accumulated 5,000 tokens, or about 15-20 exchanges, and you switch models 4 times in the same Session:
| Action | Accumulated conversation tokens | Input tokens reread for this switch | Note |
|---|---|---|---|
| First switch (Flash → Sonnet) | 5,000 | 5,000 | Sonnet takes over for the first time |
| Sonnet returns 500 tokens, then you switch back to Flash | 5,500 | 5,500 | Flash must also read from the beginning (it does not remember that it spoke earlier) |
| Flash returns 400, then you switch to GPT-4o | 5,900 | 5,900 | Another round of input |
| GPT returns 600, then you switch back to Sonnet | 6,500 | 6,500 | Sonnet handled an earlier message, but pi-web does not make it “remember”; it still rereads the conversation |
| Total switching cost | — | 22,900 input tokens | Output tokens are not included |
By comparison, if you use Flash throughout, the input grows with each new turn, but there is no extra “rereading” caused by a switch. The cost of switching comes from giving the earlier conversation to a new model.
Switch models, start a new Session, or fork: how to choose
The model selector is not the only way to hand a conversation to a different model. In practice, you can choose from three actions, each with a different purpose:
| Action | What happens to the earlier conversation | Does the new model know the context? | When to use it |
|---|---|---|---|
| Switch models | The complete conversation remains in the same Session | Yes (it reads the entire Session as input) | Another model should continue the same topic, such as reviewing an answer or exploring it in more depth |
| Start a new Session (+ New session) | The old conversation remains in the list on the left, but the new conversation is blank | No (it starts completely from scratch) | You are changing to an unrelated topic, or you want a clean answer that is not influenced by the earlier conversation |
| Fork the Session (Chapter 8) | A complete copy branches from the current message | Yes (the new branch contains everything before the fork point) | You want to try a different answer, compare A/B results, or preserve the original conversation while taking another path |
Here is how those options differ when you are buying an air conditioner:
- Switch models: You ask Flash, “What air-conditioner capacity should I choose for a living room with a floor area of 6 ping?” It recommends 1 ton. You switch to Claude and ask, “Please review this recommendation.” Claude continues in the same conversation.
- Start a new Session: Flash answers your question, you are satisfied, and you finish. Three days later, you want to ask, “How should I compare air-conditioner noise?” That is separate from the earlier floor-area discussion, so a new Session is cleaner.
- Fork: You want both Flash’s and Claude’s views on whether 1 ton is enough, but you do not want to lose the Flash branch. Fork the Session, switch to Claude in the fork, send the same question, and compare the two windows side by side.
Some switches can fail invisibly: thinking blocks may be lost
Chapter 12 explained that Anthropic’s Claude uses “native thinking blocks.” These blocks are structured data in the model’s response, not just text. OpenAI-compatible providers such as GLM, DeepSeek, Groq, and OpenRouter do not use that structure; they provide plain-text answers.
This creates an easy trap. When you switch from Claude to any OpenAI-compatible model, Claude’s earlier native thinking blocks cannot be inserted into the new provider’s messages array in their original format. Depending on how your version of pi-web serializes the transcript, the entire block may be discarded or flattened into plain text before the main response. Both behaviors have existed. In practice, assume that the new model’s context is not identical to the context Claude had. If the earlier conversation depends heavily on that reasoning, such as a message that says, “Continue with the steps you just considered,” the new model may produce a confusing answer.
| Switch path | Are thinking blocks preserved? | Recommended approach |
|---|---|---|
| Claude → Claude (switching to another Claude model) | Yes | You can switch directly |
| Claude → GLM / DeepSeek / GPT / any OpenAI-compatible model | The structured fields cannot be preserved (the entire block may be discarded or flattened into plain text before the main response, depending on the version) | If the conversation depends on that reasoning, fork the Session instead of switching directly. Alternatively, ask Claude to state its reasoning explicitly in the main response before you switch |
| GLM reasoning content → Claude | The reasoning is plain text, so Claude can read it (but its format differs from Claude’s native reasoning and may be treated as ordinary prose) | This usually works; Claude treats it as earlier context |
| Any reasoning model → non-reasoning model | The reasoning content remains, but the new model does not start its own reasoning process | That is fine; the new model simply does not perform another round of reasoning |
Keyboard and mouse tips for faster switching
If you switch models frequently, perhaps because draft-then-review is part of your daily workflow, these tips reduce mouse movement:
- Type to search in the selector: The model selector has a search field at the top; pi-web implements it as a Command combobox. Type “son” to filter the list to Sonnet models, then press Enter to select one. Your hands can stay on the keyboard.
- Cmd/Ctrl+K opens the command palette: Pi-web’s built-in command palette currently handles Skill and extension commands, such as
/skilland/help. It is not a quick model switcher, and there is no official “Cmd+K to switch models” shortcut. To switch quickly, open the selector and type as described above. - Give models short names: In
~/.pi/agent/models.json, thenamefield of each model entry supplies its display name; Chapter 6 shows this JSON structure. You can edit the file directly and change"name": "Claude Sonnet 4.5"to"name": "deep". The selector will then display the short name. The current UI has no alias field, so you must edit the JSON manually. - Set the default model: Pi-web reads
~/.pi/agent/settings.jsonand uses itsdefaultModel/defaultProvidervalues to choose the default model. You can also force a model with thePI_WEB_DEFAULT_MODELenvironment variable; see Appendix A. The composer selector currently has no “Set as default” button. To change the default, edit settings.json or the environment variable, then refresh your browser. A fast, low-cost model makes a practical default for everyday conversations. - Hide models you do not use: After you connect 5-6 providers, the selector can become long. In the Models panel, use provider visibility to hide an entire provider or deselect individual models, which updates the
hiddenModelslist. You can also usePI_WEB_HIDE_PROVIDERSto hide entire providers through an environment variable.
Common model-switching pitfalls
-
The selector appears to do nothing, and the old model still responds
Check three places: (a) Look at the model selector’s label. If it has not changed to the model you selected, the switch did not happen; you may have clicked outside the list. (b) Check the message you sent. Its upper-right corner normally identifies the model. If it still shows the old model, the switch had not taken effect when you sent it. (c) Press F12 to open your browser’s developer tools, then inspect the Console for a red error such as
models.json parse error. If you see one, the model configuration file is invalid; return to the Models panel and save it again. -
The AI suddenly answers in another language after the switch
Some providers’ models, especially Anthropic Claude and OpenAI GPT, may prefer a different default language. After switching, the model may answer in that language even if you asked your question in English. Add “Please respond in English” explicitly to your first message after the switch. The Session should then continue in English. That is more economical than switching back to a model whose language behavior you prefer.
-
You see “402 Payment Required” or “insufficient balance” after switching
A 402 means that provider has no credit left. Check the error for the provider name, such as
anthropic: insufficient credits. You have two options: (1) Add credit in that provider’s official dashboard. (2) Switch back to a provider that still has credit. Your conversation is still there. Reenter the message that failed to send. You will not be charged again for earlier messages. Chapter 22 covers this type of error in more detail. -
Earlier thinking blocks disappear, or the AI gives an unrelated answer
This is the issue described in the warning above: native thinking blocks cannot cross provider boundaries in their original format. If you switch from Claude to GLM or DeepSeek, Claude’s structured thinking blocks do not look the same in the new provider’s context. They may be missing or flattened into plain text, so the new model may not see what you expect. This is normal behavior, not a bug. Copy the critical reasoning into a new message as context, or fork the Session instead of switching next time.
-
No models from another provider appear in the selector
You have not added that provider in the Models panel. Follow the process in Chapter 6: select Models → Add Provider in the upper toolbar, choose a provider, enter its baseUrl and API key, select Test and wait for a green result, then save. Return to the composer; the selector will now include that provider’s models.
-
The selector contains too many models to find the one you need
After you connect 5-6 providers, the selector can easily contain 30-50 models. You have three options: (a) Open the selector and type part of the model name in its search field. Pi-web’s Command combobox searches every model ID. (b) In the Models panel, use provider visibility to hide an entire provider or deselect individual models; this updates the
hiddenModelslist. You can also setPI_WEB_HIDE_PROVIDERS=xxx,yyyin the environment to hide providers directly. (c) In~/.pi/agent/models.json, shorten each model’snamefield. For example, rename “Claude Sonnet 4.5” to “Deep” so it is easier to find.
FAQ
Will switching too many times in one Session cause a problem?
Does switching models affect conversation quality? Could the new model answer worse?
Which model is the default? What does Pi Agent use if I have not selected one?
~/.pi/agent/settings.json, specifically its defaultModel and defaultProvider values. You can also force those values with the PI_WEB_DEFAULT_MODEL and PI_WEB_DEFAULT_PROVIDER environment variables; Appendix A lists the related variables. The upstream pi-web composer currently has no “Set as default” button. To change the default, edit settings.json or the environment variables, then refresh the page. If you have never configured a default, pi-web normally uses the value already written to ~/.pi/agent/settings.json by the pi CLI. If there is still no value, it treats the model as unspecified and prompts you to choose one.