Skip to main content
Replicate is a platform for running machine learning models in the cloud.
Replicate doesn’t use a standardized JSON format for their API, so Portkey acts as a proxy, managing authentication and logging all requests.

Quick Start

from portkey_ai import Portkey

# 1. Install: pip install portkey-ai
# 2. Add @replicate provider in model catalog
# 3. Use it:

portkey = Portkey(
    api_key="PORTKEY_API_KEY",
    provider="@replicate"
)

response = portkey.post(
    url="predictions",
    data={
        "version": "MODEL_VERSION_ID",
        "input": {"prompt": "Hello, world!"}
    }
)

print(response)

Add Provider in Model Catalog

Before making requests, add Replicate to your Model Catalog:
  1. Go to Model Catalog → Add Provider
  2. Select Replicate
  3. Enter your Replicate API token
  4. Name your provider (e.g., replicate)

Complete Setup Guide

See all setup options and detailed configuration instructions

Using Replicate with Portkey

Since Replicate doesn’t follow the OpenAI format, use Portkey’s post() method to interact with any Replicate endpoint:
from portkey_ai import Portkey

portkey = Portkey(
    api_key="PORTKEY_API_KEY",
    provider="@replicate"
)

# Run a prediction
response = portkey.post(
    url="predictions",
    data={
        "version": "stability-ai/sdxl:...",
        "input": {
            "prompt": "A serene landscape"
        }
    }
)

print(response)

Supported Endpoints

Portkey proxies all Replicate API endpoints:
  • /predictions - Create predictions
  • /predictions/{prediction_id} - Get prediction status
  • /predictions/{prediction_id}/cancel - Cancel predictions
  • /models - List models
  • /collections - List collections
See Replicate’s API documentation for complete endpoint details.

Next Steps

For complete SDK documentation:

SDK Reference

Complete Portkey SDK documentation