Replicate API

ai-ml replicate

Replicate API

Run open-source AI models with a cloud API. Stable Diffusion, LLaMA, Whisper.

Quick Facts

FieldValue
ProviderReplicate
CategoryAI/ML APIs
Websitehttps://replicate.com
AuthenticationBearer Token
Pricing Modelusage-based
Tagsai, image-generation, stable-diffusion, llama

Authentication

This API uses Bearer Token authentication. Refer to the official documentation at https://replicate.com.

Pricing

The pricing model is usage-based. Visit the provider’s pricing page for current rates.

Code Samples

Python

import requests

API_KEY = "YOUR_API_KEY"
BASE_URL = "https://replicate.com"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

response = requests.get(BASE_URL, headers=headers)
print(response.status_code)
print(response.json())

JavaScript (Node.js)

const API_KEY = process.env.API_KEY || "YOUR_API_KEY";
const BASE_URL = "https://replicate.com";

async function callApi() {
  const response = await fetch(BASE_URL, {
    headers: {
      "Authorization": `Bearer ${API_KEY}`,
      "Content-Type": "application/json"
    }
  });
  const data = await response.json();
  console.log(data);
}

callApi();

Go

package main

import (
    "fmt"
    "io"
    "net/http"
    "os"
)

func main() {
    apiKey := os.Getenv("API_KEY")
    if apiKey == "" {
        apiKey = "YOUR_API_KEY"
    }
    req, _ := http.NewRequest("GET", "https://replicate.com", nil)
    req.Header.Set("Authorization", "Bearer "+apiKey)
    req.Header.Set("Content-Type", "application/json")
    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}

cURL

curl -X GET "https://replicate.com" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"

Best Practices

  • Never hardcode API keys in source code
  • Respect rate limits, implement exponential backoff
  • Validate responses
  • Cache when possible
  • Use webhooks for async workflows
  • Log request IDs for debugging

Browse other APIs in AI/ML APIs or all APIs from Replicate.

Other languages