{"record":{"id":"70462b762bc6ed88","repo":"BerriAI/litellm","slug":"azureexception-contextwindowexceedederror-messa","errorCode":null,"errorMessage":"AzureException ContextWindowExceededError - {message}","messagePattern":"AzureException ContextWindowExceededError - (.+?)","errorType":"exception","errorClass":"ContextWindowExceededError","httpStatus":400,"severity":"error","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":1905,"sourceCode":"                if azure_error_code != \"content_policy_violation\":\n                    _inner: Final = body_dict[\"error\"].get(\"inner_error\") or body_dict[\"error\"].get(\"innererror\")\n                    if isinstance(_inner, dict) and _inner.get(\"code\") == \"ResponsibleAIPolicyViolation\":\n                        azure_error_code = \"content_policy_violation\"\n            else:\n                azure_error_code = body_dict.get(\"code\")\n    except Exception:\n        azure_error_code = None\n\n    if \"Internal server error\" in error_str:\n        raise litellm.InternalServerError(\n            message=f\"AzureException Internal server error - {message}\",\n            llm_provider=\"azure\",\n            model=model,\n            litellm_debug_info=extra_information,\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"This model's maximum context length is\" in error_str:\n        raise ContextWindowExceededError(\n            message=f\"AzureException ContextWindowExceededError - {message}\",\n            llm_provider=\"azure\",\n            model=model,\n            litellm_debug_info=extra_information,\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"DeploymentNotFound\" in error_str:\n        raise NotFoundError(\n            message=f\"AzureException NotFoundError - {message}\",\n            llm_provider=\"azure\",\n            model=model,\n            litellm_debug_info=extra_information,\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif azure_error_code == \"content_policy_violation\" or ExceptionCheckers.is_azure_content_policy_violation_error(\n        error_str\n    ):\n        from litellm.llms.azure.exception_mapping import (","sourceCodeStart":1887,"sourceCodeEnd":1923,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/exception_mapping_utils.py#L1887-L1923","documentation":"Azure-specific mapping: 'This model's maximum context length is' errors are re-raised as litellm ContextWindowExceededError, meaning the prompt exceeds the deployed Azure OpenAI model's context window.","triggerScenarios":"Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:1905 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the prompt/messages size to fit the Azure deployment's context window.","Use an Azure deployment with a larger context model."],"exampleFix":null,"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-23T08:17:48.524Z"}