Code questions and short factual questions put different demands on a chat model. AnythingLLM's model router sends matching prompts to a chosen model while a fallback model handles other messages.
Calculated rules compare message content or other properties without an extra LLM classification call. Keyword matching fits a known term in the prompt; it does not estimate how difficult a question is.
Start with an existing workspace, permission to edit instance and workspace settings, and a working Ollama connection with two downloaded chat models. Assigning a router changes which model handles subsequent prompts for everyone using that workspace.
Steps to create a model router in AnythingLLM with Ollama:
- Open AnythingLLM's settings with the wrench icon at the bottom of the sidebar.

- Expand AI Providers in the settings sidebar.

- Open Model Router under AI Providers.

- Click New Router.

- Enter
Prompt Routerin Name.
The router name can be any unused name. Primary Provider & Model should already show Ollama from the system provider settings.
- Select your smaller chat model under Primary Provider & Model.
This is the fallback when no rule matches. The screenshots use installed models named small-chat:latest and code-chat:latest; your downloaded models can have different names. The fallback is small-chat:latest and the rule will use code-chat:latest.
- Set Cache Cooldown (seconds) to
0.
The default is 300 seconds. A positive cooldown keeps the last matched model active for non-matching follow-ups within that window. Zero disables this sticky routing so the fallback can answer the next non-matching prompt.
- Click Create Router.

- Open Prompt Router from the saved router list.

- Click New Rule.

- Enter
code_questionsin Title.
Rule Type starts at Calculated, which uses message properties rather than asking an LLM to classify the prompt.
- Select Prompt Content under Property.

- Set Comparator to contains.

- Enter
pythonin Value.
The match is case-insensitive. A prompt containing python will match this rule even when it is not asking for code.
- Select Ollama under Route to Provider & Model.

- Select your other chat model in the rule's model dropdown.
The screenshots select code-chat:latest, which must differ from the fallback model for the two routing results to be distinguishable.
- Click Create Rule.

- Return to workspaces with the back arrow at the bottom of the settings sidebar.

- Open your workspace's settings with its sidebar gear icon.
Router Desk is the existing workspace shown in the screenshots.
- Open the Chat Settings tab.

- Select Chat under Chat mode.
New workspaces start in Agent mode. Chat mode tests ordinary replies without entering an agent session.
- Open the Workspace LLM Provider menu.

- Select Model Router from the provider list.

- Select Prompt Router from Select a router.

- Reload Chat Settings after Saved appears.
The provider, router, and mode remain at Model Router, Prompt Router, and Chat after reload. A reverted selection means the settings were not retained.
- Return to the workspace chat with the back arrow above the settings tabs.

- Enter
Write one line of python that prints hello.in the message box.
- Send the prompt with the upward-arrow button.

- Confirm that the completed reply shows Routed to code-chat:latest via code_questions.
The model name must match your rule's selected model. The reply wording can vary; a model's claim about its own identity is not a routing check.
- Enter
Say hello.in the same conversation's message box.
This prompt does not contain python, so it does not match the rule.
- Send the greeting with the upward-arrow button.

- Hover over the completed greeting reply to reveal its model footer.

- Confirm that the greeting's footer names your fallback model.
The screenshots show small-chat:latest after the earlier reply used code-chat:latest. An error, an unfinished reply, or the rule model answering both prompts with cooldown zero means routing is not working as configured.