{"record":{"id":"b40a8a4f46dbeb49","repo":"BerriAI/litellm","slug":"contextwindowexceedederror-exception-provider","errorCode":null,"errorMessage":"ContextWindowExceededError: {exception_provider} - {message}","messagePattern":"ContextWindowExceededError: (.+?) - (.+?)","errorType":"exception","errorClass":"ContextWindowExceededError","httpStatus":400,"severity":"error","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":298,"sourceCode":"            \"openai.OpenAIError\",\n            f\"{custom_llm_provider}.{custom_llm_provider}Error\",\n        )\n    if custom_llm_provider == \"openai\":\n        exception_provider = \"OpenAI\" + \"Exception\"\n    else:\n        exception_provider = custom_llm_provider[0].upper() + custom_llm_provider[1:] + \"Exception\"\n\n    if ExceptionCheckers.is_error_str_rate_limit(\n        error_str, status_code=getattr(original_exception, \"status_code\", None)\n    ):\n        raise RateLimitError(\n            message=f\"RateLimitError: {exception_provider} - {message}\",\n            model=model,\n            llm_provider=custom_llm_provider,\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif ExceptionCheckers.is_error_str_context_window_exceeded(error_str):\n        raise ContextWindowExceededError(\n            message=f\"ContextWindowExceededError: {exception_provider} - {message}\",\n            llm_provider=custom_llm_provider,\n            model=model,\n            response=getattr(original_exception, \"response\", None),\n            litellm_debug_info=extra_information,\n        )\n    elif \"invalid_request_error\" in error_str and \"model_not_found\" in error_str:\n        raise NotFoundError(\n            message=f\"{exception_provider} - {message}\",\n            llm_provider=custom_llm_provider,\n            model=model,\n            response=getattr(original_exception, \"response\", None),\n            litellm_debug_info=extra_information,\n        )\n    elif \"A timeout occurred\" in error_str:\n        raise Timeout(\n            message=f\"{exception_provider} - {message}\",\n            model=model,","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/exception_mapping_utils.py#L280-L316","documentation":"Exception-mapping branch: when the provider error string matches context-window-exceeded heuristics, the original exception is re-raised as litellm ContextWindowExceededError, signaling the request (prompt + max_tokens) exceeds the model's context length.","triggerScenarios":"Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:298 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The input exceeds the model's context window; shorten the prompt/messages.","Switch to a model with a larger context window or enable truncation/summarization."],"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"}