Skip to content

Releases: replicate/replicate-python-beta

v2.0.0-beta.2

24 Oct 15:55
f778511

Choose a tag to compare

v2.0.0-beta.2 Pre-release
Pre-release

2.0.0-beta.2 (2025-10-23)

Full Changelog: v2.0.0-beta.1...v2.0.0-beta.2

Documentation

  • update readme and upgrading guide for v2 beta (#90) (8ca8600)

Python SDK 2.0.0 beta

23 Oct 16:34
6146b12

Choose a tag to compare

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:

🔬Low-level API

The v2 SDK includes generic request methods like replicate.get() and replicate.post() for making custom API requests with full control over the request and response. This is useful for testing undocumented APIs, setting custom headers, or getting lower-level access to response objects.


New SDK features

In addition to the new API design, there are loads of new features in the v2 SDK:

  • Type hints: Typed requests and responses provide autocomplete and documentation within your editor.
  • Pagination: All list methods are paginated, and the SDK provides auto-paginating iterators with each list response so you do not have to request successive pages manually.
  • Retries: Certain errors like 408, 409, 429, and >=500 are automatically retried 2 times by default, with a short exponential backoff.
  • Async/await support: Full async client with AsyncReplicate that supports all SDK methods including run() and stream().
  • Alternative HTTP backends: Optional aiohttp support for improved concurrency performance in async applications.
  • Streaming output: Stream model outputs in real-time with replicate.stream() for language models.
  • File upload flexibility: Pass files as URLs, file handles, bytes, PathLike objects, or tuples of (filename, contents, media_type).
  • Raw response access: Access response headers and raw data with .with_raw_response and .with_streaming_response.
  • Per-request configuration: Override client options on a per-request basis with .with_options().
  • Configurable timeouts: Fine-grained timeout control at the client or request level, including separate read/write/connect timeouts.
  • Better error handling: Specific exception types for different HTTP status codes (BadRequestError, `Aut...
Read more

v2.0.0-alpha.31

22 Oct 23:10
a84dffe

Choose a tag to compare

v2.0.0-alpha.31 Pre-release
Pre-release

2.0.0-alpha.31 (2025-10-17)

Full Changelog: v2.0.0-alpha.30...v2.0.0-alpha.31

Chores

  • bump httpx-aiohttp version to 0.1.9 (d187919)

v2.0.0-alpha.30

15 Oct 18:18
e478856

Choose a tag to compare

v2.0.0-alpha.30 Pre-release
Pre-release

2.0.0-alpha.30 (2025-10-15)

Full Changelog: v2.0.0-alpha.29...v2.0.0-alpha.30

Documentation

v2.0.0-alpha.29

15 Oct 17:29
c7424c5

Choose a tag to compare

v2.0.0-alpha.29 Pre-release
Pre-release

2.0.0-alpha.29 (2025-10-15)

Full Changelog: v2.0.0-alpha.28...v2.0.0-alpha.29

Features

  • add deprecated replicate.stream() for v1 compatibility (#79) (79b69bd)

Bug Fixes

Chores

  • change production repo to replicate/replicate-python-beta (b59e930)
  • sync repo (24fe88a)

Documentation

v2.0.0-alpha.28

07 Oct 21:06
f85db05

Choose a tag to compare

v2.0.0-alpha.28 Pre-release
Pre-release

2.0.0-alpha.28 (2025-10-07)

Full Changelog: v2.0.0-alpha.27...v2.0.0-alpha.28

Chores

  • do not install brew dependencies in ./scripts/bootstrap by default (40f38a7)
  • types: change optional parameter type from NotGiven to Omit (f331b97)
  • update OpenAPI spec and rebuild SDKs (8b43277)
  • update OpenAPI spec and rebuild SDKs (77c9c21)
  • update OpenAPI spec and rebuild SDKs (d5ed889)
  • update OpenAPI spec and rebuild SDKs (0a821f8)
  • update OpenAPI spec and rebuild SDKs (a4bdae2)

Documentation

  • remove replicate.stream from README (#78) (9efac9a)

v2.0.0-alpha.27

29 Sep 19:58
2804bd6

Choose a tag to compare

v2.0.0-alpha.27 Pre-release
Pre-release

2.0.0-alpha.27 (2025-09-29)

Full Changelog: v2.0.0-alpha.26...v2.0.0-alpha.27

Features

  • add api_token parameter support for legacy compatibility (7a781df)
  • add legacy exception compatibility aliases (#70) (1a66fc8)

Bug Fixes

  • predictions: use Omit instead of NotGiven (6f10116)

Chores

  • internal: update formatting (d1bebb6)
  • types: change optional parameter type from NotGiven to Omit (3223abf)

v2.0.0-alpha.26

17 Sep 16:05
a4878ab

Choose a tag to compare

v2.0.0-alpha.26 Pre-release
Pre-release

2.0.0-alpha.26 (2025-09-17)

Full Changelog: v2.0.0-alpha.25...v2.0.0-alpha.26

Features

  • api: add new replicate.search() method (beta) (30d7019)

Bug Fixes

  • tests: fix tests for module-level client (1e72f23)

Chores

  • internal: update pydantic dependency (54872cb)

v2.0.0-alpha.25

15 Sep 23:59
ab2920d

Choose a tag to compare

v2.0.0-alpha.25 Pre-release
Pre-release

2.0.0-alpha.25 (2025-09-15)

Full Changelog: v2.0.0-alpha.24...v2.0.0-alpha.25

Chores

  • update OpenAPI spec and rebuild SDKs (5e7effd)

v2.0.0-alpha.24

12 Sep 19:31
30d1282

Choose a tag to compare

v2.0.0-alpha.24 Pre-release
Pre-release

2.0.0-alpha.24 (2025-09-11)

Full Changelog: v2.0.0-alpha.23...v2.0.0-alpha.24

Chores

  • tests: simplify get_platform test (0b697dc)