> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portkey.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Replicate

> Use Portkey as a proxy to Replicate for auth management and logging.

[Replicate](https://replicate.com/) is a platform for running machine learning models in the cloud.

> [!NOTE]
>
> 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

```python Python icon="python" theme={"system"}
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)
```

```js Javascript icon="square-js" theme={"system"}
import Portkey from 'portkey-ai'

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

const portkey = new Portkey({
    apiKey: "PORTKEY_API_KEY",
    provider: "@replicate"
})

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

console.log(response)
```

```sh cURL icon="square-terminal" theme={"system"}
# 1. Add @replicate provider in model catalog
# 2. Use it:

curl https://api.portkey.ai/v1/predictions \
  -H "Content-Type: application/json" \
  -H "x-portkey-api-key: $PORTKEY_API_KEY" \
  -d '{
    "version": "MODEL_VERSION_ID",
    "input": {"prompt": "Hello, world!"}
  }'
```

## Add Provider in Model Catalog

Before making requests, add Replicate to your Model Catalog:

1. Go to [**Model Catalog → Add Provider**](https://app.portkey.ai/model-catalog/providers)
2. Select **Replicate**
3. Enter your [Replicate API token](https://replicate.com/account/api-tokens)
4. Name your provider (e.g., `replicate`)

> [card] [Complete Setup Guide](https://docs.portkey.ai/docs/product/model-catalog.md)
>
> 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:

```python Python theme={"system"}
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)
```

```javascript Node.js theme={"system"}
import Portkey from 'portkey-ai';

const portkey = new Portkey({
    apiKey: 'PORTKEY_API_KEY',
    provider: '@replicate'
});

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

console.log(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](https://replicate.com/docs/reference/http) for complete endpoint details.

***

## Next Steps

> [card] [Observability](https://docs.portkey.ai/docs/product/observability.md)
>
> Monitor and trace your Replicate requests

> [card] [Metadata](https://docs.portkey.ai/docs/product/observability/metadata.md)
>
> Add custom metadata to requests

> [card] [Caching](https://docs.portkey.ai/docs/product/ai-gateway/cache-simple-and-semantic.md)
>
> Cache Replicate responses

> [card] [Guardrails](https://docs.portkey.ai/docs/product/guardrails.md)
>
> Add input/output checks

For complete SDK documentation:

> [card] [SDK Reference](https://docs.portkey.ai/docs/api-reference/sdk/list.md)
>
> Complete Portkey SDK documentation

***

> [card] [Portkey is now PRISMA AIRS AI Gateway. See it in action.](https://www.paloaltonetworks.in/ai-security/ai-gateway?utm_source=portkey\&utm_medium=referral\&utm_campaign=prisma_airs\&utm_content=docs_nav#contact)
>
> Contact Us


## Related topics

- [January](https://docs.portkey.ai/docs/changelog/2025/jan.md)
- [Enterprise Gateway](https://docs.portkey.ai/docs/changelog/enterprise.md)
- [April](https://docs.portkey.ai/docs/changelog/2025/apr.md)
- [Supported Providers](https://docs.portkey.ai/docs/api-reference/inference-api/supported-providers.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.