{"record":{"id":"c50d93d2fd57d080","repo":"BerriAI/litellm","slug":"azureexception-badrequesterror-message","errorCode":null,"errorMessage":"AzureException BadRequestError - {message}","messagePattern":"AzureException BadRequestError - (.+?)","errorType":"exception","errorClass":"BadRequestError","httpStatus":400,"severity":"error","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":1954,"sourceCode":"            \"This error occurs when load balancing Responses API across deployments with different API keys.\\n\"\n            \"   Encrypted content is tied to the organization that created it and cannot be decrypted by other organizations.\\n\\n\"\n            \"   Solution: Enable 'encrypted_content_affinity' to route follow-up requests to the correct deployment:\\n\\n\"\n            \"   router_settings:\\n\"\n            \"     enable_pre_call_checks: true\\n\"\n            \"     optional_pre_call_checks:\\n\"\n            \"       - encrypted_content_affinity\\n\\n\"\n            \"   Learn more: https://docs.litellm.ai/docs/response_api#encrypted-content-affinity-multi-region-load-balancing\"\n        )\n        raise BadRequestError(\n            message=helpful_message,\n            llm_provider=\"azure\",\n            model=model,\n            litellm_debug_info=extra_information,\n            response=getattr(original_exception, \"response\", None),\n            body=getattr(original_exception, \"body\", None),\n        )\n    elif \"invalid_request_error\" in error_str and getattr(original_exception, \"status_code\", None) in (None, 400):\n        raise BadRequestError(\n            message=f\"AzureException BadRequestError - {message}\",\n            llm_provider=\"azure\",\n            model=model,\n            litellm_debug_info=extra_information,\n            response=getattr(original_exception, \"response\", None),\n            body=getattr(original_exception, \"body\", None),\n        )\n    elif \"The api_key client option must be set either by passing api_key to the client or by setting\" in error_str:\n        raise AuthenticationError(\n            message=f\"{exception_provider} AuthenticationError - {message}\",\n            llm_provider=custom_llm_provider,\n            model=model,\n            litellm_debug_info=extra_information,\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"Connection error\" in error_str:\n        raise APIConnectionError(\n            message=f\"{exception_provider} APIConnectionError - {message}\",","sourceCodeStart":1936,"sourceCodeEnd":1972,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/litellm_core_utils/exception_mapping_utils.py#L1936-L1972","documentation":"Error \"AzureException BadRequestError - {message}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:1954 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the Azure request per the error message (often deployment name, api_version, or parameters)."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}