BerriAI/litellm · error · ValueError

Azure Content Safety: {azure_guardrail} is not a valid guard

Error message

Azure Content Safety: {azure_guardrail} is not a valid guardrail

What it means

Dispatch guard in the Azure Content Safety initializer: the path segment after 'azure/' in litellm_params.guardrail is neither prompt_shield nor text_moderations, so no handler class matches.

Source

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

                "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,
            **{
                **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,
            },
        )
    else:
        raise ValueError(f"Azure Content Safety: {azure_guardrail} is not a valid guardrail")

    litellm.logging_callback_manager.add_litellm_callback(azure_content_safety_guardrail)
    return azure_content_safety_guardrail


guardrail_initializer_registry: Final = {
    SupportedGuardrailIntegrations.AZURE_PROMPT_SHIELD.value: initialize_guardrail,
    SupportedGuardrailIntegrations.AZURE_TEXT_MODERATIONS.value: initialize_guardrail,
}


guardrail_class_registry: Final = {
    SupportedGuardrailIntegrations.AZURE_PROMPT_SHIELD.value: AzureContentSafetyPromptShieldGuardrail,
    SupportedGuardrailIntegrations.AZURE_TEXT_MODERATIONS.value: AzureContentSafetyTextModerationGuardrail,
}

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Use a supported Azure guardrail type (e.g. prompt_shield or text moderation).

Example fix

Set the guardrail to a valid Azure Content Safety guardrail name.
Defensive patterns

Strategy: validation

When it happens

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

Common situations: An unrecognized Azure guardrail type was configured.


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