skillfed

replicate

Python client for Replicate

replicate v1.0.7 1.8M downloads/30d#3,509 on PyPI909
Permissive 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) AGING released

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 replicate

uv

uv add replicate

poetry

poetry add replicate

Installing 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

replicate api clientrun ml models pythonmachine learning inferenceasync model executionstreaming model outputreplicate predictionsai model api wrapper
ml-inferenceasync-readyapi-client

More Artificial Intelligence packages