For Amazon Bedrock support changedcli-sdks-libraries/sdks/python
Nearest release: v2.1.239, published 2 hours before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+20added
Lines−18removed
From line
36
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits10to this page, all time
The whole hunk
from line 36, old and new numbered
/
from line 36
3636
3737## Requirements
3838
39Python 3.9 or later is required.
39Python 3.10 or later is required. If you are upgrading from a 0.x release of the SDK, see the [v1 migration guide](https://github.com/anthropics/anthropic-sdk-python/blob/main/MIGRATION.md) for the list of breaking changes.
4040
4141## Usage
4242
from line 102
102102
103103### Using aiohttp for better concurrency
104104
105For improved async performance, you can use the `aiohttp` HTTP backend instead of the default `httpx`:
105For improved async performance, you can use the `aiohttp` HTTP backend instead of the default `httpx2`:
106106
107107```python
108108import os
from line 362
362362 )
363363except anthropic.APIConnectionError as e:
364364 print("The server could not be reached")
365 print(e.__cause__) # an underlying Exception, likely raised within httpx
365 print(e.__cause__) # an underlying Exception, likely raised within httpx2
366366except anthropic.RateLimitError as e:
367367 print("A 429 status code was received; we should back off a bit.")
368368except anthropic.APIStatusError as e:
from line 426
426426
427427## Timeouts
428428
429By default requests time out after 10 minutes. You can configure this with a `timeout` option, which accepts a float or an `httpx.Timeout` object:
429By default requests time out after 10 minutes. You can configure this with a `timeout` option, which accepts a float or an `httpx2.Timeout` object:
430430
431431```python
432import httpx
432import httpx2
433433from anthropic import Anthropic
434434
435435# Configure the default for all requests:
from line 439
439439
440440# More granular control:
441441client = Anthropic(
442 timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),
442 timeout=httpx2.Timeout(60.0, read=5.0, write=10.0, connect=2.0),
443443)
444444
445445# Override per-request:
from line 588
588588
589589### Accessing raw response data (for example, headers)
590590
591The "raw" `Response` returned by `httpx` can be accessed through the `.with_raw_response` property on the client. This is useful for accessing response headers or other metadata:
591The "raw" `Response` returned by `httpx2` can be accessed through the `.with_raw_response` property on the client. This is useful for accessing response headers or other metadata:
592592
593593```python
594594client = Anthropic()
from line 606
606606print(message.content)
607607```
608608
609These methods return an `APIResponse` object.
609These methods return an `APIResponse` object. On the async client they return an `AsyncAPIResponse`, and `.parse()`, `.read()`, `.text()`, and `.json()` must be awaited.
610610
611611### Streaming response body
612612
from line 645
645645To make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs. Options on the client, such as retries, are respected when making these requests.
646646
647647```python
648import httpx
648import httpx2
649649
650650response = client.post(
651651 "/foo",
652 cast_to=httpx.Response,
652 cast_to=httpx2.Response,
653653 body={"my_param": True},
654654)
655655
from line 670
670670
671671### Configuring the HTTP client
672672
673You can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including support for proxies and transports:
673The SDK sends requests with [httpx2](https://httpx2.pydantic.dev), an API-compatible fork of `httpx`. To customize the HTTP client, including proxies and transports, pass your own [httpx2 client](https://httpx2.pydantic.dev/api/#client) as `http_client`:
674674
675675```python
676import httpx
676import httpx2
677677from anthropic import Anthropic, DefaultHttpxClient
678678
679679client = Anthropic(
from line 681
681681 base_url="http://my.test.server.example.com:8083",
682682 http_client=DefaultHttpxClient(
683683 proxy="http://my.test.proxy.example.com",
684 transport=httpx.HTTPTransport(local_address="0.0.0.0"),
684 transport=httpx2.HTTPTransport(local_address="0.0.0.0"),
685685 ),
686686)
687687```
from line 693
693693```
694694
695695<Note>
696 Use `DefaultHttpxClient` and `DefaultAsyncHttpxClient` instead of raw `httpx.Client` and `httpx.AsyncClient` to ensure the SDK's default configuration (such as timeouts and connection limits) is preserved.
696 Use `DefaultHttpxClient` and `DefaultAsyncHttpxClient` instead of raw `httpx2.Client` and `httpx2.AsyncClient` to ensure the SDK's default configuration (such as timeouts and connection limits) is preserved. The `http_client` argument must be an `httpx2` client. Passing a client from the separate `httpx` package raises a `TypeError`.
697697</Note>
698
699Tracing and mocking tools that patch `httpx` itself, such as OpenTelemetry's `HTTPXClientInstrumentor`, Sentry's `httpx` integration, `respx`, or `pytest-httpx`, do not see the SDK's requests by default. To use them, call `httpx2.alias_httpx()` once at startup, before anything imports `httpx`. This makes `import httpx` resolve to `httpx2` for the whole process.
698700
699701### Managing HTTP resources
700702
No line in this hunk matches that.