█

AI/TLDR

Buy me a coffee
Buy me a coffee

Semantic Router (Aurelio Labs)

Embedding-based decision layer that routes LLM and agent requests without an extra LLM call

Gateways & RoutingOpen source
Language
Python
License
MIT
$pip install -qU semantic-router
IN SHORT

What is Semantic Router (Aurelio Labs)?

Semantic Router (Aurelio Labs) is Embedding-based decision layer that routes LLM and agent requests without an extra LLM call. It sits in the Gateways & Routing category of the Evaluation & Production Ops tools and is open-source, written in Python and licensed MIT. To get started: install.

Overview

Semantic Router is an open-source Python library from Aurelio Labs that acts as a decision-making layer for LLMs and agents. Instead of asking another LLM which tool or path to take, it compares the meaning of an incoming request against a set of example phrases using vector embeddings, then picks the matching route.

It fits the gateway and routing category: you define named routes, each with a handful of example utterances, and the router decides which one a user query belongs to. Because the decision is a vector lookup rather than a generation, it returns quickly and avoids the latency and cost of an extra model call.

It is aimed at developers building chatbots and agents who need to branch on intent, enforce guardrails, or steer requests to different prompts or models. If a query matches no route, the router returns None, so you can fall back to default behavior.

What it does

  • Routes requests by semantic similarity using embeddings instead of an extra LLM call
  • Define decision paths as named Route objects, each with a list of example utterances
  • Pluggable encoders including OpenAI, Cohere, Hugging Face, and FastEmbed
  • Optional fully local execution with HuggingFaceEncoder and LlamaCppLLM
  • Vector index integrations with Pinecone and Qdrant for storing utterances
  • Supports dynamic routes for parameter generation and function calls, plus multi-modal routes

Getting started

Install the package, define your routes, pick an encoder, and create a router to start making decisions.

Install

Install Semantic Router from PyPI.

bashbash
pip install -qU semantic-router

Define routes

Each Route has a name and a list of example utterances that represent its intent.

pythonpython
from semantic_router import Route

politics = Route(
    name="politics",
    utterances=[
        "isn't politics the best thing ever",
        "why don't you tell me about your political opinions",
        "don't you just love the president",
    ],
)

chitchat = Route(
    name="chitchat",
    utterances=[
        "how's the weather today?",
        "how are things going?",
        "lovely weather today",
    ],
)

routes = [politics, chitchat]

Pick an encoder

Initialize an embedding model. The README shows Cohere and OpenAI encoders.

pythonpython
import os
from semantic_router.encoders import OpenAIEncoder

os.environ["OPENAI_API_KEY"] = "<YOUR_API_KEY>"
encoder = OpenAIEncoder()

Create the router and route a query

Build a SemanticRouter from the encoder and routes, then call it with a user query. It returns the matching route name, or None if nothing matches.

pythonpython
from semantic_router.routers import SemanticRouter

rl = SemanticRouter(encoder=encoder, routes=routes, auto_sync="local")

rl("don't you love politics?").name
# 'politics'

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Steer a chatbot to a different prompt based on whether a user wants chitchat, support, or another topic
  • Add a guardrail that detects and avoids certain conversation topics before they reach the model
  • Route requests to different tools, agents, or models without paying for an extra LLM decision call
  • Trigger function calls or parameter generation via dynamic routes when a query matches a known intent

How Semantic Router (Aurelio Labs) compares

Semantic Router (Aurelio Labs) alongside other open-source gateways & routing tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
OmniRoute★ 91.4kA local-first AI gateway that fronts hundreds of model providers with one OpenAI-compatible endpoint, quota-aware auto-fallback, many routing strategies and prompt compression.
Free Claude Code★ 74.7kA local proxy that points Claude Code, Codex, Pi, OpenCode, Cline and other agent CLIs at 50 free, paid, subscription or local model providers, with automatic failover and an admin UI.
LiteLLM★ 64.2kA Python SDK and proxy server that gives one OpenAI-compatible API to 100+ LLM providers, with cost tracking, budgets, fallbacks, rate limiting, and an admin UI.
Kong Gateway★ 44.4kA Lua/NGINX API gateway whose AI Gateway plugins put one universal endpoint in front of OpenAI, Anthropic, Gemini, Bedrock and other providers, with semantic routing, caching and MCP traffic governance.
magpie★ 43.7kMenu bar app and local gateway that lets Claude Code, Codex, Gemini CLI and dozens of other coding agents run on any provider's model, with routing groups that fail over across accounts when a quota runs out.
9Router★ 33kLocal OpenAI-compatible router for coding CLIs that tracks per-provider quota, falls back from subscription to cheap to free models, and compresses tool results to cut tokens.
Experiential★ 20.1kAn open-source gateway that puts hosted, BYOK, local and custom models behind one OpenAI-compatible API, with per-identity model and spend limits and routers fitted from your own traces.
Semantic Router (Aurelio Labs)★ 4.1kEmbedding-based decision layer that routes LLM and agent requests without an extra LLM call