{"record":{"id":"4e28009383242f27","repo":"BerriAI/litellm","slug":"exception-provider-message","errorCode":null,"errorMessage":"{exception_provider} - {message}","messagePattern":"\\{exception_provider\\} - \\{message\\}","errorType":"exception","errorClass":"NotFoundError","httpStatus":404,"severity":"error","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":306,"sourceCode":"    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,\n            llm_provider=custom_llm_provider,\n            litellm_debug_info=extra_information,\n        )\n    elif (\n        (\"invalid_request_error\" in error_str and \"content_policy_violation\" in error_str)\n        or (\"Invalid prompt\" in error_str and \"violating our usage policy\" in error_str)\n        or (\"request was rejected as a result of the safety system\" in error_str.lower())\n    ):","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/litellm_core_utils/exception_mapping_utils.py#L288-L324","documentation":"Normalized NotFoundError from the exception-mapping chain: the provider error string contains both 'invalid_request_error' and 'model_not_found', so litellm maps it to NotFoundError with the message '<Provider>Exception - <original message>'. It means the requested model does not exist for that API key/account/deployment.","triggerScenarios":"Calling a model name the key has no access to ('gpt-4o' on an org without access), typos in model names ('gpt-4o-mini ' with whitespace, 'gpt4o'), using a custom/in-house model name on a base URL where it isn't deployed, or referencing a fine-tune/deployment that was deleted.","commonSituations":"Model deprecated/renamed by the provider and old names kept in config; proxy deployments listing models the backing key can't see; typos or casing mistakes in model=; pointing at Azure with an OpenAI public model name (missing deployment mapping).","solutions":["Verify the exact model id against the provider's models endpoint (or litellm model_list/get_model_info) and correct model=.","For Azure, ensure the model maps to an existing deployment name; for the proxy, check model_list entries match what the key can access.","Remove stale hard-coded names; source them from a validated catalog or env var to avoid drift when providers rename models."],"exampleFix":"# before\nlitellm.completion(model=\"gpt-4o-mini-pro\", messages=m)  # typo -> NotFoundError\n\n# after\nlitellm.completion(model=\"gpt-4o-mini\", messages=m)\n# discover valid ids: litellm.model_list; openai client.models.list()","handlingStrategy":"type-guard","validationCode":"import litellm\n\ndef model_exists(model: str) -> bool:\n    return model in {m[\"model_name\"] for m in litellm.model_list} or model in litellm.model_cost.keys()","typeGuard":"from litellm import NotFoundError\n\ndef is_model_not_found(exc: BaseException) -> bool:\n    return isinstance(exc, NotFoundError) and \"model\" in str(exc).lower()","tryCatchPattern":"from litellm import NotFoundError\n\ntry:\n    resp = litellm.completion(model=m, messages=msgs)\nexcept NotFoundError as e:\n    m = FALLBACK_MODEL  # only if you intended a fallback; else surface 404 to caller\n    resp = litellm.completion(model=m, messages=msgs)","preventionTips":["Source model ids from litellm.model_list or the provider's models endpoint.","Validate model names in config at startup and prune unknown entries.","After provider model renames/deprecations, run a config audit before deploying."],"tags":["model-not-found","exception-mapping","config","provider-error"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}