# One Model on the Client: the Gateway Tiers Automatically

> Take model choice out of the client: one exposed model name, with the gateway tiering automatically by conversation state (plan vs execution) so a strong model plans and a cost-efficient model executes, with no per-machine config drift.

Canonical: https://www.gatellm.io/use-cases/automatic-model-tiering/

Take model choice out of the UI — the client exposes a single model name, planning runs on the strong model and execution lands on the cost-efficient one, tiered on the hop the request was already taking.

## What the community actually complains about
"Everyone has a different model in their settings and the same prompt comes out differently for two people," "the most common question in someone's first week is which model should I pick," "retiring a model means editing env vars on every dev machine." Model choice has been handed to the people with the least information to make it: they can't see their own spend, and they have no way to know whether this particular request deserves the strong model.
Drop everyone to a cheap model instead and the work degrades — hand planning and architecture judgment to a small model and the rework costs more than the savings. The split that actually matters is what this request is doing, planning or execution, and the client has never told the gateway that.

## How GateLLM does it
The client keeps a single model name; a catch-all mapping (from "*") on the gateway normalizes whatever name the client asks for, so editing personal settings no longer changes where the request lands. There is nothing left to explain about which model to pick.
The tiering signal is already in the conversation: Claude Code's plan mode injects Plan mode is active on entry and Exited Plan Mode on exit. A before-slot script scans backwards from the last message, takes the last marker seen to determine the current state, then calls context.useModel() to switch routing. The decision is a string-position comparison — no separate classification call, no extra network hop.
Tiering has to live in the before slot: the after slot sees the translated upstream body and cannot read the client-injected markers, and after-slot useModel only switches within the same protocol, while plan to execution is a cross-model route change. request_payload rules (prompt_cache_key and friends) must be configured on both models: the entry model keeps its own while planning, the target model's apply once the switch happens.

## 5 levers that actually land
- Single ingress name: the client exposes one model name and a from "*" catch-all mapping normalizes every requested name to one landing model
- Automatic tiering: a before-slot script takes the last marker scanning backwards — the entry marker stays in history forever, so a "contains" check reads the state as plan-mode permanently
- Protocol guard: the script checks context.sourceProtocol first and returns early for non-Anthropic traffic, so one entry model serving several clients never gets mis-routed
- Observable: an SW tag in the log model column marks a script switch and MM marks an identity mapping; statistics and billing attribute to the final model name, so every tiering decision is auditable
- Zero client rollout: config changes need no per-machine edits and mappings hot-reload (the one exception is the script heap cap SCRIPT_MEMORY_LIMIT_MB, which needs a restart)

## FAQ
### Can a client still pick its own model?
It can pick, but the pick no longer decides where the request lands: the catch-all mapping normalizes any requested name, and a script useModel is an admin-forced route change that is not bound by client permissions. Exposing a single name on the client is what removes the question entirely.

### Why not a dedicated model router or classifier?
Latency and shape. A separate router adds a hop and usually a classification call; here the tiering signal is marker text already present in the conversation, and the decision is a last-marker position comparison on the path the request was taking anyway. Protocol translation, auth and metering already live on the gateway — tiering does not need a second component to duplicate them.

### The script switched nothing and the logs show no error?
Most likely a script OOM: each script runs in its own QuickJS sandbox (heap cap SCRIPT_MEMORY_LIMIT_MB, 64MB by default) and on overflow the default log-and-continue mode silently drops all side effects, useModel included. Claude Code's dozens of tool definitions consume memory first — that floor cannot be removed at the script layer, so raise the cap (a restart is required). Check the SW tag in the log model column to confirm the switch.

- [Full how-to: switching models by plan mode (docs)](https://docs.gatellm.io/en/howto/script-switch-model-by-plan-mode)

## Related use cases
- [Enforce which model agents actually run: pin the model, split plan from execution](https://www.gatellm.io/use-cases/enforce-model-policy.md)

## Related
- [Home](https://www.gatellm.io/index.md)
- [Pricing](https://www.gatellm.io/pricing.md)
- [Cost Calculator](https://www.gatellm.io/calculator.md)
- [About](https://www.gatellm.io/about.md)
- [Book a Demo](https://www.gatellm.io/demo.md)
- [FAQ](https://www.gatellm.io/faq.md)
- [Compare AI Gateways](https://www.gatellm.io/compare.md)
- [Compare LiteLLM](https://www.gatellm.io/compare/litellm.md)
- [Compare OpenRouter](https://www.gatellm.io/compare/openrouter.md)
- [Compare Alibaba Cloud AI Gateway](https://www.gatellm.io/compare/alibaba-cloud.md)
- [Compare Azure API Management](https://www.gatellm.io/compare/azure-apim.md)
- [Compare Apigee](https://www.gatellm.io/compare/apigee.md)
- [Compare Cloudflare AI Gateway](https://www.gatellm.io/compare/cloudflare.md)
- [Compare Kong AI Gateway](https://www.gatellm.io/compare/kong.md)
- [Compare Portkey](https://www.gatellm.io/compare/portkey.md)
- [LiteLLM vs Kong AI Gateway](https://www.gatellm.io/compare/litellm-vs-kong.md)
- [LiteLLM vs OpenRouter](https://www.gatellm.io/compare/litellm-vs-openrouter.md)
- [LiteLLM vs Portkey](https://www.gatellm.io/compare/litellm-vs-portkey.md)
- [Use Cases](https://www.gatellm.io/use-cases.md)
- [Reduce LLM Cost](https://www.gatellm.io/use-cases/reduce-cost.md)
- [High Availability](https://www.gatellm.io/use-cases/high-availability.md)
- [Multi-Tenant Isolation](https://www.gatellm.io/use-cases/multi-tenant.md)
- [Compliance & Audit](https://www.gatellm.io/use-cases/compliance-audit.md)
- [Troubleshooting by Symptom](https://www.gatellm.io/use-cases/troubleshooting.md)
- [Mixed Multi-Vendor Model Stack](https://www.gatellm.io/use-cases/mixed-model-stack.md)
- [Self-Host AI Inside Office](https://www.gatellm.io/use-cases/self-hosted-office-ai.md)
- [Token Usage Visibility & Attribution](https://www.gatellm.io/use-cases/token-ops.md)
- [Token FinOps: AI Cost Allocation & Control](https://www.gatellm.io/use-cases/token-finops.md)
- [MCP Tool Governance](https://www.gatellm.io/use-cases/mcp-tool-governance.md)
- [Web Search for Every Model](https://www.gatellm.io/use-cases/web-search-grounding.md)
- [Multi-Key Rotation & Standby](https://www.gatellm.io/use-cases/multi-key-pooling.md)
- [Admission Control for Connected Clients](https://www.gatellm.io/use-cases/client-admission-control.md)
- [Enforce Which Model Agents Actually Run](https://www.gatellm.io/use-cases/enforce-model-policy.md)
- [One Protocol, Any Model](https://www.gatellm.io/use-cases/one-protocol-any-model.md)
- [Office / Microsoft 365 Add-in](https://www.gatellm.io/office-addin.md)
- [Glossary](https://www.gatellm.io/glossary.md)
- [Model Catalog](https://www.gatellm.io/models.md)
- [SDK & Framework Integrations](https://www.gatellm.io/integrations.md)
- [AI Coding Agents & Harnesses](https://www.gatellm.io/coding-agents.md)
- [Security & Compliance](https://www.gatellm.io/security.md)
- [Privacy Policy](https://www.gatellm.io/privacy-policy.md)
- [Terms of Service](https://www.gatellm.io/terms.md)
- [Cookie Policy](https://www.gatellm.io/cookies.md)
- [Data Processing Agreement (DPA)](https://www.gatellm.io/dpa.md)
- [Sub-processor List](https://www.gatellm.io/subprocessors.md)
- [Security Questionnaire (CAIQ/SIG/VSA)](https://www.gatellm.io/trust.md)
- [Incident Response & Support](https://www.gatellm.io/sla.md)
- [Vulnerability Disclosure Policy](https://www.gatellm.io/vulnerability-disclosure.md)
- [Open Source License Notice](https://www.gatellm.io/open-source-licenses.md)
- [Version Support & Lifecycle (EOL)](https://www.gatellm.io/lifecycle.md)
- [Engineering Blog](https://www.gatellm.io/blog.md)
- [Your Agents Have More Permissions Than Your Employees: Governing MCP Tools at the Gateway](https://www.gatellm.io/blog/mcp-tool-governance.md)
- [The $10k Invoice Problem: Five Ways to Cut LLM Spend Without Dumbing Down Your App](https://www.gatellm.io/blog/reduce-cost.md)
- [Your Vendor's List Price Is Not Your Cost: Applying Real FinOps to Token Spend](https://www.gatellm.io/blog/token-finops.md)
- [llms.txt](https://www.gatellm.io/llms.txt)
