All posts

How does Lyzr’s LLM gateway reduce token costs by routing between open-weight and frontier models?

How does Lyzr's LLM gateway reduce token costs by routing between open-weight and frontier models?

Nirupam3 min read
How does Lyzr’s LLM gateway reduce token costs by routing between open-weight and frontier models?

Got a use case in mind?

8 weeks from use case to agents running in production.

Platform, people and FDEs, all in. Bring your environment. We'll co-build and stay until it's live.

Talk to Us

Free resource

101 AI Agents Use Cases

100+ production-ready AI agent use cases across Marketing, Sales, HR, Banking, Insurance, Operations and a lot more

Download now

Using a powerful frontier model for every single agent task is an expensive habit.

It’s like using a sledgehammer to crack a nut.

Lyzr's LLM gateway reduces these token costs by routing tasks to the cheapest, simplest model that can reliably complete them. It uses a less expensive "shadow" model to attempt the task first, only escalating to a frontier model when necessary.

This is all managed within OpenController by Lyzr, the control plane for enterprise AI agents. OpenController is Lyzr's answer to the governance problem in production AI: a single layer to observe, control, and secure agents between development and deployment.

How Smart Routing Works

The process is a simple, automated cascade designed to save costs without sacrificing quality.

A single request passes through the gateway to a shadow open-weight model, a quality check, and then either returns or escalates to a frontier model.
  1. An agent task arrives at the OpenController gateway.

  2. Instead of going straight to an expensive model like GPT-4 or Claude 3, the request is first routed to a smaller, faster, cheaper open-weight model. This is the "shadow LLM."

  3. The gateway evaluates the shadow LLM's output against a predefined quality threshold. This could be a set of rules, a classifier model, or other validation logic.

  4. If the output meets the quality bar, the task is complete. The response is returned, and you've just paid a fraction of the cost of a frontier model call.

  5. If the output fails the quality check, the gateway automatically discards it and re-routes the original, unmodified task to the designated frontier model.

  6. The frontier model's high-quality output is then returned to the user. The cost is higher for this single task, but you only incurred it because it was proven necessary.

This ensures you always get a reliable result while defaulting to the most cost-effective path.

You Can't Control What You Don't See

This entire cost-saving mechanism depends on observability.

A trace record for one request lists the first model tried, the quality check result, the final model used and the token cost of each step.

If you can't see the routing decisions, you can't measure the savings or tune the performance.

OpenController provides a complete, end-to-end trace for every request that passes through the gateway.

This trace shows you which model was attempted first, whether the quality check passed or failed, which model was used for the final output, and the associated token costs for each step.

It gives platform teams the hard data needed to prove ROI and refine routing strategies. This is the same observability system that allows you to get a single end-to-end trace when an agent calls multiple sub-agents as tools.

The "Six Sigma" Principle of Quality

The mention of "Six Sigma" in this context is an analogy for process control.

A comparison shows weak answers reaching users without a quality threshold versus the gateway enforcing a user-defined threshold so only acceptable answers get through.

It's not about literal statistical methodologies. It's about defining what "good" looks like for a given task and then building a system that reliably delivers it.

In OpenController, you define the quality threshold.

You decide the criteria that a cheaper model's output must meet to be considered acceptable.

The gateway simply enforces your standard, request by request. This prevents low-quality or incomplete answers from ever reaching the end-user, building trust in the agent's reliability while the system works to minimize costs in the background.

The Takeaway

True cost control isn't just about choosing cheaper models. It's about building an intelligent system that automatically chooses the right model for every individual task, based on rules you define.

OpenController provides that system. Let's talk about how it fits your stack.

Want to see how it fits your stack? Talk to us about OpenController by Lyzr.

Got a use case in mind?

8 weeks from use case to agents running in production.

Platform, people and FDEs, all in. Bring your environment. We'll co-build and stay until it's live.

Talk to Us

Free resource

101 AI Agents Use Cases

100+ production-ready AI agent use cases across Marketing, Sales, HR, Banking, Insurance, Operations and a lot more

Download now

Continue reading

You might also like

Build with Lyzr

Try it in Agent Studio

From framework-agnostic design to production-grade agents, deployed in under 24 hours.