Skip to content

Commit a4878ab

Browse files
release: 2.0.0-alpha.26 (#65)
* feat(api): add new replicate.search() method (beta) ...and remove the old replicate.models.search() method from the MCP server, so tools will not have to decide between the two. * codegen metadata * chore(internal): update pydantic dependency * fix(tests): fix tests for module-level client * release: 2.0.0-alpha.26 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
1 parent ab2920d commit a4878ab

File tree

14 files changed

+453
-14
lines changed

14 files changed

+453
-14
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.25"
2+
".": "2.0.0-alpha.26"
33
}

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 35
1+
configured_endpoints: 36
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-87c7c57bd75c54990c679c9e87d009851cdff572815a55d1b6ee4d4ee20adaa1.yml
33
openapi_spec_hash: d987f14befa536004eece7b49caad993
4-
config_hash: b1b4f5d24ba07b4667ffe7b9dec081e3
4+
config_hash: a916e7f3559ab312c7b6696cd6b35fb5

CHANGELOG.md

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

3+
## 2.0.0-alpha.26 (2025-09-17)
4+
5+
Full Changelog: [v2.0.0-alpha.25...v2.0.0-alpha.26](https://github.com/replicate/replicate-python-stainless/compare/v2.0.0-alpha.25...v2.0.0-alpha.26)
6+
7+
### Features
8+
9+
* **api:** add new replicate.search() method (beta) ([30d7019](https://github.com/replicate/replicate-python-stainless/commit/30d701999ea48ee65c5e5fd467072ccd5db35f87))
10+
11+
12+
### Bug Fixes
13+
14+
* **tests:** fix tests for module-level client ([1e72f23](https://github.com/replicate/replicate-python-stainless/commit/1e72f23da3f0930955fe126848a8a8e58dbb710e))
15+
16+
17+
### Chores
18+
19+
* **internal:** update pydantic dependency ([54872cb](https://github.com/replicate/replicate-python-stainless/commit/54872cb5e00fb65cae2abffcf0169a8b138e35fa))
20+
321
## 2.0.0-alpha.25 (2025-09-15)
422

523
Full Changelog: [v2.0.0-alpha.24...v2.0.0-alpha.25](https://github.com/replicate/replicate-python-stainless/compare/v2.0.0-alpha.24...v2.0.0-alpha.25)

api.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# Replicate
2+
3+
Types:
4+
5+
```python
6+
from replicate.types import SearchResponse
7+
```
8+
9+
Methods:
10+
11+
- <code title="get /search">replicate.<a href="./src/replicate/_client.py">search</a>(\*\*<a href="src/replicate/types/client_search_params.py">params</a>) -> <a href="./src/replicate/types/search_response.py">SearchResponse</a></code>
12+
113
# Collections
214

315
Types:

pyproject.toml

Lines changed: 1 addition & 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.25"
3+
version = "2.0.0-alpha.26"
44
description = "The official Python library for the replicate API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"

requirements-dev.lock

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ pluggy==1.5.0
8888
propcache==0.3.1
8989
# via aiohttp
9090
# via yarl
91-
pydantic==2.10.3
91+
pydantic==2.11.9
9292
# via replicate
93-
pydantic-core==2.27.1
93+
pydantic-core==2.33.2
9494
# via pydantic
9595
pygments==2.18.0
9696
# via rich
@@ -126,6 +126,9 @@ typing-extensions==4.12.2
126126
# via pydantic-core
127127
# via pyright
128128
# via replicate
129+
# via typing-inspection
130+
typing-inspection==0.4.1
131+
# via pydantic
129132
virtualenv==20.24.5
130133
# via nox
131134
yarl==1.20.0

requirements.lock

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ multidict==6.4.4
5555
propcache==0.3.1
5656
# via aiohttp
5757
# via yarl
58-
pydantic==2.10.3
58+
pydantic==2.11.9
5959
# via replicate
60-
pydantic-core==2.27.1
60+
pydantic-core==2.33.2
6161
# via pydantic
6262
sniffio==1.3.0
6363
# via anyio
@@ -68,5 +68,8 @@ typing-extensions==4.12.2
6868
# via pydantic
6969
# via pydantic-core
7070
# via replicate
71+
# via typing-inspection
72+
typing-inspection==0.4.1
73+
# via pydantic
7174
yarl==1.20.0
7275
# via aiohttp

src/replicate/_client.py

Lines changed: 162 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,42 @@
2727

2828
from . import _exceptions
2929
from ._qs import Querystring
30+
from .types import client_search_params
3031
from ._types import (
3132
NOT_GIVEN,
33+
Body,
3234
Omit,
35+
Query,
36+
Headers,
3337
Timeout,
3438
NotGiven,
3539
Transport,
3640
ProxiesTypes,
3741
RequestOptions,
3842
)
39-
from ._utils import is_given, get_async_library
43+
from ._utils import (
44+
is_given,
45+
maybe_transform,
46+
get_async_library,
47+
async_maybe_transform,
48+
)
4049
from ._compat import cached_property
4150
from ._version import __version__
51+
from ._response import (
52+
to_raw_response_wrapper,
53+
to_streamed_response_wrapper,
54+
async_to_raw_response_wrapper,
55+
async_to_streamed_response_wrapper,
56+
)
4257
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
4358
from ._exceptions import APIStatusError, ReplicateError
4459
from ._base_client import (
4560
DEFAULT_MAX_RETRIES,
4661
SyncAPIClient,
4762
AsyncAPIClient,
63+
make_request_options,
4864
)
65+
from .types.search_response import SearchResponse
4966

5067
if TYPE_CHECKING:
5168
from .resources import files, models, account, hardware, webhooks, trainings, collections, deployments, predictions
@@ -354,6 +371,70 @@ def copy(
354371
# client.with_options(timeout=10).foo.create(...)
355372
with_options = copy
356373

374+
def search(
375+
self,
376+
*,
377+
query: str,
378+
limit: int | NotGiven = NOT_GIVEN,
379+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
380+
# The extra values given here take precedence over values defined on the client or passed to this method.
381+
extra_headers: Headers | None = None,
382+
extra_query: Query | None = None,
383+
extra_body: Body | None = None,
384+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
385+
) -> SearchResponse:
386+
"""
387+
Search for public models, collections, and docs using a text query.
388+
389+
For models, the response includes all model data, plus a new `metadata` object
390+
with the following fields:
391+
392+
- `generated_description`: A longer and more detailed AI-generated description
393+
of the model
394+
- `tags`: An array of tags for the model
395+
- `score`: A score for the model's relevance to the search query
396+
397+
Example cURL request:
398+
399+
```console
400+
curl -s \\
401+
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \\
402+
"https://api.replicate.com/v1/search?query=nano+banana"
403+
```
404+
405+
Note: This search API is currently in beta and may change in future versions.
406+
407+
Args:
408+
query: The search query string
409+
410+
limit: Maximum number of model results to return (1-50, defaults to 20)
411+
412+
extra_headers: Send extra headers
413+
414+
extra_query: Add additional query parameters to the request
415+
416+
extra_body: Add additional JSON properties to the request
417+
418+
timeout: Override the client-level default timeout for this request, in seconds
419+
"""
420+
return self.get(
421+
"/search",
422+
options=make_request_options(
423+
extra_headers=extra_headers,
424+
extra_query=extra_query,
425+
extra_body=extra_body,
426+
timeout=timeout,
427+
query=maybe_transform(
428+
{
429+
"query": query,
430+
"limit": limit,
431+
},
432+
client_search_params.ClientSearchParams,
433+
),
434+
),
435+
cast_to=SearchResponse,
436+
)
437+
357438
@override
358439
def _make_status_error(
359440
self,
@@ -665,6 +746,70 @@ def copy(
665746
# client.with_options(timeout=10).foo.create(...)
666747
with_options = copy
667748

749+
async def search(
750+
self,
751+
*,
752+
query: str,
753+
limit: int | NotGiven = NOT_GIVEN,
754+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
755+
# The extra values given here take precedence over values defined on the client or passed to this method.
756+
extra_headers: Headers | None = None,
757+
extra_query: Query | None = None,
758+
extra_body: Body | None = None,
759+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
760+
) -> SearchResponse:
761+
"""
762+
Search for public models, collections, and docs using a text query.
763+
764+
For models, the response includes all model data, plus a new `metadata` object
765+
with the following fields:
766+
767+
- `generated_description`: A longer and more detailed AI-generated description
768+
of the model
769+
- `tags`: An array of tags for the model
770+
- `score`: A score for the model's relevance to the search query
771+
772+
Example cURL request:
773+
774+
```console
775+
curl -s \\
776+
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \\
777+
"https://api.replicate.com/v1/search?query=nano+banana"
778+
```
779+
780+
Note: This search API is currently in beta and may change in future versions.
781+
782+
Args:
783+
query: The search query string
784+
785+
limit: Maximum number of model results to return (1-50, defaults to 20)
786+
787+
extra_headers: Send extra headers
788+
789+
extra_query: Add additional query parameters to the request
790+
791+
extra_body: Add additional JSON properties to the request
792+
793+
timeout: Override the client-level default timeout for this request, in seconds
794+
"""
795+
return await self.get(
796+
"/search",
797+
options=make_request_options(
798+
extra_headers=extra_headers,
799+
extra_query=extra_query,
800+
extra_body=extra_body,
801+
timeout=timeout,
802+
query=await async_maybe_transform(
803+
{
804+
"query": query,
805+
"limit": limit,
806+
},
807+
client_search_params.ClientSearchParams,
808+
),
809+
),
810+
cast_to=SearchResponse,
811+
)
812+
668813
@override
669814
def _make_status_error(
670815
self,
@@ -705,6 +850,10 @@ class ReplicateWithRawResponse:
705850
def __init__(self, client: Replicate) -> None:
706851
self._client = client
707852

853+
self.search = to_raw_response_wrapper(
854+
client.search,
855+
)
856+
708857
@cached_property
709858
def collections(self) -> collections.CollectionsResourceWithRawResponse:
710859
from .resources.collections import CollectionsResourceWithRawResponse
@@ -766,6 +915,10 @@ class AsyncReplicateWithRawResponse:
766915
def __init__(self, client: AsyncReplicate) -> None:
767916
self._client = client
768917

918+
self.search = async_to_raw_response_wrapper(
919+
client.search,
920+
)
921+
769922
@cached_property
770923
def collections(self) -> collections.AsyncCollectionsResourceWithRawResponse:
771924
from .resources.collections import AsyncCollectionsResourceWithRawResponse
@@ -827,6 +980,10 @@ class ReplicateWithStreamedResponse:
827980
def __init__(self, client: Replicate) -> None:
828981
self._client = client
829982

983+
self.search = to_streamed_response_wrapper(
984+
client.search,
985+
)
986+
830987
@cached_property
831988
def collections(self) -> collections.CollectionsResourceWithStreamingResponse:
832989
from .resources.collections import CollectionsResourceWithStreamingResponse
@@ -888,6 +1045,10 @@ class AsyncReplicateWithStreamedResponse:
8881045
def __init__(self, client: AsyncReplicate) -> None:
8891046
self._client = client
8901047

1048+
self.search = async_to_streamed_response_wrapper(
1049+
client.search,
1050+
)
1051+
8911052
@cached_property
8921053
def collections(self) -> collections.AsyncCollectionsResourceWithStreamingResponse:
8931054
from .resources.collections import AsyncCollectionsResourceWithStreamingResponse

src/replicate/_models.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,15 @@ def model_dump(
256256
mode: Literal["json", "python"] | str = "python",
257257
include: IncEx | None = None,
258258
exclude: IncEx | None = None,
259-
by_alias: bool = False,
259+
by_alias: bool | None = None,
260260
exclude_unset: bool = False,
261261
exclude_defaults: bool = False,
262262
exclude_none: bool = False,
263263
round_trip: bool = False,
264264
warnings: bool | Literal["none", "warn", "error"] = True,
265265
context: dict[str, Any] | None = None,
266266
serialize_as_any: bool = False,
267+
fallback: Callable[[Any], Any] | None = None,
267268
) -> dict[str, Any]:
268269
"""Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump
269270
@@ -295,10 +296,12 @@ def model_dump(
295296
raise ValueError("context is only supported in Pydantic v2")
296297
if serialize_as_any != False:
297298
raise ValueError("serialize_as_any is only supported in Pydantic v2")
299+
if fallback is not None:
300+
raise ValueError("fallback is only supported in Pydantic v2")
298301
dumped = super().dict( # pyright: ignore[reportDeprecated]
299302
include=include,
300303
exclude=exclude,
301-
by_alias=by_alias,
304+
by_alias=by_alias if by_alias is not None else False,
302305
exclude_unset=exclude_unset,
303306
exclude_defaults=exclude_defaults,
304307
exclude_none=exclude_none,
@@ -313,13 +316,14 @@ def model_dump_json(
313316
indent: int | None = None,
314317
include: IncEx | None = None,
315318
exclude: IncEx | None = None,
316-
by_alias: bool = False,
319+
by_alias: bool | None = None,
317320
exclude_unset: bool = False,
318321
exclude_defaults: bool = False,
319322
exclude_none: bool = False,
320323
round_trip: bool = False,
321324
warnings: bool | Literal["none", "warn", "error"] = True,
322325
context: dict[str, Any] | None = None,
326+
fallback: Callable[[Any], Any] | None = None,
323327
serialize_as_any: bool = False,
324328
) -> str:
325329
"""Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump_json
@@ -348,11 +352,13 @@ def model_dump_json(
348352
raise ValueError("context is only supported in Pydantic v2")
349353
if serialize_as_any != False:
350354
raise ValueError("serialize_as_any is only supported in Pydantic v2")
355+
if fallback is not None:
356+
raise ValueError("fallback is only supported in Pydantic v2")
351357
return super().json( # type: ignore[reportDeprecated]
352358
indent=indent,
353359
include=include,
354360
exclude=exclude,
355-
by_alias=by_alias,
361+
by_alias=by_alias if by_alias is not None else False,
356362
exclude_unset=exclude_unset,
357363
exclude_defaults=exclude_defaults,
358364
exclude_none=exclude_none,

0 commit comments

Comments
 (0)