{"record":{"id":"9e286ac2fb7e4b9c","repo":"BerriAI/litellm","slug":"anthropicerror-error-str","errorCode":null,"errorMessage":"AnthropicError - {error_str}","messagePattern":"AnthropicError - (.+?)","errorType":"exception","errorClass":"ContextWindowExceededError","httpStatus":400,"severity":"error","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":516,"sourceCode":"        )\n\n\ndef _map_anthropic_exception(\n    *,\n    model: str,\n    original_exception: _ProviderHTTPException,\n    custom_llm_provider: str,\n    error_str: str,\n    exception_type: str,\n    exception_provider: str,\n    extra_information: str,\n) -> None:\n    if (\n        \"prompt is too long\" in error_str\n        or \"prompt: length\" in error_str\n        or ExceptionCheckers.is_error_str_context_window_exceeded(error_str)\n    ):\n        raise ContextWindowExceededError(\n            message=f\"AnthropicError - {error_str}\",\n            model=model,\n            llm_provider=\"anthropic\",\n        )\n    elif \"overloaded_error\" in error_str or \"Overloaded\" in error_str:\n        raise InternalServerError(\n            message=f\"AnthropicError - {error_str}\",\n            model=model,\n            llm_provider=\"anthropic\",\n        )\n    if \"Invalid API Key\" in error_str:\n        raise AuthenticationError(\n            message=f\"AnthropicError - {error_str}\",\n            model=model,\n            llm_provider=\"anthropic\",\n        )\n    if \"content filtering policy\" in error_str:\n        raise ContentPolicyViolationError(","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/exception_mapping_utils.py#L498-L534","documentation":"Anthropic-specific mapping: prompt-length errors ('prompt is too long', 'prompt: length') from the Anthropic SDK are re-raised as litellm ContextWindowExceededError, meaning the prompt exceeds Anthropic's context limit.","triggerScenarios":"Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:516 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the Anthropic request parameters and API key against the error details.","Verify the model name is a valid Anthropic 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"}