BerriAI/litellm · error · ValueError

Azure Content Safety: guardrail_name is required

Error message

Azure Content Safety: guardrail_name is required

What it means

Init guard for Azure Content Safety: the guardrail config entry lacks guardrail_name, which is needed to register and look up the callback instance.

Source

Thrown at litellm/proxy/guardrails/guardrail_hooks/azure/__init__.py:24

from .text_moderation import AzureContentSafetyTextModerationGuardrail

if TYPE_CHECKING:
    from litellm.types.guardrails import Guardrail, LitellmParams


def initialize_guardrail(litellm_params: "LitellmParams", guardrail: "Guardrail"):
    import litellm

    if not litellm_params.api_key:
        raise ValueError("Azure Content Safety: api_key is required")
    if not litellm_params.api_base:
        raise ValueError("Azure Content Safety: api_base is required")

    azure_guardrail: Final = litellm_params.guardrail.split("/")[1]

    guardrail_name: Final = guardrail.get("guardrail_name")
    if not guardrail_name:
        raise ValueError("Azure Content Safety: guardrail_name is required")

    if azure_guardrail == "prompt_shield":
        azure_content_safety_guardrail: (
            AzureContentSafetyPromptShieldGuardrail | AzureContentSafetyTextModerationGuardrail
        ) = AzureContentSafetyPromptShieldGuardrail(
            guardrail_name=guardrail_name,
            **{
                **litellm_params.model_dump(exclude_none=True),
                "api_key": litellm_params.api_key,
                "api_base": litellm_params.api_base,
                "default_on": litellm_params.default_on,
                "event_hook": litellm_params.mode,
            },
        )
    elif azure_guardrail == "text_moderations":
        azure_content_safety_guardrail = AzureContentSafetyTextModerationGuardrail(
            guardrail_name=guardrail_name,
            **{

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Set guardrail_name in the Azure Content Safety guardrail config.

Example fix

guardrail_name: azure_content_safety
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/guardrails/guardrail_hooks/azure/__init__.py:24 when the library encounters an invalid state.

Common situations: Azure Content Safety guardrail missing the guardrail_name field.


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