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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: '0.8.11'
version: '0.9.13'

- name: Install dependencies
run: uv sync --all-extras
Expand All @@ -46,7 +46,7 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: '0.8.11'
version: '0.9.13'

- name: Install dependencies
run: uv sync --all-extras
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: '0.8.11'
version: '0.9.13'

- name: Bootstrap
run: ./scripts/bootstrap
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
if: ${{ steps.release.outputs.releases_created }}
uses: astral-sh/setup-uv@v5
with:
version: '0.8.11'
version: '0.9.13'

- name: Publish to PyPI
if: ${{ steps.release.outputs.releases_created }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/detect-breaking-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: '0.8.11'
version: '0.9.13'
- name: Install dependencies
run: uv sync --all-extras
- name: Detect removed symbols
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: '0.8.11'
version: '0.9.13'

- name: Publish to PyPI
run: |
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 34
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-a49e89deec4e00d1da490808099d66e2001531b12d8666a7f5d0b496f760440d.yml
openapi_spec_hash: c93ef3808c58e233b01966ff154f31ce
config_hash: 7e9dfe17ab5c80abee5372ce746a926e
config_hash: a5d8cd02f9a686d4e0baa7ba652e3e55
10 changes: 4 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ $ ./scripts/test
### Snapshots

Some tests use [inline-snapshot](https://15r10nk.github.io/inline-snapshot/latest/). To update them after making changes, rerun the tests with the `--inline-snapshot=fix` and `-n0` options:

```bash
./scripts/test --inline-snapshot=fix -n0
```
Expand All @@ -108,15 +107,14 @@ Some tests use [inline-snapshot](https://15r10nk.github.io/inline-snapshot/lates
> `inline-snapshot` is incompatible with [pytest-xdist](https://github.com/pytest-dev/pytest-xdist), so you need to disable parallel execution `(-n0)` when using the `--inline-snapshot` option.

In addition, some tests capture snapshots of the HTTP requests they make.
To refresh these snapshots, run the tests with the `ANTHROPIC_LIVE=1` environment variable enabled.

To refresh these snapshots, run the tests with the `--http-record` flag:
```bash
ANTHROPIC_LIVE=1 ./scripts/test --inline-snapshot=fix
./scripts/test --inline-snapshot=fix --http-record -n0
```

> [!NOTE]
> Sometimes it makes sense to update only the inline snapshots `(--inline-snapshot=fix)` without refreshing the HTTP snapshots `(ANTHROPIC_LIVE=1)`.
> This is useful when the endpoint hasnt changed, but your code handles the response differently and the assertions need updating.
> Sometimes it makes sense to update only the inline snapshots `(--inline-snapshot=fix)` without refreshing the HTTP snapshots `(--http-record)`.
> This is useful when the endpoint hasn't changed, but your code handles the response differently and the assertions need updating.

## Linting and formatting

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,15 @@ pip install anthropic[aiohttp]
Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:

```python
import os
import asyncio
from anthropic import DefaultAioHttpClient
from anthropic import AsyncAnthropic


async def main() -> None:
async with AsyncAnthropic(
api_key="my-anthropic-api-key",
api_key=os.environ.get("ANTHROPIC_API_KEY"), # This is the default and can be omitted
http_client=DefaultAioHttpClient(),
) as client:
message = await client.messages.create(
Expand Down
21 changes: 13 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ license = "MIT"
authors = [
{ name = "Anthropic", email = "[email protected]" },
]

dependencies = [
"httpx>=0.25.0, <1",
"pydantic>=1.9.0, <3",
"typing-extensions>=4.10, <5",
"anyio>=3.5.0, <5",
"distro>=1.7.0, <2",
"sniffio",
"pydantic>=1.9.0, <3",
"typing-extensions>=4.10, <5",
"anyio>=3.5.0, <5",
"distro>=1.7.0, <2",
"sniffio",
"jiter>=0.4.0, <1",
"docstring-parser>=0.15,<1",
]

requires-python = ">= 3.9"
classifiers = [
"Typing :: Typed",
Expand All @@ -26,6 +28,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Operating System :: OS Independent",
"Operating System :: POSIX",
"Operating System :: MacOS",
Expand All @@ -46,7 +49,7 @@ Repository = "https://github.com/anthropics/anthropic-sdk-python"

[tool.uv]
managed = true
required-version = ">=0.5.0"
required-version = ">=0.9"
conflicts = [
[
{ group = "pydantic-v1" },
Expand All @@ -58,7 +61,7 @@ conflicts = [
# version pins are in uv.lock
dev = [
"pyright==1.1.399",
"mypy",
"mypy==1.17",
"respx",
"pytest",
"pytest-asyncio",
Expand All @@ -71,12 +74,14 @@ dev = [
"pytest-xdist>=3.6.1",
"inline-snapshot>=0.28.0",
"griffe>=1",
"http-snapshot[httpx]==0.1.6",
]
pydantic-v1 = [
"pydantic>=1.9.0,<2",
]
pydantic-v2 = [
"pydantic>=2,<3",
"pydantic~=2.0 ; python_full_version < '3.14'",
"pydantic~=2.12 ; python_full_version >= '3.14'",
]

[build-system]
Expand Down
92 changes: 55 additions & 37 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,40 @@
-e .
annotated-types==0.7.0
# via pydantic
anyio==4.8.0
anyio==4.12.0
# via
# anthropic
# httpx
asttokens==3.0.0
asttokens==3.0.1
# via inline-snapshot
boto3-stubs==1.40.69
botocore-stubs==1.40.69
backports-asyncio-runner==1.2.0 ; python_full_version < '3.11'
# via pytest-asyncio
boto3-stubs==1.41.5
botocore-stubs==1.41.6
# via boto3-stubs
certifi==2024.12.14
certifi==2025.11.12
# via
# httpcore
# httpx
colorama==0.4.6
# via
# griffe
# pytest
dirty-equals==0.9.0
dirty-equals==0.11
distro==1.9.0
# via anthropic
docstring-parser==0.17.0
# via anthropic
exceptiongroup==1.2.2 ; python_full_version < '3.11'
exceptiongroup==1.3.1 ; python_full_version < '3.11'
# via
# anyio
# pytest
execnet==2.1.1
execnet==2.1.2
# via pytest-xdist
executing==2.2.1
# via inline-snapshot
griffe==1.13.0
griffe==1.14.0 ; python_full_version < '3.10'
griffe==1.15.0 ; python_full_version >= '3.10'
h11==0.16.0
# via httpcore
httpcore==1.0.9
Expand All @@ -42,76 +45,91 @@ httpx==0.28.1
# via
# anthropic
# respx
idna==3.10
idna==3.11
# via
# anyio
# httpx
importlib-metadata==8.6.1
iniconfig==2.0.0
importlib-metadata==8.7.0
iniconfig==2.1.0 ; python_full_version < '3.10'
# via pytest
iniconfig==2.3.0 ; python_full_version >= '3.10'
# via pytest
inline-snapshot==0.31.1
jiter==0.12.0
# via anthropic
markdown-it-py==3.0.0
markdown-it-py==3.0.0 ; python_full_version < '3.10'
# via rich
markdown-it-py==4.0.0 ; python_full_version >= '3.10'
# via rich
mdurl==0.1.2
# via markdown-it-py
mypy==1.14.1
mypy-extensions==1.0.0
mypy==1.17.0
mypy-extensions==1.1.0
# via mypy
nodeenv==1.9.1
# via pyright
packaging==24.2
packaging==25.0
# via pytest
pluggy==1.5.0
pathspec==0.12.1
# via mypy
pluggy==1.6.0
# via pytest
pydantic==2.10.3
pydantic==2.12.5
# via anthropic
pydantic-core==2.27.1
pydantic-core==2.41.5
# via pydantic
pygments==2.19.1
pygments==2.19.2
# via
# pytest
# rich
pyright==1.1.399
pytest==8.4.1
pytest==8.4.2 ; python_full_version < '3.10'
# via
# inline-snapshot
# pytest-asyncio
# pytest-xdist
pytest==9.0.1 ; python_full_version >= '3.10'
# via
# inline-snapshot
# pytest-asyncio
# pytest-xdist
pytest-asyncio==0.24.0
pytest-xdist==3.7.0
python-dateutil==2.9.0.post0
pytest-asyncio==1.2.0 ; python_full_version < '3.10'
pytest-asyncio==1.3.0 ; python_full_version >= '3.10'
pytest-xdist==3.8.0
python-dateutil==2.9.0.post0 ; python_full_version < '3.10'
# via time-machine
respx==0.22.0
rich==13.9.4
rich==14.2.0
# via inline-snapshot
ruff==0.9.4
six==1.17.0
ruff==0.14.7
six==1.17.0 ; python_full_version < '3.10'
# via python-dateutil
sniffio==1.3.1
# via
# anthropic
# anyio
time-machine==2.16.0
tomli==2.2.1 ; python_full_version < '3.11'
# via anthropic
time-machine==2.19.0 ; python_full_version < '3.10'
time-machine==3.1.0 ; python_full_version >= '3.10'
tomli==2.3.0 ; python_full_version < '3.11'
# via
# inline-snapshot
# mypy
# pytest
types-awscrt==0.28.2
types-awscrt==0.29.1
# via botocore-stubs
types-s3transfer==0.14.0
types-s3transfer==0.15.0
# via boto3-stubs
typing-extensions==4.12.2
typing-extensions==4.15.0
# via
# anthropic
# anyio
# boto3-stubs
# exceptiongroup
# mypy
# pydantic
# pydantic-core
# pyright
# rich
zipp==3.21.0
# pytest-asyncio
# typing-inspection
typing-inspection==0.4.2
# via pydantic
zipp==3.23.0
# via importlib-metadata
20 changes: 14 additions & 6 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,20 @@ fi

export DEFER_PYDANTIC_BUILD=false

# Note that we need to specify the patch version here so that uv
# won't use unstable (alpha, beta, rc) releases for the tests
PY_VERSION_MIN=">=3.9.0"
PY_VERSION_MAX=">=3.14.0"

function run_tests() {
echo "==> Running tests with Pydantic v2"
uv run --isolated --all-extras pytest "$@"

echo "==> Running tests with Pydantic v1"
uv run --isolated --all-extras --group=pydantic-v1 pytest "$@"
# Skip Pydantic v1 tests on latest Python (not supported)
if [[ "$UV_PYTHON" != "$PY_VERSION_MAX" ]]; then
echo "==> Running tests with Pydantic v1"
uv run --isolated --all-extras --group=pydantic-v1 pytest "$@"
fi
}

# If UV_PYTHON is already set in the environment, just run the command once
Expand All @@ -68,9 +76,9 @@ if [[ -n "$UV_PYTHON" ]]; then
else
# If UV_PYTHON is not set, run the command for min and max versions

echo "==> Running tests for Python 3.9"
UV_PYTHON=3.9 run_tests "$@"
echo "==> Running tests for Python $PY_VERSION_MIN"
UV_PYTHON="$PY_VERSION_MIN" run_tests "$@"

echo "==> Running tests for Python 3.13"
UV_PYTHON=3.13 run_tests "$@"
echo "==> Running tests for Python $PY_VERSION_MAX"
UV_PYTHON="$PY_VERSION_MAX" run_tests "$@"
fi
Loading