Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.7"
".": "0.1.0-alpha.8"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 29
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-2788217b7ad7d61d1a77800bc5ff12a6810f1692d4d770b72fa8f898c6a055ab.yml
openapi_spec_hash: 4423bf747e228484547b441468a9f156
config_hash: f4b37a468a2e67394c9d35f080d37c51
configured_endpoints: 30
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-0d7d82bff8a18b03e0cd1cbf8609c3026bb07db851bc6f9166032045a9925eea.yml
openapi_spec_hash: 8ce211dfa6fece24b1413e91ba55210a
config_hash: 2e6a171ce57a4a6a8e8dcd3dd893d8cc
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.1.0-alpha.8 (2025-04-30)

Full Changelog: [v0.1.0-alpha.7...v0.1.0-alpha.8](https://github.com/replicate/replicate-python-stainless/compare/v0.1.0-alpha.7...v0.1.0-alpha.8)

### Features

* **api:** api update ([a5aa64a](https://github.com/replicate/replicate-python-stainless/commit/a5aa64a71517fdf74e61e4debe68fba458f2e380))
* **client:** add support for model queries ([6df1fd6](https://github.com/replicate/replicate-python-stainless/commit/6df1fd6b994373a49b602258a8064998c88a0eca))

## 0.1.0-alpha.7 (2025-04-24)

Full Changelog: [v0.1.0-alpha.6...v0.1.0-alpha.7](https://github.com/replicate/replicate-python-stainless/compare/v0.1.0-alpha.6...v0.1.0-alpha.7)
Expand Down
1 change: 1 addition & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Methods:
- <code title="get /models">client.models.<a href="./src/replicate/resources/models/models.py">list</a>() -> <a href="./src/replicate/types/model_list_response.py">SyncCursorURLPage[ModelListResponse]</a></code>
- <code title="delete /models/{model_owner}/{model_name}">client.models.<a href="./src/replicate/resources/models/models.py">delete</a>(model_name, \*, model_owner) -> None</code>
- <code title="get /models/{model_owner}/{model_name}">client.models.<a href="./src/replicate/resources/models/models.py">get</a>(model_name, \*, model_owner) -> None</code>
- <code title="query /models">client.models.<a href="./src/replicate/resources/models/models.py">search</a>(\*\*<a href="src/replicate/types/model_search_params.py">params</a>) -> None</code>

## Examples

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "replicate-stainless"
version = "0.1.0-alpha.7"
version = "0.1.0-alpha.8"
description = "The official Python library for the replicate-client API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
28 changes: 28 additions & 0 deletions src/replicate/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,20 @@ def post(
)
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))

def query(
self,
path: str,
*,
cast_to: Type[ResponseT],
body: Body | None = None,
options: RequestOptions = {},
files: RequestFiles | None = None,
) -> ResponseT:
opts = FinalRequestOptions.construct(
method="query", url=path, json_data=body, files=to_httpx_files(files), **options
)
return self.request(cast_to, opts)

def patch(
self,
path: str,
Expand Down Expand Up @@ -1709,6 +1723,20 @@ async def post(
)
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)

async def query(
self,
path: str,
*,
cast_to: Type[ResponseT],
body: Body | None = None,
options: RequestOptions = {},
files: RequestFiles | None = None,
) -> ResponseT:
opts = FinalRequestOptions.construct(
method="query", url=path, json_data=body, files=await async_to_httpx_files(files), **options
)
return await self.request(cast_to, opts)

async def patch(
self,
path: str,
Expand Down
2 changes: 2 additions & 0 deletions src/replicate/_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self, client: ReplicateClient) -> None:
self._put = client.put
self._delete = client.delete
self._get_api_list = client.get_api_list
self._query = client.query

def _sleep(self, seconds: float) -> None:
time.sleep(seconds)
Expand All @@ -38,6 +39,7 @@ def __init__(self, client: AsyncReplicateClient) -> None:
self._put = client.put
self._delete = client.delete
self._get_api_list = client.get_api_list
self._query = client.query

async def _sleep(self, seconds: float) -> None:
await anyio.sleep(seconds)
2 changes: 1 addition & 1 deletion src/replicate/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "replicate"
__version__ = "0.1.0-alpha.7" # x-release-please-version
__version__ = "0.1.0-alpha.8" # x-release-please-version
116 changes: 115 additions & 1 deletion src/replicate/resources/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
ReadmeResourceWithStreamingResponse,
AsyncReadmeResourceWithStreamingResponse,
)
from ...types import model_create_params
from ...types import model_create_params, model_search_params
from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
from ..._utils import maybe_transform, async_maybe_transform
from .examples import (
Expand Down Expand Up @@ -404,6 +404,57 @@ def get(
cast_to=NoneType,
)

def search(
self,
*,
body: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> None:
"""
Get a list of public models matching a search query.

Example cURL request:

```console
curl -s -X QUERY \\
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \\
-H "Content-Type: text/plain" \\
-d "hello" \\
https://api.replicate.com/v1/models
```

The response will be a paginated JSON object containing an array of model
objects.

See the [`models.get`](#models.get) docs for more details about the model
object.

Args:
body: The search query

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
return self._query(
"/models",
body=maybe_transform(body, model_search_params.ModelSearchParams),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=NoneType,
)


class AsyncModelsResource(AsyncAPIResource):
@cached_property
Expand Down Expand Up @@ -753,6 +804,57 @@ async def get(
cast_to=NoneType,
)

async def search(
self,
*,
body: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> None:
"""
Get a list of public models matching a search query.

Example cURL request:

```console
curl -s -X QUERY \\
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \\
-H "Content-Type: text/plain" \\
-d "hello" \\
https://api.replicate.com/v1/models
```

The response will be a paginated JSON object containing an array of model
objects.

See the [`models.get`](#models.get) docs for more details about the model
object.

Args:
body: The search query

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
return await self._query(
"/models",
body=await async_maybe_transform(body, model_search_params.ModelSearchParams),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=NoneType,
)


class ModelsResourceWithRawResponse:
def __init__(self, models: ModelsResource) -> None:
Expand All @@ -770,6 +872,9 @@ def __init__(self, models: ModelsResource) -> None:
self.get = to_raw_response_wrapper(
models.get,
)
self.search = to_raw_response_wrapper(
models.search,
)

@cached_property
def examples(self) -> ExamplesResourceWithRawResponse:
Expand Down Expand Up @@ -804,6 +909,9 @@ def __init__(self, models: AsyncModelsResource) -> None:
self.get = async_to_raw_response_wrapper(
models.get,
)
self.search = async_to_raw_response_wrapper(
models.search,
)

@cached_property
def examples(self) -> AsyncExamplesResourceWithRawResponse:
Expand Down Expand Up @@ -838,6 +946,9 @@ def __init__(self, models: ModelsResource) -> None:
self.get = to_streamed_response_wrapper(
models.get,
)
self.search = to_streamed_response_wrapper(
models.search,
)

@cached_property
def examples(self) -> ExamplesResourceWithStreamingResponse:
Expand Down Expand Up @@ -872,6 +983,9 @@ def __init__(self, models: AsyncModelsResource) -> None:
self.get = async_to_streamed_response_wrapper(
models.get,
)
self.search = async_to_streamed_response_wrapper(
models.search,
)

@cached_property
def examples(self) -> AsyncExamplesResourceWithStreamingResponse:
Expand Down
22 changes: 18 additions & 4 deletions src/replicate/resources/predictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def create(

```console
curl -s -X POST -H 'Prefer: wait' \\
-d '{"version": "5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa", "input": {"text": "Alice"}}' \\
-d '{"version": "replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa", "input": {"text": "Alice"}}' \\
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \\
-H 'Content-Type: application/json' \\
https://api.replicate.com/v1/predictions
Expand Down Expand Up @@ -110,7 +110,14 @@ def create(
- you don't want to upload and host the file somewhere
- you don't need to use the file again (Replicate will not store it)

version: The ID of the model version that you want to run.
version: The ID of the model version that you want to run. This can be specified in two
formats:

1. Just the 64-character version ID:
`9dcd6d78e7c6560c340d916fe32e9f24aabfa331e5cce95fe31f77fb03121426`
2. Full model identifier with version ID in the format `{owner}/{model}:{id}`.
For example,
`replicate/hello-world:9dcd6d78e7c6560c340d916fe32e9f24aabfa331e5cce95fe31f77fb03121426`

stream: **This field is deprecated.**

Expand Down Expand Up @@ -484,7 +491,7 @@ async def create(

```console
curl -s -X POST -H 'Prefer: wait' \\
-d '{"version": "5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa", "input": {"text": "Alice"}}' \\
-d '{"version": "replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa", "input": {"text": "Alice"}}' \\
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \\
-H 'Content-Type: application/json' \\
https://api.replicate.com/v1/predictions
Expand Down Expand Up @@ -521,7 +528,14 @@ async def create(
- you don't want to upload and host the file somewhere
- you don't need to use the file again (Replicate will not store it)

version: The ID of the model version that you want to run.
version: The ID of the model version that you want to run. This can be specified in two
formats:

1. Just the 64-character version ID:
`9dcd6d78e7c6560c340d916fe32e9f24aabfa331e5cce95fe31f77fb03121426`
2. Full model identifier with version ID in the format `{owner}/{model}:{id}`.
For example,
`replicate/hello-world:9dcd6d78e7c6560c340d916fe32e9f24aabfa331e5cce95fe31f77fb03121426`

stream: **This field is deprecated.**

Expand Down
1 change: 1 addition & 0 deletions src/replicate/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .prediction_output import PredictionOutput as PredictionOutput
from .model_create_params import ModelCreateParams as ModelCreateParams
from .model_list_response import ModelListResponse as ModelListResponse
from .model_search_params import ModelSearchParams as ModelSearchParams
from .account_get_response import AccountGetResponse as AccountGetResponse
from .training_get_response import TrainingGetResponse as TrainingGetResponse
from .hardware_list_response import HardwareListResponse as HardwareListResponse
Expand Down
12 changes: 12 additions & 0 deletions src/replicate/types/model_search_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing_extensions import Required, TypedDict

__all__ = ["ModelSearchParams"]


class ModelSearchParams(TypedDict, total=False):
body: Required[str]
"""The search query"""
11 changes: 10 additions & 1 deletion src/replicate/types/prediction_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ class PredictionCreateParams(TypedDict, total=False):
"""

version: Required[str]
"""The ID of the model version that you want to run."""
"""The ID of the model version that you want to run.

This can be specified in two formats:

1. Just the 64-character version ID:
`9dcd6d78e7c6560c340d916fe32e9f24aabfa331e5cce95fe31f77fb03121426`
2. Full model identifier with version ID in the format `{owner}/{model}:{id}`.
For example,
`replicate/hello-world:9dcd6d78e7c6560c340d916fe32e9f24aabfa331e5cce95fe31f77fb03121426`
"""

stream: bool
"""**This field is deprecated.**
Expand Down
Loading