Skip to content

Commit fcc59d5

Browse files
authored
Merge pull request #31 from replicate/release-please--branches--main--changes--next
release: 2.0.0-alpha.5
2 parents a15571c + d7a0b4c commit fcc59d5

31 files changed

+353
-58
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "2.0.0-alpha.4"
2+
".": "2.0.0-alpha.5"
33
}

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 35
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-12e7ef40109b6b34f1471a638d09b79f005c8dbf7e1a8aeca9db7e37a334e8eb.yml
3-
openapi_spec_hash: 10b0fc9094dac5d51f46bbdd5fe3de32
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-f5aff38eef8d7b245a7af062bf02920ae75e5b9b3dc822416aeb48966c2c6874.yml
3+
openapi_spec_hash: c0a966beaf5ae95c6bdddd4a933bd4aa
44
config_hash: 12536d2bf978a995771d076a4647c17d

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# Changelog
22

3+
## 2.0.0-alpha.5 (2025-06-25)
4+
5+
Full Changelog: [v2.0.0-alpha.4...v2.0.0-alpha.5](https://github.com/replicate/replicate-python-stainless/compare/v2.0.0-alpha.4...v2.0.0-alpha.5)
6+
7+
### Features
8+
9+
* **api:** api update ([6e667da](https://github.com/replicate/replicate-python-stainless/commit/6e667da6c2e80add847e612bbd08db1c865793d7))
10+
* **api:** api update ([0a187a9](https://github.com/replicate/replicate-python-stainless/commit/0a187a9ba906c0bc5c4e658883266276fc357665))
11+
* **api:** api update ([edb14b6](https://github.com/replicate/replicate-python-stainless/commit/edb14b65c61203c2e42a1accd384e7b456e33448))
12+
* **client:** add support for aiohttp ([c802a30](https://github.com/replicate/replicate-python-stainless/commit/c802a30a0569cb25eb700ff5501c5a87291ef4b0))
13+
14+
15+
### Chores
16+
17+
* **tests:** skip some failing tests on the latest python versions ([d331b72](https://github.com/replicate/replicate-python-stainless/commit/d331b72364eaed6f935f9b23fdc776303ebf57a6))
18+
19+
20+
### Documentation
21+
22+
* **client:** fix httpx.Timeout documentation reference ([d17c345](https://github.com/replicate/replicate-python-stainless/commit/d17c3454afaa0ae0b022f468515e8478e5ba6568))
23+
324
## 2.0.0-alpha.4 (2025-06-18)
425

526
Full Changelog: [v2.0.0-alpha.3...v2.0.0-alpha.4](https://github.com/replicate/replicate-python-stainless/compare/v2.0.0-alpha.3...v2.0.0-alpha.4)

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,42 @@ asyncio.run(main())
6868

6969
Functionality between the synchronous and asynchronous clients is otherwise identical.
7070

71+
### With aiohttp
72+
73+
By default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.
74+
75+
You can enable this by installing `aiohttp`:
76+
77+
```sh
78+
# install from PyPI
79+
pip install --pre replicate[aiohttp]
80+
```
81+
82+
Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
83+
84+
```python
85+
import os
86+
import asyncio
87+
from replicate import DefaultAioHttpClient
88+
from replicate import AsyncReplicate
89+
90+
91+
async def main() -> None:
92+
async with AsyncReplicate(
93+
bearer_token=os.environ.get(
94+
"REPLICATE_API_TOKEN"
95+
), # This is the default and can be omitted
96+
http_client=DefaultAioHttpClient(),
97+
) as replicate:
98+
prediction = await replicate.predictions.get(
99+
prediction_id="gm3qorzdhgbfurvjtvhg6dckhu",
100+
)
101+
print(prediction.id)
102+
103+
104+
asyncio.run(main())
105+
```
106+
71107
## Using types
72108

73109
Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
@@ -228,7 +264,7 @@ replicate.with_options(max_retries=5).predictions.create(
228264
### Timeouts
229265

230266
By default requests time out after 1 minute. You can configure this with a `timeout` option,
231-
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:
267+
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:
232268

233269
```python
234270
from replicate import Replicate

api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,16 @@ Methods:
6161
Types:
6262

6363
```python
64-
from replicate.types import ModelListResponse
64+
from replicate.types import ModelListResponse, ModelGetResponse, ModelSearchResponse
6565
```
6666

6767
Methods:
6868

6969
- <code title="post /models">replicate.models.<a href="./src/replicate/resources/models/models.py">create</a>(\*\*<a href="src/replicate/types/model_create_params.py">params</a>) -> None</code>
7070
- <code title="get /models">replicate.models.<a href="./src/replicate/resources/models/models.py">list</a>() -> <a href="./src/replicate/types/model_list_response.py">SyncCursorURLPage[ModelListResponse]</a></code>
7171
- <code title="delete /models/{model_owner}/{model_name}">replicate.models.<a href="./src/replicate/resources/models/models.py">delete</a>(\*, model_owner, model_name) -> None</code>
72-
- <code title="get /models/{model_owner}/{model_name}">replicate.models.<a href="./src/replicate/resources/models/models.py">get</a>(\*, model_owner, model_name) -> None</code>
73-
- <code title="query /models">replicate.models.<a href="./src/replicate/resources/models/models.py">search</a>(\*\*<a href="src/replicate/types/model_search_params.py">params</a>) -> None</code>
72+
- <code title="get /models/{model_owner}/{model_name}">replicate.models.<a href="./src/replicate/resources/models/models.py">get</a>(\*, model_owner, model_name) -> <a href="./src/replicate/types/model_get_response.py">ModelGetResponse</a></code>
73+
- <code title="query /models">replicate.models.<a href="./src/replicate/resources/models/models.py">search</a>(\*\*<a href="src/replicate/types/model_search_params.py">params</a>) -> <a href="./src/replicate/types/model_search_response.py">SyncCursorURLPage[ModelSearchResponse]</a></code>
7474

7575
## Examples
7676

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "replicate"
3-
version = "2.0.0-alpha.4"
3+
version = "2.0.0-alpha.5"
44
description = "The official Python library for the replicate API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"
@@ -37,6 +37,8 @@ classifiers = [
3737
Homepage = "https://github.com/replicate/replicate-python-stainless"
3838
Repository = "https://github.com/replicate/replicate-python-stainless"
3939

40+
[project.optional-dependencies]
41+
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.6"]
4042

4143
[tool.rye]
4244
managed = true

requirements-dev.lock

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,24 @@
1010
# universal: false
1111

1212
-e file:.
13+
aiohappyeyeballs==2.6.1
14+
# via aiohttp
15+
aiohttp==3.12.8
16+
# via httpx-aiohttp
17+
# via replicate
18+
aiosignal==1.3.2
19+
# via aiohttp
1320
annotated-types==0.6.0
1421
# via pydantic
1522
anyio==4.4.0
1623
# via httpx
1724
# via replicate
1825
argcomplete==3.1.2
1926
# via nox
27+
async-timeout==5.0.1
28+
# via aiohttp
29+
attrs==25.3.0
30+
# via aiohttp
2031
certifi==2023.7.22
2132
# via httpcore
2233
# via httpx
@@ -34,23 +45,33 @@ execnet==2.1.1
3445
# via pytest-xdist
3546
filelock==3.12.4
3647
# via virtualenv
48+
frozenlist==1.6.2
49+
# via aiohttp
50+
# via aiosignal
3751
h11==0.14.0
3852
# via httpcore
3953
httpcore==1.0.2
4054
# via httpx
4155
httpx==0.28.1
56+
# via httpx-aiohttp
4257
# via replicate
4358
# via respx
59+
httpx-aiohttp==0.1.6
60+
# via replicate
4461
idna==3.4
4562
# via anyio
4663
# via httpx
64+
# via yarl
4765
importlib-metadata==7.0.0
4866
iniconfig==2.0.0
4967
# via pytest
5068
markdown-it-py==3.0.0
5169
# via rich
5270
mdurl==0.1.2
5371
# via markdown-it-py
72+
multidict==6.4.4
73+
# via aiohttp
74+
# via yarl
5475
mypy==1.14.1
5576
mypy-extensions==1.0.0
5677
# via mypy
@@ -65,6 +86,9 @@ platformdirs==3.11.0
6586
# via virtualenv
6687
pluggy==1.5.0
6788
# via pytest
89+
propcache==0.3.1
90+
# via aiohttp
91+
# via yarl
6892
pydantic==2.10.3
6993
# via replicate
7094
pydantic-core==2.27.1
@@ -97,12 +121,15 @@ tomli==2.0.2
97121
# via pytest
98122
typing-extensions==4.12.2
99123
# via anyio
124+
# via multidict
100125
# via mypy
101126
# via pydantic
102127
# via pydantic-core
103128
# via pyright
104129
# via replicate
105130
virtualenv==20.24.5
106131
# via nox
132+
yarl==1.20.0
133+
# via aiohttp
107134
zipp==3.17.0
108135
# via importlib-metadata

requirements.lock

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,51 @@
1010
# universal: false
1111

1212
-e file:.
13+
aiohappyeyeballs==2.6.1
14+
# via aiohttp
15+
aiohttp==3.12.8
16+
# via httpx-aiohttp
17+
# via replicate
18+
aiosignal==1.3.2
19+
# via aiohttp
1320
annotated-types==0.6.0
1421
# via pydantic
1522
anyio==4.4.0
1623
# via httpx
1724
# via replicate
25+
async-timeout==5.0.1
26+
# via aiohttp
27+
attrs==25.3.0
28+
# via aiohttp
1829
certifi==2023.7.22
1930
# via httpcore
2031
# via httpx
2132
distro==1.8.0
2233
# via replicate
2334
exceptiongroup==1.2.2
2435
# via anyio
36+
frozenlist==1.6.2
37+
# via aiohttp
38+
# via aiosignal
2539
h11==0.14.0
2640
# via httpcore
2741
httpcore==1.0.2
2842
# via httpx
2943
httpx==0.28.1
44+
# via httpx-aiohttp
45+
# via replicate
46+
httpx-aiohttp==0.1.6
3047
# via replicate
3148
idna==3.4
3249
# via anyio
3350
# via httpx
51+
# via yarl
52+
multidict==6.4.4
53+
# via aiohttp
54+
# via yarl
55+
propcache==0.3.1
56+
# via aiohttp
57+
# via yarl
3458
pydantic==2.10.3
3559
# via replicate
3660
pydantic-core==2.27.1
@@ -40,6 +64,9 @@ sniffio==1.3.0
4064
# via replicate
4165
typing-extensions==4.12.2
4266
# via anyio
67+
# via multidict
4368
# via pydantic
4469
# via pydantic-core
4570
# via replicate
71+
yarl==1.20.0
72+
# via aiohttp

src/replicate/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
APIResponseValidationError,
4242
)
4343
from .lib._models import Model as Model, Version as Version, ModelVersionIdentifier as ModelVersionIdentifier
44-
from ._base_client import DefaultHttpxClient, DefaultAsyncHttpxClient
44+
from ._base_client import DefaultHttpxClient, DefaultAioHttpClient, DefaultAsyncHttpxClient
4545
from ._utils._logs import setup_logging as _setup_logging
4646

4747
__all__ = [
@@ -83,6 +83,7 @@
8383
"DEFAULT_CONNECTION_LIMITS",
8484
"DefaultHttpxClient",
8585
"DefaultAsyncHttpxClient",
86+
"DefaultAioHttpClient",
8687
"FileOutput",
8788
"AsyncFileOutput",
8889
"Model",

src/replicate/_base_client.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,24 @@ def __init__(self, **kwargs: Any) -> None:
13031303
super().__init__(**kwargs)
13041304

13051305

1306+
try:
1307+
import httpx_aiohttp
1308+
except ImportError:
1309+
1310+
class _DefaultAioHttpClient(httpx.AsyncClient):
1311+
def __init__(self, **_kwargs: Any) -> None:
1312+
raise RuntimeError("To use the aiohttp client you must have installed the package with the `aiohttp` extra")
1313+
else:
1314+
1315+
class _DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
1316+
def __init__(self, **kwargs: Any) -> None:
1317+
kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
1318+
kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
1319+
kwargs.setdefault("follow_redirects", True)
1320+
1321+
super().__init__(**kwargs)
1322+
1323+
13061324
if TYPE_CHECKING:
13071325
DefaultAsyncHttpxClient = httpx.AsyncClient
13081326
"""An alias to `httpx.AsyncClient` that provides the same defaults that this SDK
@@ -1311,8 +1329,12 @@ def __init__(self, **kwargs: Any) -> None:
13111329
This is useful because overriding the `http_client` with your own instance of
13121330
`httpx.AsyncClient` will result in httpx's defaults being used, not ours.
13131331
"""
1332+
1333+
DefaultAioHttpClient = httpx.AsyncClient
1334+
"""An alias to `httpx.AsyncClient` that changes the default HTTP transport to `aiohttp`."""
13141335
else:
13151336
DefaultAsyncHttpxClient = _DefaultAsyncHttpxClient
1337+
DefaultAioHttpClient = _DefaultAioHttpClient
13161338

13171339

13181340
class AsyncHttpxClientWrapper(DefaultAsyncHttpxClient):

0 commit comments

Comments
 (0)