Skip to main content

Replicate image generation integration for Pipecat

Project description

pipecat-replicate

Replicate image generation integration for Pipecat — a framework for building voice and multimodal conversational AI applications.

Pipecat Compatibility

Tested with Pipecat v0.0.108

Features

  • Text-to-image generation using any Replicate-hosted model
  • Official models (owner/name) and versioned community models (owner/name:version)
  • Sync prediction requests with automatic polling fallback
  • Returns URLImageRawFrame for direct use in Pipecat pipelines
  • Configurable via the standard Pipecat Settings dataclass pattern

Installation

Using pip

pip install pipecat-replicate

Using uv

uv add pipecat-replicate

From source

git clone https://github.com/bnovik0v/pipecat-replicate.git
cd pipecat-replicate
pip install -e .

Quick Start

  1. Get your Replicate API token at https://replicate.com/account/api-tokens

  2. Set the environment variable:

export REPLICATE_API_TOKEN=r8_...
  1. Use in a Pipecat pipeline:
import aiohttp
from pipecat.frames.frames import TextFrame
from pipecat.pipeline.pipeline import Pipeline
from pipecat.pipeline.runner import PipelineRunner
from pipecat.pipeline.task import PipelineTask
from pipecat_replicate import ReplicateImageGenService

async with aiohttp.ClientSession() as session:
    imagegen = ReplicateImageGenService(
        aiohttp_session=session,
        settings=ReplicateImageGenService.Settings(
            model="black-forest-labs/flux-schnell",
            aspect_ratio="1:1",
        ),
    )

    pipeline = Pipeline([imagegen, ...])
    task = PipelineTask(pipeline)
    await task.queue_frames([TextFrame("a cat in the style of a screenprint poster")])

    runner = PipelineRunner()
    await runner.run(task)

Configuration

Settings

Field Type Default Description
model str "black-forest-labs/flux-schnell" Replicate model identifier
aspect_ratio str "1:1" Aspect ratio for generated images
num_outputs int 1 Number of images to generate (1–4)
num_inference_steps int 4 Number of denoising steps
seed int None Random seed for reproducible generation
output_format str "webp" Output image format
output_quality int 80 Output quality (0–100)
disable_safety_checker bool False Whether to disable the model safety check
go_fast bool True Use the model's fast generation mode
megapixels str "1" Approximate megapixel count

Constructor Parameters

Parameter Type Default Description
aiohttp_session aiohttp.ClientSession (required) HTTP session for API requests
api_token str $REPLICATE_API_TOKEN Replicate API token
settings Settings (see defaults above) Generation settings
base_url str "https://api.replicate.com/v1" API base URL
wait_timeout_secs int 60 Sync wait timeout (Prefer header)
poll_interval_secs float 0.5 Poll interval for async predictions
max_poll_attempts int 120 Maximum number of polling attempts

Examples

See examples/basic_image_gen.py for a complete example that generates an image and displays it in a Tk window.

REPLICATE_API_TOKEN=r8_... python examples/basic_image_gen.py

Running Tests

uv sync --group dev
uv run pytest

License

BSD 2-Clause — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pipecat_replicate-0.1.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pipecat_replicate-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file pipecat_replicate-0.1.0.tar.gz.

File metadata

  • Download URL: pipecat_replicate-0.1.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pipecat_replicate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 33c6c5f163f176a54e2295a108acc43fb620c1e0b946baed0d9215272ca6d297
MD5 7c1eeebaacff3cb477addbcdf8ad026b
BLAKE2b-256 4556530b568ef60f78f4d819ff57f626e16e6aedb474e2e558dcaa43c3a95138

See more details on using hashes here.

Provenance

The following attestation bundles were made for pipecat_replicate-0.1.0.tar.gz:

Publisher: publish.yml on bnovik0v/pipecat-replicate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pipecat_replicate-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pipecat_replicate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9b9d782e0ac2d475d8103ab4581e005791fca7cc890c01f000ce20a8cad1659
MD5 6be39d540383882c516af372838ebb99
BLAKE2b-256 288c5c49dce1fe366fe7525a35c48ce5c55570ea69343c9992c9df29c8188107

See more details on using hashes here.

Provenance

The following attestation bundles were made for pipecat_replicate-0.1.0-py3-none-any.whl:

Publisher: publish.yml on bnovik0v/pipecat-replicate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page