BerriAI/litellm · error · HTTPException

semantic_guard_violation

semantic_guard_violation

Error message

Request blocked by semantic guardrail '{guardrail.guardrail_name}'. Matched route: {route_name}

What it means

Error "Request blocked by semantic guardrail '{guardrail.guardrail_name}'. Matched route: {route_name}" thrown in BerriAI/litellm.

Source

Thrown at litellm/proxy/guardrails/guardrail_hooks/semantic_guard/semantic_guard.py:235

    detection_info: Final = {
        "route_name": route_name,
        "similarity_score": similarity_score,
        "guardrail": guardrail.guardrail_name,
    }

    verbose_logger.warning(
        "SemanticGuard match: route=%s, score=%s, action=%s", route_name, similarity_score, guardrail.on_flagged_action
    )

    if guardrail.on_flagged_action == "passthrough":
        guardrail.raise_passthrough_exception(
            violation_message=violation_msg,
            request_data=data,
            detection_info=detection_info,
        )
    else:
        raise HTTPException(  # pyright: ignore[reportOptionalCall]  # fastapi is installed wherever this proxy hook runs
            status_code=400,
            detail={
                "error": violation_msg,
                "route": route_name,
                "similarity_score": similarity_score,
                "type": "semantic_guard_violation",
            },
        )

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Rephrase the request so it does not match the blocked semantic route.
  2. Remove or adjust the matched route in the guardrail configuration if it blocks legitimate traffic.

When it happens

Trigger: Thrown at litellm/proxy/guardrails/guardrail_hooks/semantic_guard/semantic_guard.py:235 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/36276e74f6dab87d. Report an issue: GitHub.