{"record":{"id":"5b78a34d9b285ed6","repo":"BerriAI/litellm","slug":"azure-content-safety-api-base-is-required","errorCode":null,"errorMessage":"Azure Content Safety: api_base is required","messagePattern":"Azure Content Safety: api_base is required","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/guardrails/guardrail_hooks/azure/__init__.py","lineNumber":18,"sourceCode":"from typing import TYPE_CHECKING, Final\n\nfrom litellm.types.guardrails import SupportedGuardrailIntegrations\n\nfrom .prompt_shield import AzureContentSafetyPromptShieldGuardrail\nfrom .text_moderation import AzureContentSafetyTextModerationGuardrail\n\nif TYPE_CHECKING:\n    from litellm.types.guardrails import Guardrail, LitellmParams\n\n\ndef initialize_guardrail(litellm_params: \"LitellmParams\", guardrail: \"Guardrail\"):\n    import litellm\n\n    if not litellm_params.api_key:\n        raise ValueError(\"Azure Content Safety: api_key is required\")\n    if not litellm_params.api_base:\n        raise ValueError(\"Azure Content Safety: api_base is required\")\n\n    azure_guardrail: Final = litellm_params.guardrail.split(\"/\")[1]\n\n    guardrail_name: Final = guardrail.get(\"guardrail_name\")\n    if not guardrail_name:\n        raise ValueError(\"Azure Content Safety: guardrail_name is required\")\n\n    if azure_guardrail == \"prompt_shield\":\n        azure_content_safety_guardrail: (\n            AzureContentSafetyPromptShieldGuardrail | AzureContentSafetyTextModerationGuardrail\n        ) = AzureContentSafetyPromptShieldGuardrail(\n            guardrail_name=guardrail_name,\n            **{\n                **litellm_params.model_dump(exclude_none=True),\n                \"api_key\": litellm_params.api_key,\n                \"api_base\": litellm_params.api_base,\n                \"default_on\": litellm_params.default_on,\n                \"event_hook\": litellm_params.mode,","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/guardrails/guardrail_hooks/azure/__init__.py#L1-L36","documentation":"Init guard for Azure Content Safety guardrails: litellm_params.api_base is empty, so the regional Content Safety endpoint URL is unknown.","triggerScenarios":"Thrown at litellm/proxy/guardrails/guardrail_hooks/azure/__init__.py:18 when the library encounters an invalid state.","commonSituations":"Azure Content Safety guardrail configured without api_base.","solutions":["Provide the Azure Content Safety endpoint as api_base in the guardrail config."],"exampleFix":"api_base: https://<resource>.cognitiveservices.azure.com","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}