Chapter 13

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.

Concept: Switching models does not restart the conversation. It means that a different model answers from your next message onward. Every earlier message remains, and the new model reads the conversation in its own way.

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.
Tip: Selecting a model and sending a message are two separate actions. Nothing happens immediately after you choose a new model from the list. That is normal. The new model is called only after you type and send your next message. To confirm the switch, check that the text on the model button has changed.

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.

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

  2. 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, and actions.

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

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

  5. Compare the two responses and decide what to use

    Claude will often identify issues such as GLM using device_id instead of entity_id (a pitfall covered in Chapter 8), whether mode should be restart rather than the default single, 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.

  6. (Advanced) Switch back to GLM to apply Claude’s feedback

    After Claude reviews the draft, you can switch back to glm-4-flash and 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.

Tip: At the end of the conversation, the model name shown for that item in the Session list on the left may be the last model used. That is only a visual label; it does not mean that model handled the entire Session. Pi Agent records the model used for each message separately.

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
Concept: All three scenarios require you to choose deliberately which model answers each part. The costliest mistake is to keep using the most expensive model by reflex. You may assume the advanced model is better, but you are paying 10 times as much for work a low-cost model could handle.

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,0005,000Sonnet takes over for the first time
Sonnet returns 500 tokens, then you switch back to Flash5,5005,500Flash must also read from the beginning (it does not remember that it spoke earlier)
Flash returns 400, then you switch to GPT-4o5,9005,900Another round of input
GPT returns 600, then you switch back to Sonnet6,5006,500Sonnet handled an earlier message, but pi-web does not make it “remember”; it still rereads the conversation
Total switching cost22,900 input tokensOutput 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.

Warning: A long Session (more than 30 exchanges) combined with frequent model switches is one of the easiest ways to lose control of costs. You can save money in two ways: (1) Switch only when necessary. Decide which part truly needs another model. (2) If the conversation has become too long, ask the AI to “summarize the discussion above in 5 points.” Start a new Session, paste in the summary, and continue with a compressed context.

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.
Tip: A fork is cleaner than a switch, but it costs more because two Sessions grow independently. A switch is more continuous than a fork, but it can make it harder to trace which model produced each response later. Choose based on your goal.

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
Warning: An “invisible failure” produces no error message. The new model still responds, but its answer may be confusing because it missed critical information. If a response seems unrelated to your question, consider whether you just switched from Claude to a non-Claude model.

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 /skill and /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, the name field 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.json and uses its defaultModel/defaultProvider values to choose the default model. You can also force a model with the PI_WEB_DEFAULT_MODEL environment 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 hiddenModels list. You can also use PI_WEB_HIDE_PROVIDERS to hide entire providers through an environment variable.
Tip: These JSON and environment-variable methods reflect the current pi-web implementation. A later UI may add an alias field or a “Set as default” button. Use those controls if they appear. If you cannot find them in your version of pi-web, that does not mean anything is broken.

Common model-switching pitfalls

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

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

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

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

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

  6. 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 hiddenModels list. You can also set PI_WEB_HIDE_PROVIDERS=xxx,yyy in the environment to hide providers directly. (c) In ~/.pi/agent/models.json, shorten each model’s name field. 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?
It will not break the Session, but it can become expensive. As the “Hidden cost” section showed, each switch makes the new model reread the entire conversation as input tokens. If 10 messages have accumulated 5,000 tokens, switching 4 times adds 22,900 input tokens. Switching itself does not break the Session or trigger a rate limit. However, if the conversation exceeds that model’s context window, you will receive an explicit error. Your monthly bill may still rise noticeably. Switch only when necessary, or ask the AI for a concise summary and continue in a new Session.
Does switching models affect conversation quality? Could the new model answer worse?
It can affect the response, but the difference is usually style rather than a simple drop in quality. Each model reads conversations differently. Claude often reviews the entire conversation carefully and produces a structured answer. GPT tends to continue directly from the latest message. GLM tends to be concise. A response may feel different after a switch because the new model has a different style, not because it became less capable. Quality does fall if you switch to a model that lacks the required capability, such as moving a complex programming conversation from Sonnet to GLM-4-Flash. That is a model-selection problem, not an inherent problem with switching.
Which model is the default? What does Pi Agent use if I have not selected one?
The default comes from ~/.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.
Can Pi Agent automatically select the best model? I do not want to decide
Pi-web currently requires manual selection. It does not decide which provider should handle a question. This is deliberate: which model to use is the user’s choice, and the tool should not decide whose service you pay for. An auto-select Skill may appear in the future; Chapter 14 explains Skills. One might switch to Claude when it detects a code-review request, for example, but no official version exists yet. A practical approach is to set a fast, low-cost model as the default and switch manually when you need an advanced model. That covers 80% of everyday use.
Could switching models accidentally delete my earlier conversation?
No. Switching only determines which model answers your next message. It does not delete, edit, or rerun existing messages. Selecting + New session and switching models are two different actions. A new Session opens a blank conversation; switching models continues the current one with a different model. To clear a conversation, use the delete Session action described in Chapter 8. If you only switch models, every message remains.
What should I learn next?
You now know how to switch models, completing the section on using multiple AIs. You understand why you might connect several providers, what each of the six is best at, what reasoning means, and how to combine models. Continue to Chapter 14: What is a Skill? and learn how to teach an AI a specialized procedure. Skills are a core pi-web feature and another way, beyond draft-then-review workflows, to get more from AI.