> ## Documentation Index
> Fetch the complete documentation index at: https://daily-docs-source-analytics-user-turn-strategies.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Replicate

> Image generation service implementation using Replicate-hosted models

export const CommunityMaintained = ({maintainer, maintainerUrl, repo}) => <Note>
    <strong>Community-maintained integration.</strong> This service is built and
    maintained by{" "}
    <a href={maintainerUrl} target="_blank" rel="noreferrer">
      {maintainer}
    </a>
    . Pipecat does not test or officially support it. Please report issues and
    request changes on the{" "}
    <a href={repo} target="_blank" rel="noreferrer">
      source repository
    </a>
    . Learn more about{" "}
    <a href="/api-reference/server/services/community-integrations">
      community integrations
    </a>
    .
  </Note>;

<CommunityMaintained maintainer="bnovik0v" maintainerUrl="https://github.com/bnovik0v" repo="https://github.com/bnovik0v/pipecat-replicate" />

## Overview

`ReplicateImageGenService` generates images from text prompts using models
hosted on [Replicate](https://replicate.com/), such as
`black-forest-labs/flux-schnell`. Any text-to-image model available on Replicate
can be used by setting the `model` parameter.

<CardGroup cols={2}>
  <Card title="Source Repository" icon="github" href="https://github.com/bnovik0v/pipecat-replicate">
    Source code, examples, and issues for the Replicate integration
  </Card>

  <Card title="PyPI Package" icon="cube" href="https://pypi.org/project/pipecat-replicate/">
    The `pipecat-replicate` package on PyPI
  </Card>

  <Card title="Replicate Models" icon="image" href="https://replicate.com/explore">
    Browse text-to-image models available on Replicate
  </Card>

  <Card title="API Tokens" icon="key" href="https://replicate.com/account/api-tokens">
    Create and manage your Replicate API tokens
  </Card>
</CardGroup>

## Installation

This is a community-maintained package distributed separately from `pipecat-ai`:

```bash theme={null}
uv add pipecat-replicate
```

## Prerequisites

### Replicate Account Setup

Before using the Replicate image generation service, you need:

1. **Replicate Account**: Sign up at [Replicate](https://replicate.com/)
2. **API Token**: Create a token from your [account settings](https://replicate.com/account/api-tokens)

### Required Environment Variables

* `REPLICATE_API_TOKEN`: Your Replicate API token for authentication

## Configuration

<ParamField path="aiohttp_session" type="aiohttp.ClientSession" required>
  HTTP client session used for Replicate API requests and image downloads.
</ParamField>

<ParamField path="api_token" type="str" default="None">
  Replicate API token. Falls back to the `REPLICATE_API_TOKEN` environment
  variable if not provided.
</ParamField>

<ParamField path="settings" type="ReplicateImageGenService.Settings" default="None">
  Runtime-configurable generation settings. See [Settings](#settings) below.
</ParamField>

<ParamField path="base_url" type="str" default="https://api.replicate.com/v1">
  Base URL for the Replicate API.
</ParamField>

<ParamField path="wait_timeout_secs" type="int" default="60">
  Sync wait duration passed in the Replicate `Prefer` header.
</ParamField>

<ParamField path="poll_interval_secs" type="float" default="0.5">
  How often to poll Replicate for prediction status.
</ParamField>

<ParamField path="max_poll_attempts" type="int" default="120">
  Maximum number of polling attempts before giving up.
</ParamField>

### Settings

Runtime-configurable settings passed via the `settings` constructor argument
using `ReplicateImageGenService.Settings(...)`.

| Parameter                | Type   | Default                            | Description                                                            |
| ------------------------ | ------ | ---------------------------------- | ---------------------------------------------------------------------- |
| `model`                  | `str`  | `"black-forest-labs/flux-schnell"` | Replicate model identifier. Use `owner/name`, or `owner/name:version`. |
| `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. `None` uses a random seed.    |
| `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 checker.                           |
| `go_fast`                | `bool` | `True`                             | Use the model's faster generation mode.                                |
| `megapixels`             | `str`  | `"1"`                              | Approximate megapixel count for generated images.                      |

<Note>
  Available parameters and defaults are defined by the integration and the
  selected Replicate model. See the [source
  repository](https://github.com/bnovik0v/pipecat-replicate) for the
  authoritative, up-to-date list.
</Note>

## Usage

```python theme={null}
import aiohttp
from pipecat_replicate import ReplicateImageGenService
from pipecat.frames.frames import TextFrame

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

    # ... add image_gen to your pipeline, then queue a prompt:
    await task.queue_frames(
        [TextFrame("a cat in the style of a screenprint poster")]
    )
```

## Compatibility

Tested with Pipecat v0.0.108. Check the [source
repository](https://github.com/bnovik0v/pipecat-replicate) for the latest tested
version and changelog.
