> ## Documentation Index
> Fetch the complete documentation index at: https://portkey-docs-add-third-party-integration-issues-fixes.mintlify.site/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.
</Note>

## Quick Start

<CodeGroup>
  ```python Python icon="python" theme={null}
  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={null}
  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={null}
  # 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!"}
    }'
  ```
</CodeGroup>

## 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 title="Complete Setup Guide" icon="book" href="/product/model-catalog">
  See all setup options and detailed configuration instructions
</Card>

***

## Using Replicate with Portkey

Since Replicate doesn't follow the OpenAI format, use Portkey's `post()` method to interact with any Replicate endpoint:

<CodeGroup>
  ```python Python theme={null}
  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={null}
  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);
  ```
</CodeGroup>

***

## 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

<CardGroup cols={2}>
  <Card title="Observability" icon="chart-line" href="/product/observability">
    Monitor and trace your Replicate requests
  </Card>

  <Card title="Metadata" icon="tag" href="/product/observability/metadata">
    Add custom metadata to requests
  </Card>

  <Card title="Caching" icon="database" href="/product/ai-gateway/cache-simple-and-semantic">
    Cache Replicate responses
  </Card>

  <Card title="Guardrails" icon="shield-check" href="/product/guardrails">
    Add input/output checks
  </Card>
</CardGroup>

For complete SDK documentation:

<Card title="SDK Reference" icon="code" href="/api-reference/sdk/list">
  Complete Portkey SDK documentation
</Card>
