Registry / ai-ml / replicate

replicate

JSON →
library1.0.7pypypi✓ verified 28d ago

Python client for running ML models on Replicate's cloud API. v0.x stable client is at 1.x on PyPI. A v2.0 beta (replicate-python-beta) exists as a separate package with a redesigned API. replicate.stream() is deprecated in v2. Billing changed to prepaid credit for new accounts in July 2025.

pip install replicate
INSTALL
IMPORT
SIG · REPLICATE
R
replicate
ai-mlpythonv1.0.7
Install
4.0s avg
Import
598ms
Disk
32MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.0a16 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.632s · 33.5MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 4.0s · import 0.564s · 33MB
32MB installed
● package 32MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Client
from replicate import Client
import replicate
run
from replicate import run
import replicate

Run a model on Replicate. Requires REPLICATE_API_TOKEN environment variable.

import replicate output = replicate.run( "black-forest-labs/flux-schnell", input={"prompt": "an iguana on the beach"} ) # output is a list of FileOutput objects for image models with open('output.png', 'wb') as f: f.write(output[0].read())
Debug
Known issues
breakingreplicate.run() output for image models is a list of FileOutput objects, not URLs or strings. Treating output[0] as a string raises AttributeError.
fix
Use output[0].read() to get bytes, or output[0].url to get the URL string.
affects: >= 0.25.0
breakingv2.0 alpha (replicate-python-beta) has a completely redesigned API with replicate.use() replacing replicate.run(). The two packages are incompatible — do not mix v1 and v2 patterns.
fix
Stick to stable v1.x unless explicitly opting into the v2 beta. Do not install replicate-python-beta alongside replicate.
affects: 2.0.0a*
deprecatedreplicate.stream() is deprecated in v2 SDK. Still available for v1 backwards compatibility but will be removed.
fix
Use replicate.run() with stream=True parameter, or use predictions.create() with streaming for fine-grained control.
affects: >= 2.0.0
gotchaModel versions are pinned by hash in many tutorials (e.g. 'owner/model:abc123'). Pinned version hashes go stale as models are updated. Unpinned calls use the latest deployment which may have different inputs/outputs.
fix
Use versioned model strings for production ('owner/model:hash'). Check replicate.com/owner/model/versions for current hashes.
affects: all
gotchareplicate.run() is synchronous and blocks until the prediction completes. For long-running models this can block for minutes.
fix
Use replicate.predictions.create() to get a prediction ID immediately, then poll with predictions.get() or use AsyncReplicate for non-blocking calls.
affects: all
gotchaNew Replicate accounts (post July 2025) use prepaid credit billing, not monthly billing. API calls will fail with 402 if credit balance is zero, unlike monthly billing which allows negative balances until invoice.
fix
Add credit at replicate.com/account/billing before making API calls. Set up auto-reload to avoid unexpected failures.
affects: all
Upgrade
Version history
1.0.7latest on PyPI · released May 27, 2025
Audit
Dependencies
httpxrequiredHTTP client used internally. Installed automatically.
pydanticrequiredUsed for model input/output validation.
Agent activity
24 hits · last 30 days
node
20
OpenAI (training)
1
Resources
replicate — pip install replicate · libregistry