replicate
Python client for Replicate
What it is and what it does
Replicate is a Python client that connects your code to Replicate's hosted machine learning models via HTTP. It abstracts away API details, letting you run image generation, language models, and other AI tasks with a single function call. The package handles authentication via environment variables, manages prediction lifecycle (starting, polling, streaming), and provides both synchronous and asynchronous interfaces for concurrent workloads.
The 1.0.0 release introduced a breaking change: model outputs that produce files now return FileOutput objects by default instead of URL strings, offering streaming-like iteration over file content. You can opt out with use_file_output=False if needed. The client supports streaming tokens from language models in real time, running predictions in the background with webhook callbacks, and composing multiple model outputs into pipelines.
Use it for:
- Generate images by running text-to-image models like Flux or Stable Diffusion with a single replicate.run() call.
- Stream tokens from large language models in real time using replicate.stream() for interactive chatbot or text-generation applications.
- Run multiple model predictions concurrently using async_run() within an asyncio context for batch processing workflows.
- Start long-running predictions in the background and receive webhook notifications when they complete instead of blocking.
- Process files (images, audio) by passing local file handles or URLs to models that accept file inputs.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A Python client for running machine learning models on Replicate's API, supporting synchronous and asynchronous execution, file streaming, and webhook-based background jobs.
Yes. This is the official Replicate Python client with low install friction, permissive licensing, and no known vulnerabilities. Install it if you need to call Replicate models from Python—it's the standard integration point. Be aware that the project is aging (last commit August 2025) and the 1.0.0 breaking change around FileOutput requires code updates if upgrading from earlier versions.
Install
replicate on PyPI
pip
pip install replicateuv
uv add replicatepoetry
poetry add replicateInstalling replicate
Before you install
Low install friction with four lightweight runtime dependencies (httpx, packaging, pydantic, typing_extensions). Maintenance status is aging—last commit was 2025-08-26 with 909 repository stars, indicating the project is stable but not actively developed.
License in practice
Licensed under Apache License 2.0 (permissive), allowing commercial and derivative use with minimal restrictions beyond attribution and liability disclaimers.
Quickstart
pip install replicate
import replicate
outputs = replicate.run(
"black-forest-labs/flux-schnell",
input={"prompt": "astronaut riding a rocket"}
)
for output in outputs:
print(output)
Requires REPLICATE_API_TOKEN environment variable set with a valid API token from replicate.com/account.
Verify before relying
- Whether FileOutput's iterable interface and performance characteristics match the documented behavior in production use.
- Specific timeout and retry behavior when predictions exceed the default 60-second wait window.
- Compatibility and stability with all Replicate model versions and input types beyond the documented examples.
Package facts
| License | Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — httpx, packaging, pydantic, typing_extensions |
| Maintenance | aging — 444 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,832,814/month — #3,509 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: replicate-1.0.7-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
opentelemetry-instrumentation-replicateAdds OpenTelemetry tracing to Replicate API…
permissive · top 5,000 on PyPI
datarobot-predictProvides a unified Python interface for making…
permissive · top 15,000 on PyPI
cogCog packages machine learning models into…
permissive · top 5,000 on PyPI
inference-modelsLoads and runs computer vision models from…
unclear · top 15,000 on PyPI
fal-clientA Python client library for calling ML models…
unclear · top 5,000 on PyPI
aiohttp-sse-client2Provides an async Python client for consuming…
permissive · top 15,000 on PyPI
gradio-clientCalls any Gradio app as a Python API with a…
permissive · top 5,000 on PyPI
lhotseLhotse prepares multimodal (speech, audio,…
permissive · top 5,000 on PyPI
azure-ai-mlProvides a Python client library for…
permissive · top 5,000 on PyPI
aleph-alpha-clientPython client library for calling the Aleph…
permissive · top 15,000 on PyPI