# Pin the model agents run — plan on one, execute on another

> Force a specific model for agent runs and split plan mode from execution: ingress allowlist + catch-all model mapping + plan-mode script switch, so developers can't route simple tasks to Opus.

Canonical: https://www.gatellm.io/use-cases/enforce-model-policy/

Neutralize client-side model choice, then split plan mode from execution so a strong model plans and a cheap model executes.

## What the community actually complains about
"Our devs flip Claude Code to Opus to summarize a changelog," "everyone has a different model in their settings and we can't see who spent what," "we tried a client-side policy, but anyone can just edit it back."
Model choice is a cost decision, not a developer preference — it has to be enforced at the gateway, where the request actually lands.

## How GateLLM does it
Three layers, none skippable: the key group's models allowlist (ingress gate) rejects unauthorized model names with 403; a catch-all model mapping from "*" rewrites whatever the client requests to the sanctioned model; and a before-slot script keeps plan mode on the strong model and switches to the execution model on exit.
Bypass requests — like Claude Code's conversation-title generation — carry no plan marker, so they fall through to the cheap execution model. That is exactly the "don't run Opus on a summary" behavior you wanted.

## 5 levers that actually land
- Ingress gate: the key group's models allowlist rejects any unauthorized model name before routing
- Catch-all mapping: from "*" → to the sanctioned model normalizes every requested name to one model
- Plan/exec split: a before-slot script reads the plan-mode markers and switches routing only after exiting plan
- Observable: switched requests get an SW tag in the logs, so every request's real landing model is auditable
- Hot-reload: mappings and rules take effect immediately — no restart, no per-developer rollout

## FAQ
### Why not use a declarative switch-route rule for plan mode?
switch-route predicates only do structural existence and small-value equality — they never read the content of a string value, which is what keeps large bodies on disk. The plan-mode marker lives in the message text, so it needs the before-slot script; structural checks (image → vision model) are where switch-route shines.

### Can a client still pick Opus by editing its own settings?
No. The ingress gate 403s any model name outside the allowlist, and the catch-all mapping normalizes whatever remains to the sanctioned model. Model choice stops being a client decision the moment the request reaches the gateway.

### The script seems to have no effect and logs show no error?
Each script runs in its own QuickJS sandbox with a 64MB heap cap (SCRIPT_MEMORY_LIMIT_MB). On out-of-memory the default log-and-continue mode silently drops all side effects — including useModel — so the routing just doesn't switch. Claude Code's tool definitions consume memory first; raise the limit (a restart is required).

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

## Related use cases
- [No model choice on the client: the gateway tiers automatically](https://www.gatellm.io/use-cases/automatic-model-tiering.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)
- [No Model Choice on the Client](https://www.gatellm.io/use-cases/automatic-model-tiering.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)
