diff --git a/src/anthropic/lib/bedrock/_client.py b/src/anthropic/lib/bedrock/_client.py index 89c601d9..9d5eb3bc 100644 --- a/src/anthropic/lib/bedrock/_client.py +++ b/src/anthropic/lib/bedrock/_client.py @@ -14,7 +14,7 @@ from ..._compat import model_copy from ..._version import __version__ from ..._streaming import Stream, AsyncStream -from ..._exceptions import APIStatusError +from ..._exceptions import AnthropicError, APIStatusError from ..._base_client import ( DEFAULT_MAX_RETRIES, BaseClient, @@ -55,6 +55,12 @@ def _prepare_options(input_options: FinalRequestOptions) -> FinalRequestOptions: else: options.url = f"/model/{model}/invoke" + if options.url.startswith('/v1/messages/batches'): + raise AnthropicError('The Batch API is not supported in Bedrock yet') + + if options.url == '/v1/messages/count_tokens': + raise AnthropicError('Token counting is not supported in Bedrock yet') + return options diff --git a/src/anthropic/lib/vertex/_client.py b/src/anthropic/lib/vertex/_client.py index 2c1869f8..d2f49029 100644 --- a/src/anthropic/lib/vertex/_client.py +++ b/src/anthropic/lib/vertex/_client.py @@ -15,7 +15,7 @@ from ..._models import FinalRequestOptions from ..._version import __version__ from ..._streaming import Stream, AsyncStream -from ..._exceptions import APIStatusError +from ..._exceptions import AnthropicError, APIStatusError from ..._base_client import ( DEFAULT_MAX_RETRIES, DEFAULT_CONNECTION_LIMITS, @@ -452,4 +452,7 @@ def _prepare_options(input_options: FinalRequestOptions, *, project_id: str | No options.url = f"/projects/{project_id}/locations/{region}/publishers/anthropic/models/count-tokens:rawPredict" + if options.url.startswith('/v1/messages/batches'): + raise AnthropicError('The Batch API is not supported in the Vertex client yet') + return options