{"record":{"id":"046e0c4cd9482188","repo":"BerriAI/litellm","slug":"azure-content-safety-api-key-is-required","errorCode":null,"errorMessage":"Azure Content Safety: api_key is required","messagePattern":"Azure Content Safety: api_key is required","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/guardrails/guardrail_hooks/azure/__init__.py","lineNumber":16,"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,","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/guardrails/guardrail_hooks/azure/__init__.py#L1-L34","documentation":"Init guard for Azure Content Safety guardrails: litellm_params.api_key is empty, so calls to the Content Safety endpoint cannot be authenticated.","triggerScenarios":"Thrown at litellm/proxy/guardrails/guardrail_hooks/azure/__init__.py:16 when the library encounters an invalid state.","commonSituations":"Azure Content Safety guardrail configured without an API key.","solutions":["Provide an api_key for Azure Content Safety via guardrail config or environment."],"exampleFix":"litellm_params:\n  api_key: os.environ/AZURE_CONTENT_SAFETY_KEY","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"}