← all repositories
aurelio-labs/semantic-router

Route AI requests by meaning, not slow LLM deliberation

Semantic Router replaces slow LLM generation with fast embedding similarity to decide where agent requests should go.

3.9k stars Python AgentsLLMOps · Eval
semantic-router
Velocity · 7d
+3.3
★ / day
Trend
steady
star history

What it does

Semantic Router is a decision layer that sits in front of LLMs and agents. You define routes—like politics or chitchat—by listing example utterances, and the library matches incoming queries to the closest semantic path using an encoder. If nothing fits, it returns None, acting like a bouncer that quietly turns away uninvited guests instead of bothering the main act.

The interesting bit

The clever part is that it treats routing as a pure embedding problem, skipping the token-generation bottleneck entirely. It also handles multi-modal inputs and can run fully offline with local encoders and LLMs, which is less common for orchestration layers that usually assume an OpenAI key.

Key highlights

  • Supports static routes (utterance matching) and dynamic routes that generate parameters for function calls.
  • Plugs into Cohere, OpenAI, Hugging Face, FastEmbed, and supports multi-modal routing.
  • Can persist route state to Pinecone or Qdrant rather than holding everything in memory.
  • Offers a local-only mode via HuggingFaceEncoder and LlamaCppLLM; the docs claim local Mistral 7B outperforms GPT-3.5 in most of their tests.
  • Includes threshold optimization and save/load utilities for production tuning.

Caveats

  • The README’s prose and code use RouteLayer and SemanticRouter interchangeably without explanation, suggesting the API surface is still shifting.
  • Several features—like the HybridRouteLayer and local execution—require extra dependency sets that are easy to miss.
  • The README notes “more encoders will be added soon,” so the current roster may feel narrow if your preferred provider isn’t listed.

Verdict

If your agents waste too much latency on simple “which tool?” decisions, this is a sensible drop-in filter. If your routing logic already requires heavy reasoning or branching conditionals, you will still need the LLM.

Frequently asked

What is aurelio-labs/semantic-router?
Semantic Router replaces slow LLM generation with fast embedding similarity to decide where agent requests should go.
Is semantic-router open source?
Yes — aurelio-labs/semantic-router is open source, released under the MIT license.
What language is semantic-router written in?
aurelio-labs/semantic-router is primarily written in Python.
How popular is semantic-router?
aurelio-labs/semantic-router has 3.9k stars on GitHub and is currently holding steady.
Where can I find semantic-router?
aurelio-labs/semantic-router is on GitHub at https://github.com/aurelio-labs/semantic-router.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.