Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/anthropic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
InternalServerError,
PermissionDeniedError,
UnprocessableEntityError,
FailedDependencyError,
APIResponseValidationError,
)
from ._base_client import DefaultHttpxClient, DefaultAsyncHttpxClient
Expand All @@ -64,6 +65,7 @@
"NotFoundError",
"ConflictError",
"UnprocessableEntityError",
"FailedDependencyError",
"RateLimitError",
"InternalServerError",
"Timeout",
Expand Down
5 changes: 5 additions & 0 deletions src/anthropic/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,11 @@ def _should_retry(self, response: httpx.Response) -> bool:
log.debug("Retrying due to status code %i", response.status_code)
return True

# Retry on failed dependencies.
if response.status_code == 424:
log.debug("Retrying due to status code %i", response.status_code)
return True

# Retry on rate limits.
if response.status_code == 429:
log.debug("Retrying due to status code %i", response.status_code)
Expand Down
6 changes: 6 additions & 0 deletions src/anthropic/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ def _make_status_error(
if response.status_code == 422:
return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)

if response.status_code == 424:
return _exceptions.FailedDependencyError(err_msg, response=response, body=body)

if response.status_code == 429:
return _exceptions.RateLimitError(err_msg, response=response, body=body)

Expand Down Expand Up @@ -571,6 +574,9 @@ def _make_status_error(
if response.status_code == 422:
return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)

if response.status_code == 424:
return _exceptions.FailedDependencyError(err_msg, response=response, body=body)

if response.status_code == 429:
return _exceptions.RateLimitError(err_msg, response=response, body=body)

Expand Down
5 changes: 5 additions & 0 deletions src/anthropic/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"NotFoundError",
"ConflictError",
"UnprocessableEntityError",
"FailedDependencyError",
"RateLimitError",
"InternalServerError",
]
Expand Down Expand Up @@ -100,6 +101,10 @@ class UnprocessableEntityError(APIStatusError):
status_code: Literal[422] = 422 # pyright: ignore[reportIncompatibleVariableOverride]


class FailedDependencyError(APIStatusError):
status_code: Literal[424] = 424 # pyright: ignore[reportIncompatibleVariableOverride]


class RateLimitError(APIStatusError):
status_code: Literal[429] = 429 # pyright: ignore[reportIncompatibleVariableOverride]

Expand Down
3 changes: 3 additions & 0 deletions src/anthropic/lib/bedrock/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ def _make_status_error(
if response.status_code == 422:
return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)

if response.status_code == 424:
return _exceptions.FailedDependencyError(err_msg, response=response, body=body)

if response.status_code == 429:
return _exceptions.RateLimitError(err_msg, response=response, body=body)

Expand Down