The Problem

While working with Large Language Models, I noticed that applications often send every query to the same powerful model, regardless of how difficult the query is. This can increase API costs and response times, even when a simpler model could handle the task.

I wanted to explore whether we could make model selection smarter by choosing the most suitable LLM for each query instead of always relying on the most expensive option.

That idea led to OptiRoute AI.

How I Built It

I developed OptiRoute as an intelligent LLM routing framework that evaluates incoming queries and selects a suitable model based on quality, cost, latency, and privacy requirements.

I started by benchmarking 8 different LLMs across 1,887 queries from 26 benchmark sources. This resulted in 15,096 query-model evaluations across 5 capability classes.

Using this data, I developed lightweight logistic regression scoring models that estimate how suitable each LLM is for a given query. The router extracts 2,066 features from the input and makes its decision before sending the request to an LLM.

I also developed multiple routing modes:

  • Economy: Focuses on reducing API costs.
  • Balanced: Provides a balance between response quality and cost.
  • Speed: Prioritizes faster responses.
  • Quality: Prioritizes the strongest available model.
  • Private: Restricts sensitive queries to approved local models.

The project includes a backend API and an interactive React and TypeScript dashboard where users can explore routing decisions, compare models, and analyze performance.

Results

On a frozen test set of 282 queries, the learned routing approach achieved:

  • 84.04% accuracy compared with 88.65% for always using GPT-5.
  • 94.8% of GPT-5's measured quality.
  • 68.4% lower inference cost.
  • Approximately 11.4 ms median routing overhead.

The routing decision does not require an additional LLM API call.

Challenges and What I Learned

One of the biggest challenges was finding the right balance between response quality and cost. Choosing the cheapest model does not always produce good results, while always choosing the strongest model can make applications unnecessarily expensive.

I also had to build a reliable evaluation process, avoid data leakage between training and testing, and make sure that the deployed router produced consistent results with the research experiments.

Through this project, I gained practical experience in machine learning, model benchmarking, feature engineering, API development, multi-objective optimization, and building AI systems that consider real-world constraints.

What's Next?

I want to take OptiRoute further by exploring its integration into payment and financial applications, where intelligent model selection can help manage AI infrastructure costs while maintaining reliable responses.

My goal is to make AI applications more practical and affordable without unnecessarily compromising their quality.

Built With

Share this project:

Updates

Submission history