langchain_core.exceptions: the standard model error types and is_retryable
Major integrations raise standard exceptions from langchain_core.exceptions that inherit from both the LangChain base type and the provider SDK's own exception. Each carries is_retryable, which retry middleware respects.
Standard model exceptions
| Exception | Meaning | Retryable |
|---|---|---|
| ModelAuthenticationError | missing, invalid, or expired key | no |
| ModelPermissionDeniedError | credentials lack permission | no |
| ModelInvalidRequestError | provider rejects the request | no |
| ModelNotFoundError | requested model not found | no |
| ModelRateLimitError | provider rate limit exceeded | yes |
| ModelAPIError | provider server failure | yes |
| ModelConnectionError | provider cannot be reached | yes |
| ModelTimeoutError | request times out | yes |
| ContextOverflowError | input exceeds context limit | no |
from langchain.chat_models import init_chat_model
from langchain_core.exceptions import ModelTimeoutError
model = init_chat_model("openai:gpt-5.6-luna", timeout=0.0001)
try:
model.invoke("Hello")
except ModelTimeoutError:
print("caught")Rules
- Catch the LangChain type or the provider SDK type; dual inheritance means either works.
- Branch on
is_retryable, not on your own list of error names. The attribute is the contract the middleware uses. - Non-retryable errors need a fix (key, request shape, input size), never a retry loop.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.