BerriAI/litellm · error · ValueError

SemanticGuard requires llm_router for embeddings. Configure

Error message

SemanticGuard requires llm_router for embeddings. Configure a model_list with an embedding model.

What it means

Error "SemanticGuard requires llm_router for embeddings. Configure a model_list with an embedding model." thrown in BerriAI/litellm.

Source

Thrown at litellm/proxy/guardrails/guardrail_hooks/semantic_guard/__init__.py:45

    llm_router: Optional["Router"] = None,
):
    """
    Initialize the Semantic Guard guardrail.

    Args:
        litellm_params: Guardrail configuration parameters
        guardrail: Guardrail metadata
        llm_router: LiteLLM Router instance (required for embeddings)

    Returns:
        Initialized SemanticGuardrail instance
    """
    guardrail_name: Final = guardrail.get("guardrail_name")
    if not guardrail_name:
        raise ValueError("SemanticGuard: guardrail_name is required")

    if llm_router is None:
        raise ValueError(
            "SemanticGuard requires llm_router for embeddings. Configure a model_list with an embedding model."
        )

    semantic_guardrail: Final = SemanticGuardrail(
        guardrail_name=guardrail_name,
        llm_router=llm_router,
        embedding_model=getattr(litellm_params, "embedding_model", None) or DEFAULT_SEMANTIC_GUARD_EMBEDDING_MODEL,
        similarity_threshold=getattr(litellm_params, "similarity_threshold", None)
        or DEFAULT_SEMANTIC_GUARD_SIMILARITY_THRESHOLD,
        route_templates=getattr(litellm_params, "route_templates", None),
        custom_routes_file=getattr(litellm_params, "custom_routes_file", None),
        custom_routes=getattr(litellm_params, "custom_routes", None),
        on_flagged_action=getattr(litellm_params, "on_flagged_action", "block"),
        event_hook=litellm_params.mode,
        default_on=litellm_params.default_on or False,
    )

    litellm.logging_callback_manager.add_litellm_callback(semantic_guardrail)

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Add an embedding model to the proxy model_list so llm_router can compute embeddings.
  2. Pass a configured llm_router instance when initializing SemanticGuard.

When it happens

Trigger: Thrown at litellm/proxy/guardrails/guardrail_hooks/semantic_guard/__init__.py:45 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/6ef71bc71e00004b. Report an issue: GitHub.