diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 68f4960..66603b7 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "2.0.0-alpha.28"
+ ".": "2.0.0-alpha.29"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index 627f641..276888e 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
-configured_endpoints: 36
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-8b68f03c8602e25ede74e66221e04bb17ac1f3170b8de49b8311fbe492636245.yml
-openapi_spec_hash: 81a7c6f32c6d77c1f329ca5a3c700a7a
-config_hash: 407acf62c906ee301314f2d23cdb58b1
+configured_endpoints: 37
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-7a537f433b0b71a42a3d53ce6182cc06790157bbb379461eed93cdb68659bc92.yml
+openapi_spec_hash: 5c7633dce3ece58e21f74d826946914c
+config_hash: 2c7c9d1642de34f563e0774bb1cd0ff0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1b486c4..3eca890 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,28 @@
# Changelog
+## 2.0.0-alpha.29 (2025-10-10)
+
+Full Changelog: [v2.0.0-alpha.28...v2.0.0-alpha.29](https://github.com/replicate/replicate-python-stainless/compare/v2.0.0-alpha.28...v2.0.0-alpha.29)
+
+### Features
+
+* add deprecated `replicate.stream()` for v1 compatibility ([#79](https://github.com/replicate/replicate-python-stainless/issues/79)) ([79b69bd](https://github.com/replicate/replicate-python-stainless/commit/79b69bd84448ceb55e7f683eea54dbc98cb3d9b2))
+* **api:** add models.update() operation ([2605ecc](https://github.com/replicate/replicate-python-stainless/commit/2605ecc5201017d6ec0769b39860b9e78ab950d7))
+
+
+### Chores
+
+* **internal:** detect missing future annotations with ruff ([26638e7](https://github.com/replicate/replicate-python-stainless/commit/26638e7a26c66b578a643e6491966edaf0ade528))
+* update OpenAPI spec and rebuild SDKs ([384c14f](https://github.com/replicate/replicate-python-stainless/commit/384c14fdeaebcbcc0ea41ec0376ab8037e8843cc))
+* update OpenAPI spec and rebuild SDKs ([51336e2](https://github.com/replicate/replicate-python-stainless/commit/51336e2509de93fa22a4029ae50cc78e95b40728))
+* update OpenAPI spec and rebuild SDKs ([7deb277](https://github.com/replicate/replicate-python-stainless/commit/7deb277d4b1723babf4ce1ddfd15aa2dcc7a55c9))
+* update OpenAPI spec and rebuild SDKs ([d5ee9ad](https://github.com/replicate/replicate-python-stainless/commit/d5ee9adef946014f0d192515f948cc40f69b9942))
+
+
+### Documentation
+
+* add migration guide for upgrading from v1 to v2 ([#76](https://github.com/replicate/replicate-python-stainless/issues/76)) ([5f57722](https://github.com/replicate/replicate-python-stainless/commit/5f5772200a03012bb11c8c12a6e7a0f7d683d0cf))
+
## 2.0.0-alpha.28 (2025-10-07)
Full Changelog: [v2.0.0-alpha.27...v2.0.0-alpha.28](https://github.com/replicate/replicate-python-stainless/compare/v2.0.0-alpha.27...v2.0.0-alpha.28)
diff --git a/UPGRADING.md b/UPGRADING.md
new file mode 100644
index 0000000..8a3f48d
--- /dev/null
+++ b/UPGRADING.md
@@ -0,0 +1,637 @@
+# Upgrading from v1 to v2
+
+This guide will help you migrate an existing codebase from the v1 Replicate Python SDK to v2. The v2 SDK is a complete rewrite built in partnership with [Stainless](https://www.stainless.com/customers/replicate), the company that helps design and maintain SDKs for companies like OpenAI, Anthropic, and Cloudflare. The v2 SDK is largely autogenerated from Replicate's OpenAPI specification, providing better type safety, more consistent error handling, and improved async support. Check out the [v2 release notes](https://github.com/replicate/replicate-python-stainless/releases) for more details.
+
+ā If you are working on a new project, you don't need to read this document.
+
+This doc is intended for both humans and agents. š§š½āš¦° š¤ š¤
+
+## Installing the v2 SDK
+
+Use pip to install the latest pre-release version of the v2 SDK:
+
+```sh
+pip install --pre replicate
+```
+
+## Pinning to the legacy v1 SDK
+
+You are not required to upgrade to the new 2.x version. If you're already using the 1.x version and want to continue using it, pin the version number in your dependency files.
+
+Here's an example `requirements.txt`:
+
+```
+replicate>=1.0.0,<2.0.0
+```
+
+Here's an example `pyproject.toml`:
+
+```toml
+[project]
+dependencies = [
+ "replicate>=1.0.0,<2.0.0",
+]
+```
+
+## Quick migration checklist
+
+- Update client initialization to use `Replicate()` instead of `Client()` and `bearer_token` instead of `api_token` - [details](#client-initialization-and-authentication)
+- Replace prediction instance methods with client methods (e.g., `replicate.predictions.wait(id)` instead of `prediction.wait()`) - [details](#predictions)
+- Update async code to use `AsyncReplicate` client or context-aware module-level functions - [details](#async-support)
+- Add keyword arguments to all API calls - [details](#models-and-versions)
+- Update exception handling to use new exception types - [details](#error-handling)
+
+## Client initialization and authentication
+
+In both the v1 and v2 SDKs, the simplest way to import and use the library is to import the `replicate` module and use the module-level functions like `replicate.run()`, without explicitly instantiating a client:
+
+```python
+import replicate
+
+output = replicate.run(...)
+```
+
+āļø This approach expects a `REPLICATE_API_TOKEN` variable to be present in the environment.
+
+---
+
+For cases where you need to instantiate a client (e.g., for custom configuration or async support), the client class name and parameter names have changed in v2:
+
+### Before (v1)
+
+```python
+import os
+import replicate
+from replicate import Client
+
+client = Client(api_token=os.environ["REPLICATE_API_TOKEN"])
+```
+
+### After (v2)
+
+```python
+import os
+import replicate
+from replicate import Replicate
+
+client = Replicate(bearer_token=os.environ["REPLICATE_API_TOKEN"])
+```
+
+The `api_token` parameter is still accepted for backward compatibility, but `bearer_token` is preferred.
+
+## Streaming output
+
+Streaming works differently in v2. Prediction objects no longer have a `stream()` method and the `replicate.stream()` method is deprecated.
+
+You should use `replicate.use()` with `streaming=True` for streaming output in the v2 SDK.
+
+### Before (v1)
+
+```python
+# Top-level streaming
+for event in replicate.stream(
+ "anthropic/claude-4.5-sonnet",
+ input={"prompt": "Write a haiku"}
+):
+ print(str(event), end="")
+
+# Streaming from prediction object
+prediction = replicate.predictions.create(..., stream=True)
+for event in prediction.stream():
+ print(str(event), end="")
+```
+
+### After (v2)
+
+```python
+# Use replicate.use() with streaming=True
+model = replicate.use("anthropic/claude-4.5-sonnet", streaming=True)
+for event in model(prompt="Write a haiku"):
+ print(str(event), end="")
+
+# Streaming from prediction object is not available
+prediction = replicate.predictions.create(...)
+# prediction.stream() is not available in v2
+```
+
+Note: `replicate.stream()` still works in v2 but is deprecated and will be removed in a future version.
+
+## Predictions
+
+Prediction objects in the v2 client no longer have instance methods like `wait()`, `cancel()`, and `reload()`. These have been removed in favor of client methods (e.g., use `replicate.predictions.wait(prediction.id)` instead of `prediction.wait()`).
+
+### Creating predictions
+
+#### Before (v1)
+
+```python
+# Create via model shorthand
+prediction = replicate.predictions.create(
+ model="owner/model",
+ input={"prompt": "..."}
+)
+```
+
+#### After (v2)
+
+```python
+# Create with keyword arguments model_owner and model_name
+prediction = replicate.models.predictions.create(
+ model_owner="owner",
+ model_name="model",
+ input={"prompt": "..."}
+)
+```
+
+### Getting predictions
+
+#### Before (v1)
+
+```python
+prediction = replicate.predictions.get("prediction_id")
+```
+
+#### After (v2)
+
+```python
+# Note: keyword argument required
+prediction = replicate.predictions.get(prediction_id="prediction_id")
+```
+
+### Waiting for predictions
+
+#### Before (v1)
+
+```python
+prediction = replicate.predictions.create(...)
+prediction.wait()
+```
+
+#### After (v2)
+
+```python
+prediction = replicate.predictions.create(...)
+# prediction.wait() is not available
+
+# Use resource method instead
+prediction = replicate.predictions.wait(prediction.id)
+```
+
+### Canceling predictions
+
+#### Before (v1)
+
+```python
+prediction = replicate.predictions.get("prediction_id")
+prediction.cancel()
+```
+
+#### After (v2)
+
+```python
+prediction = replicate.predictions.get(prediction_id="prediction_id")
+# prediction.cancel() is not available
+
+# Use resource method instead
+prediction = replicate.predictions.cancel(prediction.id)
+```
+
+### Reloading predictions
+
+#### Before (v1)
+
+```python
+prediction = replicate.predictions.get("prediction_id")
+prediction.reload()
+print(prediction.status)
+```
+
+#### After (v2)
+
+```python
+prediction = replicate.predictions.get(prediction_id="prediction_id")
+# prediction.reload() is not available
+
+# Fetch fresh data instead
+prediction = replicate.predictions.get(prediction_id=prediction.id)
+print(prediction.status)
+```
+
+## Async support
+
+Async functionality has been redesigned. Instead of separate `async_*` methods, v2 uses a dedicated `AsyncReplicate` client.
+
+### Before (v1)
+
+```python
+import replicate
+
+# Async methods with async_ prefix
+output = await replicate.async_run(...)
+
+for event in replicate.async_stream(...):
+ print(event)
+
+prediction = await replicate.predictions.async_create(...)
+prediction = await replicate.predictions.async_get("id")
+await prediction.async_wait()
+```
+
+### After (v2)
+
+```python
+from replicate import AsyncReplicate
+
+# Use AsyncReplicate client
+client = AsyncReplicate()
+
+# Same method names, no async_ prefix
+output = await client.run(...)
+
+async for event in client.stream(...):
+ print(event)
+
+prediction = await client.predictions.create(...)
+prediction = await client.predictions.get(prediction_id="id")
+prediction = await client.predictions.wait(prediction.id)
+
+# Or use module-level functions (context-aware)
+output = await replicate.run(...)
+async for event in replicate.stream(...):
+ print(event)
+```
+
+## Error handling
+
+Error handling is more granular in v2, with specific exception types for each HTTP status code.
+
+### Before (v1)
+
+```python
+from replicate.exceptions import ReplicateError, ModelError
+
+try:
+ output = replicate.run(...)
+except ModelError as e:
+ print(f"Model failed: {e.prediction.error}")
+except ReplicateError as e:
+ print(f"API error: {e}")
+```
+
+### After (v2)
+
+```python
+from replicate.exceptions import (
+ ModelError,
+ NotFoundError,
+ AuthenticationError,
+ RateLimitError,
+ APIStatusError
+)
+
+try:
+ output = replicate.run(...)
+except ModelError as e:
+ print(f"Model failed: {e.prediction.error}")
+except NotFoundError as e:
+ print(f"Not found: {e.message}")
+except RateLimitError as e:
+ print(f"Rate limited: {e.message}")
+except APIStatusError as e:
+ print(f"API error {e.status_code}: {e.message}")
+```
+
+Available exception types in v2:
+
+- `APIError` - Base exception for all API errors
+- `APIConnectionError` - Network connection errors
+- `APITimeoutError` - Request timeout errors
+- `APIStatusError` - Base for HTTP status errors
+- `BadRequestError` - 400 errors
+- `AuthenticationError` - 401 errors
+- `PermissionDeniedError` - 403 errors
+- `NotFoundError` - 404 errors
+- `ConflictError` - 409 errors
+- `UnprocessableEntityError` - 422 errors
+- `RateLimitError` - 429 errors
+- `InternalServerError` - 500+ errors
+- `ModelError` - Model execution failures
+
+## Pagination
+
+Pagination is more streamlined in v2 with auto-pagination support.
+
+### Before (v1)
+
+```python
+# Manual pagination
+page = replicate.predictions.list()
+for prediction in page.results:
+ print(prediction.id)
+
+if page.next:
+ next_page = replicate.predictions.list(cursor=page.next)
+
+# Auto-pagination
+for page in replicate.paginate(replicate.predictions.list):
+ for prediction in page.results:
+ print(prediction.id)
+```
+
+### After (v2)
+
+```python
+# Auto-pagination: iterate through all pages automatically
+for prediction in replicate.predictions.list():
+ print(prediction.id)
+ # Automatically fetches more pages as needed
+
+# Manual pagination (if needed)
+page = replicate.predictions.list()
+if page.has_next_page():
+ next_page = page.get_next_page()
+
+# Access results from a single page
+page = replicate.predictions.list()
+for prediction in page.results:
+ print(prediction.id)
+```
+
+## Models and versions
+
+Model and version access uses keyword arguments throughout, instead of shorthand positional arguments.
+
+The new keyword argument syntax in v2 is more verbose but clearer and more consistent with Replicate's HTTP API, and consistent across all SDKs in different programming languages.
+
+### Before (v1)
+
+```python
+# Get model
+model = replicate.models.get("owner/name")
+
+# Get version from model
+version = model.versions.get("version_id")
+
+# List versions
+versions = model.versions.list()
+```
+
+### After (v2)
+
+```python
+# Get model (keyword arguments required)
+model = replicate.models.get(
+ model_owner="owner",
+ model_name="name"
+)
+
+# Get version (no shorthand via model object)
+version = replicate.models.versions.get(
+ model_owner="owner",
+ model_name="name",
+ version_id="version_id"
+)
+
+# List versions
+versions = replicate.models.versions.list(
+ model_owner="owner",
+ model_name="name"
+)
+```
+
+The `model.versions` shorthand is not available in v2.
+
+## Trainings
+
+Training objects do not have the `.wait()` and `.cancel()` instance methods in v2.
+
+### Before (v1)
+
+```python
+training = replicate.trainings.create(
+ version="version_id",
+ input={"train_data": "https://..."},
+ destination="owner/model"
+)
+
+# Wait and cancel
+training.wait()
+training.cancel()
+```
+
+### After (v2)
+
+```python
+training = replicate.trainings.create(
+ model_owner="owner",
+ model_name="model",
+ version_id="version_id",
+ input={"train_data": "https://..."},
+ destination="owner/new-model"
+)
+
+# No instance methods available
+# Use client methods instead
+
+# Wait for training (no trainings.wait() available)
+# Poll with get() instead
+while True:
+ training = replicate.trainings.get(training_id=training.id)
+ if training.status in ["succeeded", "failed", "canceled"]:
+ break
+ time.sleep(1)
+
+# Cancel training
+training = replicate.trainings.cancel(training_id=training.id)
+```
+
+## File uploads
+
+File upload handling has changed slightly.
+
+### Before (v1)
+
+```python
+# Upload file
+file = replicate.files.create(
+ file=open("image.jpg", "rb"),
+ filename="image.jpg"
+)
+
+# Access URL
+url = file.urls["get"]
+```
+
+### After (v2)
+
+```python
+# Upload file (supports file handle, bytes, or PathLike)
+with open("image.jpg", "rb") as f:
+ file = replicate.files.create(
+ content=f, # Can pass file handle directly
+ filename="image.jpg"
+ )
+
+# Or read into memory if needed
+with open("image.jpg", "rb") as f:
+ file = replicate.files.create(
+ content=f.read(),
+ filename="image.jpg"
+ )
+
+# Access URL (property instead of dict)
+url = file.urls.get
+```
+
+File inputs to predictions work the same way in both versions.
+
+## Collections
+
+Collections API uses keyword arguments in v2.
+
+### Before (v1)
+
+```python
+collection = replicate.collections.get("collection_slug")
+models = collection.models
+```
+
+### After (v2)
+
+```python
+collection = replicate.collections.get(collection_slug="collection_slug")
+
+# Models accessed via nested resource
+models = replicate.collections.models.list(collection_slug="collection_slug")
+```
+
+## Webhooks
+
+Webhook validation is compatible between v1 and v2.
+
+### Before (v1)
+
+```python
+from replicate.webhook import Webhooks
+
+secret = replicate.webhooks.default.secret()
+Webhooks.validate(request, secret)
+```
+
+### After (v2)
+
+```python
+from replicate.resources.webhooks import Webhooks
+
+secret = replicate.webhooks.default.secret()
+Webhooks.validate(request, secret)
+```
+
+The validation logic is identical; only the import paths differ.
+
+## Experimental use() interface
+
+The experimental `use()` interface is available in both versions with similar functionality.
+
+### Before (v1)
+
+```python
+flux = replicate.use("black-forest-labs/flux-schnell")
+outputs = flux(prompt="astronaut on a horse")
+
+# Async support
+async_flux = replicate.use("black-forest-labs/flux-schnell")
+outputs = await async_flux(prompt="astronaut on a horse")
+```
+
+### After (v2)
+
+```python
+# Same interface
+flux = replicate.use("black-forest-labs/flux-schnell")
+outputs = flux(prompt="astronaut on a horse")
+
+# Async support (uses use_async parameter)
+async_flux = replicate.use("black-forest-labs/flux-schnell", use_async=True)
+outputs = await async_flux(prompt="astronaut on a horse")
+```
+
+## New features in v2
+
+### Models listing
+
+```python
+# List all models (not available in v1)
+for model in replicate.models.list():
+ print(model.name)
+```
+
+### Better type safety
+
+V2 includes comprehensive type hints generated from the OpenAPI spec, providing better IDE autocomplete and type checking.
+
+```python
+from replicate import Replicate
+from replicate.types import Prediction
+
+client: Replicate = Replicate()
+prediction: Prediction = client.predictions.get(prediction_id="...")
+```
+
+### HTTP client customization
+
+```python
+from replicate import Replicate, DefaultHttpxClient
+import httpx
+
+client = Replicate(
+ http_client=DefaultHttpxClient(
+ proxy="http://proxy.example.com",
+ transport=httpx.HTTPTransport(local_address="0.0.0.0")
+ ),
+ timeout=30.0,
+ max_retries=3
+)
+```
+
+### Raw response access
+
+```python
+# Access raw HTTP responses
+response = client.with_raw_response.predictions.get(prediction_id="...")
+print(response.headers)
+print(response.http_response.status_code)
+
+prediction = response.parse()
+```
+
+The response object is an [`APIResponse`](https://github.com/replicate/replicate-python-stainless/tree/main/src/replicate/_response.py) instance. See the [README](https://github.com/replicate/replicate-python-stainless#accessing-raw-response-data-eg-headers) for full documentation.
+
+### Streaming response wrapper
+
+```python
+# Stream response body
+with client.with_streaming_response.predictions.get(
+ prediction_id="..."
+) as response:
+ for chunk in response.iter_bytes():
+ process(chunk)
+```
+
+## Removed features
+
+The following features are not available in v2:
+
+- Prediction instance methods: `wait()`, `cancel()`, `reload()`, `stream()`, `output_iterator()`
+- Training instance methods: `cancel()`, `reload()`
+- Model instance methods: `predict()`
+- `model.versions` shorthand (use `replicate.models.versions` instead)
+- Separate `async_*` methods (use `AsyncReplicate` client)
+- Positional arguments (all methods that map to HTTP API operations like `models.get` and `collections.get` now require keyword arguments)
+
+## Getting help
+
+If you encounter issues during the migration process:
+
+- Check the [API documentation](https://replicate.com/docs/reference/http)
+- Open an issue on [GitHub](https://github.com/replicate/replicate-python-stainless/issues)
\ No newline at end of file
diff --git a/api.md b/api.md
index d037762..0e7526d 100644
--- a/api.md
+++ b/api.md
@@ -81,6 +81,7 @@ Types:
```python
from replicate.types import (
ModelCreateResponse,
+ ModelUpdateResponse,
ModelListResponse,
ModelGetResponse,
ModelSearchResponse,
@@ -90,7 +91,8 @@ from replicate.types import (
Methods:
- replicate.models.create(\*\*params) -> ModelCreateResponse
-- replicate.models.list() -> SyncCursorURLPage[ModelListResponse]
+- replicate.models.update(\*, model_owner, model_name, \*\*params) -> ModelUpdateResponse
+- replicate.models.list(\*\*params) -> SyncCursorURLPage[ModelListResponse]
- replicate.models.delete(\*, model_owner, model_name) -> None
- replicate.models.get(\*, model_owner, model_name) -> ModelGetResponse
- replicate.models.search(\*\*params) -> SyncCursorURLPage[ModelSearchResponse]
diff --git a/pyproject.toml b/pyproject.toml
index 5137c3d..b33b212 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "replicate"
-version = "2.0.0-alpha.28"
+version = "2.0.0-alpha.29"
description = "The official Python library for the replicate API"
dynamic = ["readme"]
license = "Apache-2.0"
@@ -225,6 +225,8 @@ select = [
"B",
# remove unused imports
"F401",
+ # check for missing future annotations
+ "FA102",
# bare except statements
"E722",
# unused arguments
@@ -247,6 +249,8 @@ unfixable = [
"T203",
]
+extend-safe-fixes = ["FA102"]
+
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"functools.lru_cache".msg = "This function does not retain type information for the wrapped function's arguments; The `lru_cache` function from `_utils` should be used instead"
diff --git a/src/replicate/_version.py b/src/replicate/_version.py
index 80a4c91..58c4d58 100644
--- a/src/replicate/_version.py
+++ b/src/replicate/_version.py
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
__title__ = "replicate"
-__version__ = "2.0.0-alpha.28" # x-release-please-version
+__version__ = "2.0.0-alpha.29" # x-release-please-version
diff --git a/src/replicate/resources/deployments/predictions.py b/src/replicate/resources/deployments/predictions.py
index 23a487c..cd56fa6 100644
--- a/src/replicate/resources/deployments/predictions.py
+++ b/src/replicate/resources/deployments/predictions.py
@@ -53,8 +53,8 @@ def create(
stream: bool | Omit = omit,
webhook: str | Omit = omit,
webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | Omit = omit,
+ cancel_after: str | Omit = omit,
prefer: str | Omit = omit,
- replicate_max_lifetime: str | Omit = omit,
# 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,
@@ -166,8 +166,8 @@ def create(
extra_headers = {
**strip_not_given(
{
+ "Cancel-After": cancel_after,
"Prefer": prefer,
- "Replicate-Max-Lifetime": replicate_max_lifetime,
}
),
**(extra_headers or {}),
@@ -219,8 +219,8 @@ async def create(
stream: bool | Omit = omit,
webhook: str | Omit = omit,
webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | Omit = omit,
+ cancel_after: str | Omit = omit,
prefer: str | Omit = omit,
- replicate_max_lifetime: str | Omit = omit,
# 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,
@@ -332,8 +332,8 @@ async def create(
extra_headers = {
**strip_not_given(
{
+ "Cancel-After": cancel_after,
"Prefer": prefer,
- "Replicate-Max-Lifetime": replicate_max_lifetime,
}
),
**(extra_headers or {}),
diff --git a/src/replicate/resources/models/models.py b/src/replicate/resources/models/models.py
index b9fa139..85ef431 100644
--- a/src/replicate/resources/models/models.py
+++ b/src/replicate/resources/models/models.py
@@ -14,7 +14,7 @@
ReadmeResourceWithStreamingResponse,
AsyncReadmeResourceWithStreamingResponse,
)
-from ...types import model_create_params, model_search_params
+from ...types import model_list_params, model_create_params, model_search_params, model_update_params
from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given
from ..._utils import maybe_transform, async_maybe_transform
from .examples import (
@@ -55,6 +55,7 @@
from ...types.model_list_response import ModelListResponse
from ...types.model_create_response import ModelCreateResponse
from ...types.model_search_response import ModelSearchResponse
+from ...types.model_update_response import ModelUpdateResponse
__all__ = ["ModelsResource", "AsyncModelsResource"]
@@ -206,9 +207,104 @@ def create(
cast_to=ModelCreateResponse,
)
+ def update(
+ self,
+ *,
+ model_owner: str,
+ model_name: str,
+ description: str | Omit = omit,
+ github_url: str | Omit = omit,
+ license_url: str | Omit = omit,
+ paper_url: str | Omit = omit,
+ readme: str | Omit = omit,
+ weights_url: str | Omit = omit,
+ # 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,
+ ) -> ModelUpdateResponse:
+ """
+ Update select properties of an existing model.
+
+ You can update the following properties:
+
+ - `description` - Model description
+ - `readme` - Model README content
+ - `github_url` - GitHub repository URL
+ - `paper_url` - Research paper URL
+ - `weights_url` - Model weights URL
+ - `license_url` - License URL
+
+ Example cURL request:
+
+ ```console
+ curl -X PATCH \\
+ https://api.replicate.com/v1/models/your-username/your-model-name \\
+ -H "Authorization: Token $REPLICATE_API_TOKEN" \\
+ -H "Content-Type: application/json" \\
+ -d '{
+ "description": "Detect hot dogs in images",
+ "readme": "# Hot Dog Detector\n\nš Ketchup, mustard, and onions...",
+ "github_url": "https://github.com/alice/hot-dog-detector",
+ "paper_url": "https://arxiv.org/abs/2504.17639",
+ "weights_url": "https://huggingface.co/alice/hot-dog-detector",
+ "license_url": "https://choosealicense.com/licenses/mit/"
+ }'
+ ```
+
+ The response will be the updated model object with all of its properties.
+
+ Args:
+ description: A description of the model.
+
+ github_url: A URL for the model's source code on GitHub.
+
+ license_url: A URL for the model's license.
+
+ paper_url: A URL for the model's paper.
+
+ readme: The README content of the model.
+
+ weights_url: A URL for the model's weights.
+
+ 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
+ """
+ if not model_owner:
+ raise ValueError(f"Expected a non-empty value for `model_owner` but received {model_owner!r}")
+ if not model_name:
+ raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}")
+ return self._patch(
+ f"/models/{model_owner}/{model_name}",
+ body=maybe_transform(
+ {
+ "description": description,
+ "github_url": github_url,
+ "license_url": license_url,
+ "paper_url": paper_url,
+ "readme": readme,
+ "weights_url": weights_url,
+ },
+ model_update_params.ModelUpdateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=ModelUpdateResponse,
+ )
+
def list(
self,
*,
+ sort_by: Literal["model_created_at", "latest_version_created_at"] | Omit = omit,
+ sort_direction: Literal["asc", "desc"] | Omit = omit,
# 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,
@@ -231,12 +327,56 @@ def list(
See the [`models.get`](#models.get) docs for more details about the model
object.
+
+ ## Sorting
+
+ You can sort the results using the `sort_by` and `sort_direction` query
+ parameters.
+
+ For example, to get the most recently created models:
+
+ ```console
+ curl -s \\
+ -H "Authorization: Bearer $REPLICATE_API_TOKEN" \\
+ "https://api.replicate.com/v1/models?sort_by=model_created_at&sort_direction=desc"
+ ```
+
+ Available sorting options:
+
+ - `model_created_at`: Sort by when the model was first created
+ - `latest_version_created_at`: Sort by when the model's latest version was
+ created (default)
+
+ Sort direction can be `asc` (ascending) or `desc` (descending, default).
+
+ Args:
+ sort_by: Field to sort models by. Defaults to `latest_version_created_at`.
+
+ sort_direction: Sort direction. Defaults to `desc` (descending, newest first).
+
+ 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
"""
return self._get_api_list(
"/models",
page=SyncCursorURLPage[ModelListResponse],
options=make_request_options(
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform(
+ {
+ "sort_by": sort_by,
+ "sort_direction": sort_direction,
+ },
+ model_list_params.ModelListParams,
+ ),
),
model=ModelListResponse,
)
@@ -605,9 +745,104 @@ async def create(
cast_to=ModelCreateResponse,
)
+ async def update(
+ self,
+ *,
+ model_owner: str,
+ model_name: str,
+ description: str | Omit = omit,
+ github_url: str | Omit = omit,
+ license_url: str | Omit = omit,
+ paper_url: str | Omit = omit,
+ readme: str | Omit = omit,
+ weights_url: str | Omit = omit,
+ # 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,
+ ) -> ModelUpdateResponse:
+ """
+ Update select properties of an existing model.
+
+ You can update the following properties:
+
+ - `description` - Model description
+ - `readme` - Model README content
+ - `github_url` - GitHub repository URL
+ - `paper_url` - Research paper URL
+ - `weights_url` - Model weights URL
+ - `license_url` - License URL
+
+ Example cURL request:
+
+ ```console
+ curl -X PATCH \\
+ https://api.replicate.com/v1/models/your-username/your-model-name \\
+ -H "Authorization: Token $REPLICATE_API_TOKEN" \\
+ -H "Content-Type: application/json" \\
+ -d '{
+ "description": "Detect hot dogs in images",
+ "readme": "# Hot Dog Detector\n\nš Ketchup, mustard, and onions...",
+ "github_url": "https://github.com/alice/hot-dog-detector",
+ "paper_url": "https://arxiv.org/abs/2504.17639",
+ "weights_url": "https://huggingface.co/alice/hot-dog-detector",
+ "license_url": "https://choosealicense.com/licenses/mit/"
+ }'
+ ```
+
+ The response will be the updated model object with all of its properties.
+
+ Args:
+ description: A description of the model.
+
+ github_url: A URL for the model's source code on GitHub.
+
+ license_url: A URL for the model's license.
+
+ paper_url: A URL for the model's paper.
+
+ readme: The README content of the model.
+
+ weights_url: A URL for the model's weights.
+
+ 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
+ """
+ if not model_owner:
+ raise ValueError(f"Expected a non-empty value for `model_owner` but received {model_owner!r}")
+ if not model_name:
+ raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}")
+ return await self._patch(
+ f"/models/{model_owner}/{model_name}",
+ body=await async_maybe_transform(
+ {
+ "description": description,
+ "github_url": github_url,
+ "license_url": license_url,
+ "paper_url": paper_url,
+ "readme": readme,
+ "weights_url": weights_url,
+ },
+ model_update_params.ModelUpdateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=ModelUpdateResponse,
+ )
+
def list(
self,
*,
+ sort_by: Literal["model_created_at", "latest_version_created_at"] | Omit = omit,
+ sort_direction: Literal["asc", "desc"] | Omit = omit,
# 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,
@@ -630,12 +865,56 @@ def list(
See the [`models.get`](#models.get) docs for more details about the model
object.
+
+ ## Sorting
+
+ You can sort the results using the `sort_by` and `sort_direction` query
+ parameters.
+
+ For example, to get the most recently created models:
+
+ ```console
+ curl -s \\
+ -H "Authorization: Bearer $REPLICATE_API_TOKEN" \\
+ "https://api.replicate.com/v1/models?sort_by=model_created_at&sort_direction=desc"
+ ```
+
+ Available sorting options:
+
+ - `model_created_at`: Sort by when the model was first created
+ - `latest_version_created_at`: Sort by when the model's latest version was
+ created (default)
+
+ Sort direction can be `asc` (ascending) or `desc` (descending, default).
+
+ Args:
+ sort_by: Field to sort models by. Defaults to `latest_version_created_at`.
+
+ sort_direction: Sort direction. Defaults to `desc` (descending, newest first).
+
+ 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
"""
return self._get_api_list(
"/models",
page=AsyncCursorURLPage[ModelListResponse],
options=make_request_options(
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform(
+ {
+ "sort_by": sort_by,
+ "sort_direction": sort_direction,
+ },
+ model_list_params.ModelListParams,
+ ),
),
model=ModelListResponse,
)
@@ -864,6 +1143,9 @@ def __init__(self, models: ModelsResource) -> None:
self.create = to_raw_response_wrapper(
models.create,
)
+ self.update = to_raw_response_wrapper(
+ models.update,
+ )
self.list = to_raw_response_wrapper(
models.list,
)
@@ -901,6 +1183,9 @@ def __init__(self, models: AsyncModelsResource) -> None:
self.create = async_to_raw_response_wrapper(
models.create,
)
+ self.update = async_to_raw_response_wrapper(
+ models.update,
+ )
self.list = async_to_raw_response_wrapper(
models.list,
)
@@ -938,6 +1223,9 @@ def __init__(self, models: ModelsResource) -> None:
self.create = to_streamed_response_wrapper(
models.create,
)
+ self.update = to_streamed_response_wrapper(
+ models.update,
+ )
self.list = to_streamed_response_wrapper(
models.list,
)
@@ -975,6 +1263,9 @@ def __init__(self, models: AsyncModelsResource) -> None:
self.create = async_to_streamed_response_wrapper(
models.create,
)
+ self.update = async_to_streamed_response_wrapper(
+ models.update,
+ )
self.list = async_to_streamed_response_wrapper(
models.list,
)
diff --git a/src/replicate/resources/models/predictions.py b/src/replicate/resources/models/predictions.py
index eebedfd..e001402 100644
--- a/src/replicate/resources/models/predictions.py
+++ b/src/replicate/resources/models/predictions.py
@@ -55,9 +55,10 @@ def create(
stream: bool | Omit = omit,
webhook: str | Omit = omit,
webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | Omit = omit,
+ cancel_after: str | Omit = omit,
prefer: str | Omit = omit,
- replicate_max_lifetime: str | Omit = omit,
file_encoding_strategy: Optional["FileEncodingStrategy"] = None,
+ replicate_max_lifetime: str | Omit = omit,
# 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,
@@ -173,8 +174,8 @@ def create(
extra_headers = {
**strip_not_given(
{
+ "Cancel-After": cancel_after,
"Prefer": prefer,
- "Replicate-Max-Lifetime": replicate_max_lifetime,
}
),
**(extra_headers or {}),
@@ -226,9 +227,10 @@ async def create(
stream: bool | Omit = omit,
webhook: str | Omit = omit,
webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | Omit = omit,
+ cancel_after: str | Omit = omit,
prefer: str | Omit = omit,
- replicate_max_lifetime: str | Omit = omit,
file_encoding_strategy: Optional["FileEncodingStrategy"] = None,
+ replicate_max_lifetime: str | Omit = omit,
# 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,
@@ -344,8 +346,8 @@ async def create(
extra_headers = {
**strip_not_given(
{
+ "Cancel-After": cancel_after,
"Prefer": prefer,
- "Replicate-Max-Lifetime": replicate_max_lifetime,
}
),
**(extra_headers or {}),
diff --git a/src/replicate/resources/predictions.py b/src/replicate/resources/predictions.py
index afd49a7..85b1292 100644
--- a/src/replicate/resources/predictions.py
+++ b/src/replicate/resources/predictions.py
@@ -66,9 +66,10 @@ def create(
stream: bool | Omit = omit,
webhook: str | Omit = omit,
webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | Omit = omit,
+ cancel_after: str | Omit = omit,
prefer: str | Omit = omit,
- replicate_max_lifetime: str | Omit = omit,
file_encoding_strategy: Optional["FileEncodingStrategy"] = None,
+ replicate_max_lifetime: str | Omit = omit,
# 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,
@@ -190,8 +191,8 @@ def create(
extra_headers = {
**strip_not_given(
{
+ "Cancel-After": cancel_after,
"Prefer": prefer,
- "Replicate-Max-Lifetime": replicate_max_lifetime,
}
),
**(extra_headers or {}),
@@ -528,9 +529,10 @@ async def create(
stream: bool | Omit = omit,
webhook: str | Omit = omit,
webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | Omit = omit,
+ cancel_after: str | Omit = omit,
prefer: str | Omit = omit,
- replicate_max_lifetime: str | Omit = omit,
file_encoding_strategy: Optional["FileEncodingStrategy"] = None,
+ replicate_max_lifetime: str | Omit = omit,
# 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,
@@ -652,8 +654,8 @@ async def create(
extra_headers = {
**strip_not_given(
{
+ "Cancel-After": cancel_after,
"Prefer": prefer,
- "Replicate-Max-Lifetime": replicate_max_lifetime,
}
),
**(extra_headers or {}),
diff --git a/src/replicate/types/__init__.py b/src/replicate/types/__init__.py
index 3f375e8..1763abb 100644
--- a/src/replicate/types/__init__.py
+++ b/src/replicate/types/__init__.py
@@ -5,18 +5,21 @@
from .prediction import Prediction as Prediction
from .search_response import SearchResponse as SearchResponse
from .file_get_response import FileGetResponse as FileGetResponse
+from .model_list_params import ModelListParams as ModelListParams
from .file_create_params import FileCreateParams as FileCreateParams
from .file_list_response import FileListResponse as FileListResponse
from .model_get_response import ModelGetResponse as ModelGetResponse
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 .model_update_params import ModelUpdateParams as ModelUpdateParams
from .account_get_response import AccountGetResponse as AccountGetResponse
from .client_search_params import ClientSearchParams as ClientSearchParams
from .file_create_response import FileCreateResponse as FileCreateResponse
from .file_download_params import FileDownloadParams as FileDownloadParams
from .model_create_response import ModelCreateResponse as ModelCreateResponse
from .model_search_response import ModelSearchResponse as ModelSearchResponse
+from .model_update_response import ModelUpdateResponse as ModelUpdateResponse
from .training_get_response import TrainingGetResponse as TrainingGetResponse
from .hardware_list_response import HardwareListResponse as HardwareListResponse
from .prediction_list_params import PredictionListParams as PredictionListParams
diff --git a/src/replicate/types/deployments/prediction_create_params.py b/src/replicate/types/deployments/prediction_create_params.py
index 6bc0863..9c4c98d 100644
--- a/src/replicate/types/deployments/prediction_create_params.py
+++ b/src/replicate/types/deployments/prediction_create_params.py
@@ -93,6 +93,6 @@ class PredictionCreateParams(TypedDict, total=False):
sent regardless of throttling.
"""
- prefer: Annotated[str, PropertyInfo(alias="Prefer")]
+ cancel_after: Annotated[str, PropertyInfo(alias="Cancel-After")]
- replicate_max_lifetime: Annotated[str, PropertyInfo(alias="Replicate-Max-Lifetime")]
+ prefer: Annotated[str, PropertyInfo(alias="Prefer")]
diff --git a/src/replicate/types/model_list_params.py b/src/replicate/types/model_list_params.py
new file mode 100644
index 0000000..59d7d9a
--- /dev/null
+++ b/src/replicate/types/model_list_params.py
@@ -0,0 +1,15 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import Literal, TypedDict
+
+__all__ = ["ModelListParams"]
+
+
+class ModelListParams(TypedDict, total=False):
+ sort_by: Literal["model_created_at", "latest_version_created_at"]
+ """Field to sort models by. Defaults to `latest_version_created_at`."""
+
+ sort_direction: Literal["asc", "desc"]
+ """Sort direction. Defaults to `desc` (descending, newest first)."""
diff --git a/src/replicate/types/model_update_params.py b/src/replicate/types/model_update_params.py
new file mode 100644
index 0000000..956f416
--- /dev/null
+++ b/src/replicate/types/model_update_params.py
@@ -0,0 +1,31 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import Required, TypedDict
+
+__all__ = ["ModelUpdateParams"]
+
+
+class ModelUpdateParams(TypedDict, total=False):
+ model_owner: Required[str]
+
+ model_name: Required[str]
+
+ description: str
+ """A description of the model."""
+
+ github_url: str
+ """A URL for the model's source code on GitHub."""
+
+ license_url: str
+ """A URL for the model's license."""
+
+ paper_url: str
+ """A URL for the model's paper."""
+
+ readme: str
+ """The README content of the model."""
+
+ weights_url: str
+ """A URL for the model's weights."""
diff --git a/src/replicate/types/model_update_response.py b/src/replicate/types/model_update_response.py
new file mode 100644
index 0000000..67ef5eb
--- /dev/null
+++ b/src/replicate/types/model_update_response.py
@@ -0,0 +1,53 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import Optional
+from typing_extensions import Literal
+
+from .._models import BaseModel
+
+__all__ = ["ModelUpdateResponse"]
+
+
+class ModelUpdateResponse(BaseModel):
+ cover_image_url: Optional[str] = None
+ """A URL for the model's cover image"""
+
+ default_example: Optional[object] = None
+ """The model's default example prediction"""
+
+ description: Optional[str] = None
+ """A description of the model"""
+
+ github_url: Optional[str] = None
+ """A URL for the model's source code on GitHub"""
+
+ is_official: Optional[bool] = None
+ """Boolean indicating whether the model is officially maintained by Replicate.
+
+ Official models are always on, have stable API interfaces, and predictable
+ pricing.
+ """
+
+ latest_version: Optional[object] = None
+ """The model's latest version"""
+
+ license_url: Optional[str] = None
+ """A URL for the model's license"""
+
+ name: Optional[str] = None
+ """The name of the model"""
+
+ owner: Optional[str] = None
+ """The name of the user or organization that owns the model"""
+
+ paper_url: Optional[str] = None
+ """A URL for the model's paper"""
+
+ run_count: Optional[int] = None
+ """The number of times the model has been run"""
+
+ url: Optional[str] = None
+ """The URL of the model on Replicate"""
+
+ visibility: Optional[Literal["public", "private"]] = None
+ """Whether the model is public or private"""
diff --git a/src/replicate/types/models/prediction_create_params.py b/src/replicate/types/models/prediction_create_params.py
index 69f8d38..326f235 100644
--- a/src/replicate/types/models/prediction_create_params.py
+++ b/src/replicate/types/models/prediction_create_params.py
@@ -93,6 +93,6 @@ class PredictionCreateParams(TypedDict, total=False):
sent regardless of throttling.
"""
- prefer: Annotated[str, PropertyInfo(alias="Prefer")]
+ cancel_after: Annotated[str, PropertyInfo(alias="Cancel-After")]
- replicate_max_lifetime: Annotated[str, PropertyInfo(alias="Replicate-Max-Lifetime")]
+ prefer: Annotated[str, PropertyInfo(alias="Prefer")]
diff --git a/src/replicate/types/prediction_create_params.py b/src/replicate/types/prediction_create_params.py
index 8578a34..00e547b 100644
--- a/src/replicate/types/prediction_create_params.py
+++ b/src/replicate/types/prediction_create_params.py
@@ -90,9 +90,9 @@ class PredictionCreateParamsWithoutVersion(TypedDict, total=False):
sent regardless of throttling.
"""
- prefer: Annotated[str, PropertyInfo(alias="Prefer")]
+ cancel_after: Annotated[str, PropertyInfo(alias="Cancel-After")]
- replicate_max_lifetime: Annotated[str, PropertyInfo(alias="Replicate-Max-Lifetime")]
+ prefer: Annotated[str, PropertyInfo(alias="Prefer")]
class PredictionCreateParams(PredictionCreateParamsWithoutVersion):
diff --git a/tests/api_resources/deployments/test_predictions.py b/tests/api_resources/deployments/test_predictions.py
index eeeed64..33e1cd2 100644
--- a/tests/api_resources/deployments/test_predictions.py
+++ b/tests/api_resources/deployments/test_predictions.py
@@ -43,8 +43,8 @@ def test_method_create_with_all_params(self, client: Replicate) -> None:
stream=True,
webhook="https://example.com/my-webhook-handler",
webhook_events_filter=["start", "completed"],
+ cancel_after="5m",
prefer="wait=5",
- replicate_max_lifetime="5m",
)
assert_matches_type(Prediction, prediction, path=["response"])
@@ -139,8 +139,8 @@ async def test_method_create_with_all_params(self, async_client: AsyncReplicate)
stream=True,
webhook="https://example.com/my-webhook-handler",
webhook_events_filter=["start", "completed"],
+ cancel_after="5m",
prefer="wait=5",
- replicate_max_lifetime="5m",
)
assert_matches_type(Prediction, prediction, path=["response"])
diff --git a/tests/api_resources/models/test_predictions.py b/tests/api_resources/models/test_predictions.py
index f702b05..94c8f4b 100644
--- a/tests/api_resources/models/test_predictions.py
+++ b/tests/api_resources/models/test_predictions.py
@@ -43,8 +43,8 @@ def test_method_create_with_all_params(self, client: Replicate) -> None:
stream=True,
webhook="https://example.com/my-webhook-handler",
webhook_events_filter=["start", "completed"],
+ cancel_after="5m",
prefer="wait=5",
- replicate_max_lifetime="5m",
)
assert_matches_type(Prediction, prediction, path=["response"])
@@ -139,8 +139,8 @@ async def test_method_create_with_all_params(self, async_client: AsyncReplicate)
stream=True,
webhook="https://example.com/my-webhook-handler",
webhook_events_filter=["start", "completed"],
+ cancel_after="5m",
prefer="wait=5",
- replicate_max_lifetime="5m",
)
assert_matches_type(Prediction, prediction, path=["response"])
diff --git a/tests/api_resources/test_models.py b/tests/api_resources/test_models.py
index 2cd3f1b..8b66c56 100644
--- a/tests/api_resources/test_models.py
+++ b/tests/api_resources/test_models.py
@@ -14,6 +14,7 @@
ModelListResponse,
ModelCreateResponse,
ModelSearchResponse,
+ ModelUpdateResponse,
)
from replicate.pagination import SyncCursorURLPage, AsyncCursorURLPage
@@ -82,12 +83,88 @@ def test_streaming_response_create(self, client: Replicate) -> None:
assert cast(Any, response.is_closed) is True
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ def test_method_update(self, client: Replicate) -> None:
+ model = client.models.update(
+ model_owner="model_owner",
+ model_name="model_name",
+ )
+ assert_matches_type(ModelUpdateResponse, model, path=["response"])
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ def test_method_update_with_all_params(self, client: Replicate) -> None:
+ model = client.models.update(
+ model_owner="model_owner",
+ model_name="model_name",
+ description="Detect hot dogs in images",
+ github_url="https://github.com/alice/hot-dog-detector",
+ license_url="license_url",
+ paper_url="https://arxiv.org/abs/2504.17639",
+ readme="# Updated README\n\nNew content here",
+ weights_url="https://huggingface.co/alice/hot-dog-detector",
+ )
+ assert_matches_type(ModelUpdateResponse, model, path=["response"])
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ def test_raw_response_update(self, client: Replicate) -> None:
+ response = client.models.with_raw_response.update(
+ model_owner="model_owner",
+ model_name="model_name",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ model = response.parse()
+ assert_matches_type(ModelUpdateResponse, model, path=["response"])
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ def test_streaming_response_update(self, client: Replicate) -> None:
+ with client.models.with_streaming_response.update(
+ model_owner="model_owner",
+ model_name="model_name",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ model = response.parse()
+ assert_matches_type(ModelUpdateResponse, model, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ def test_path_params_update(self, client: Replicate) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_owner` but received ''"):
+ client.models.with_raw_response.update(
+ model_owner="",
+ model_name="model_name",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"):
+ client.models.with_raw_response.update(
+ model_owner="model_owner",
+ model_name="",
+ )
+
@pytest.mark.skip(reason="Prism tests are disabled")
@parametrize
def test_method_list(self, client: Replicate) -> None:
model = client.models.list()
assert_matches_type(SyncCursorURLPage[ModelListResponse], model, path=["response"])
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ def test_method_list_with_all_params(self, client: Replicate) -> None:
+ model = client.models.list(
+ sort_by="model_created_at",
+ sort_direction="asc",
+ )
+ assert_matches_type(SyncCursorURLPage[ModelListResponse], model, path=["response"])
+
@pytest.mark.skip(reason="Prism tests are disabled")
@parametrize
def test_raw_response_list(self, client: Replicate) -> None:
@@ -313,12 +390,88 @@ async def test_streaming_response_create(self, async_client: AsyncReplicate) ->
assert cast(Any, response.is_closed) is True
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ async def test_method_update(self, async_client: AsyncReplicate) -> None:
+ model = await async_client.models.update(
+ model_owner="model_owner",
+ model_name="model_name",
+ )
+ assert_matches_type(ModelUpdateResponse, model, path=["response"])
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ async def test_method_update_with_all_params(self, async_client: AsyncReplicate) -> None:
+ model = await async_client.models.update(
+ model_owner="model_owner",
+ model_name="model_name",
+ description="Detect hot dogs in images",
+ github_url="https://github.com/alice/hot-dog-detector",
+ license_url="license_url",
+ paper_url="https://arxiv.org/abs/2504.17639",
+ readme="# Updated README\n\nNew content here",
+ weights_url="https://huggingface.co/alice/hot-dog-detector",
+ )
+ assert_matches_type(ModelUpdateResponse, model, path=["response"])
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ async def test_raw_response_update(self, async_client: AsyncReplicate) -> None:
+ response = await async_client.models.with_raw_response.update(
+ model_owner="model_owner",
+ model_name="model_name",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ model = await response.parse()
+ assert_matches_type(ModelUpdateResponse, model, path=["response"])
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ async def test_streaming_response_update(self, async_client: AsyncReplicate) -> None:
+ async with async_client.models.with_streaming_response.update(
+ model_owner="model_owner",
+ model_name="model_name",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ model = await response.parse()
+ assert_matches_type(ModelUpdateResponse, model, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ async def test_path_params_update(self, async_client: AsyncReplicate) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_owner` but received ''"):
+ await async_client.models.with_raw_response.update(
+ model_owner="",
+ model_name="model_name",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"):
+ await async_client.models.with_raw_response.update(
+ model_owner="model_owner",
+ model_name="",
+ )
+
@pytest.mark.skip(reason="Prism tests are disabled")
@parametrize
async def test_method_list(self, async_client: AsyncReplicate) -> None:
model = await async_client.models.list()
assert_matches_type(AsyncCursorURLPage[ModelListResponse], model, path=["response"])
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ async def test_method_list_with_all_params(self, async_client: AsyncReplicate) -> None:
+ model = await async_client.models.list(
+ sort_by="model_created_at",
+ sort_direction="asc",
+ )
+ assert_matches_type(AsyncCursorURLPage[ModelListResponse], model, path=["response"])
+
@pytest.mark.skip(reason="Prism tests are disabled")
@parametrize
async def test_raw_response_list(self, async_client: AsyncReplicate) -> None:
diff --git a/tests/api_resources/test_predictions.py b/tests/api_resources/test_predictions.py
index e1640b2..739db65 100644
--- a/tests/api_resources/test_predictions.py
+++ b/tests/api_resources/test_predictions.py
@@ -37,8 +37,8 @@ def test_method_create_with_all_params(self, client: Replicate) -> None:
stream=True,
webhook="https://example.com/my-webhook-handler",
webhook_events_filter=["start", "completed"],
+ cancel_after="5m",
prefer="wait=5",
- replicate_max_lifetime="5m",
)
assert_matches_type(Prediction, prediction, path=["response"])
@@ -215,8 +215,8 @@ async def test_method_create_with_all_params(self, async_client: AsyncReplicate)
stream=True,
webhook="https://example.com/my-webhook-handler",
webhook_events_filter=["start", "completed"],
+ cancel_after="5m",
prefer="wait=5",
- replicate_max_lifetime="5m",
)
assert_matches_type(Prediction, prediction, path=["response"])