BerriAI/litellm · error · ValueError

SemanticGuard: unknown route template '{template_name}'. Ava

Error message

SemanticGuard: unknown route template '{template_name}'. Available templates: {SemanticGuardRouteLoader.list_builtin_templates()}

What it means

Error "SemanticGuard: unknown route template '{template_name}'. Available templates: {SemanticGuardRouteLoader.list_builtin_templates()}" thrown in BerriAI/litellm.

Source

Thrown at litellm/proxy/guardrails/guardrail_hooks/semantic_guard/route_loader.py:34

if TYPE_CHECKING:
    from semantic_router.routers import SemanticRouter
    from semantic_router.routers.base import Route

    from litellm.router import Router


ROUTE_TEMPLATES_DIR: Final = os.path.join(os.path.dirname(__file__), "route_templates")


class SemanticGuardRouteLoader:
    """Loads route definitions from YAML templates and custom configs, builds SemanticRouter."""

    @staticmethod
    def load_builtin_template(template_name: str) -> dict[str, Any]:
        """Load a built-in route template YAML by name."""
        file_path: Final = os.path.join(ROUTE_TEMPLATES_DIR, f"{template_name}.yaml")
        if not os.path.exists(file_path):
            raise ValueError(
                f"SemanticGuard: unknown route template '{template_name}'. "
                f"Available templates: {SemanticGuardRouteLoader.list_builtin_templates()}"
            )
        with open(file_path, "r") as f:
            return yaml.safe_load(f)

    @staticmethod
    def list_builtin_templates() -> list[str]:
        """List available built-in template names."""
        templates: Final = []
        if os.path.isdir(ROUTE_TEMPLATES_DIR):
            for fname in os.listdir(ROUTE_TEMPLATES_DIR):
                if fname.endswith(".yaml"):
                    templates.append(fname.replace(".yaml", ""))
        return sorted(templates)

    @staticmethod
    def load_custom_routes_file(file_path: str) -> list[dict[str, Any]]:

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Use one of the available built-in route templates listed in the error message.
  2. Define the route in a custom routes file instead of referencing an unknown template.

When it happens

Trigger: Thrown at litellm/proxy/guardrails/guardrail_hooks/semantic_guard/route_loader.py:34 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/93161c4f407d9a5b. Report an issue: GitHub.