replicate/replicate-python-beta v2.0.0-beta.1
replicate/replicate-python-beta
Captured source
source ↗Python SDK 2.0.0 beta
Repository: replicate/replicate-python-beta
Tag: v2.0.0-beta.1
Published: 2025-10-23T16:34:47Z
Prerelease: no
Release notes: Replicate’s v2 Python SDK is now in public beta. 🎉
As always, the replicate package is published on PyPI, and you can install it with pip using the --pre flag:
pip install --pre replicate
What’s new?
This new version is a complete rewrite of the SDK, built in partnership with Stainless, the team that helps design and maintain official SDKs for companies like OpenAI, Anthropic, and Cloudflare.
Replicate's v2 Python SDK is generated dynamically from our public OpenAPI schema. This allows us to automate client code generation and provide a Python API with method names, type hints, and documentation that is perfectly consistent with our HTTP API.
Now that most of the client code is generated dynamically, all changes to Replicate’s HTTP API are automatically supported by the Python SDK. This means whenever we add a new operation (like the new search API) or improve our docs for an existing API (like predictions.create()), the changes are automatically published in a new release of the Python SDK.
Running models
We think running AI models should be as easy as installing and running a package from PyPI.
With this idea in mind, we designed a new `replicate.use()` method that lets you run models as Python functions:
# pip install --pre replicate
import replicate
claude = replicate.use("anthropic/claude-4.5-sonnet")
seedream = replicate.use("bytedance/seedream-4")
veo = replicate.use("google/veo-3-fast")
# Enhance a simple prompt
image_prompt = claude(prompt="bananas wearing cowboy hats", system_prompt="turn prompts into image prompts")
# Generate an image from the enhanced prompt
images = seedream(prompt=image_prompt)
# Generate a video from the image
video = veo(prompt="dancing bananas", image_input=images[0])
open(video)The new .use() method also supports streaming output. Here’s an example showing how to consume output tokens from Claude Sonnet 4.5 while the model is running:
import replicate
claude = replicate.use("anthropic/claude-4.5-sonnet", streaming=True)
for chunk in claude(prompt="Write a haiku about streaming output."):
print(str(chunk), end="")
# Bytes flow through the pipe
# Data chunks arrive in waves
# Code drinks from the stream---
API design
Our new SDK was designed to be approachable for newcomers while also being feature-complete for power users. There are three levels of APIs built into the new SDK, varying from simple high-level abstractions to powerful low-level methods that you give you complete control:
🍰 High-level API
The v2 SDK provides a new replicate.use() method that make it easy to run models and get their output all at once or as a streaming response. The replicate.run() method is still supported so your applications will continue to work, but recommend using use() going forward.
🛠️ Mid-level API
The v2 SDK has methods for every single operation available in our public HTTP API, like search(), predictions.create() , and collections.list(). These more fine-grained methods are defined by our OpenAPI schema, and updated in lock-step with our API. Every new feature, bug fix, or documentation improvement in our API becomes available immediately in a new release of the Python SDK. See our HTTP API docs and Python SDK docs for reference.
The SDK now supports all of these API operations:
- `search` - Search models, collections, and docs (beta)
- `predictions.create` - Create a prediction
- `predictions.get` - Get a prediction
- `predictions.list` - List predictions
- `predictions.cancel` - Cancel a prediction
- `models.create` - Create a model
- `models.get` - Get a model
- `models.list` - List public models
- `models.update` - Update metadata for a model
- `models.search` - Search public models
- `models.delete` - Delete a model
- `models.examples.list` - List examples for a model
- `models.predictions.create` - Create a prediction using an official model
- `models.readme.get` - Get a model's README
- `models.versions.get` - Get a model version
- `models.versions.list` - List model versions
- `models.versions.delete` - Delete a model version
- `collections.get` - Get a collection of models
- `collections.list` - List collections of models
- `deployments.create` - Create a deployment
- `deployments.get` - Get a deployment
- `deployments.list` - List deployments
- `deployments.update` - Update a deployment
- `deployments.delete` -…
Excerpt shown — open the source for the full document.
Notability
notability 5.0/10Beta release of Replicate Python client library.