Find an API

Search public APIs with auth details & Postman guides

← All APIs

Replicate API

api.replicate.com · AI

AI Bearer Token Paid AI Machine Learning Image Generation

Run thousands of open-source AI models via API — Stable Diffusion, LLaMA, Whisper, and more. Pay-per-second billing, no GPU required. Free trial credits included.

Authentication

Bearer token API token from replicate.com/account/api-tokens. Pass as Authorization: Bearer YOUR_TOKEN.

Sample Requests

POST Run a model

Generate an image with Stable Diffusion.

https://api.replicate.com/v1/predictions

Hover any highlighted part to learn what it does

Headers — extra info sent with the request
Content-Type application/json
Authorization Bearer YOUR_TOKEN
Request Body — data you're sending
{
  "input": {
    "prompt": "a photo of an astronaut riding a horse on mars"
  },
  "version": "ac732df83cea7fff18b8472768c88ad041fa750ff7682a21affe81863cbe77e4"
}
curl -X POST "https://api.replicate.com/v1/predictions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"input":{"prompt":"a photo of an astronaut riding a horse on mars"},"version":"ac732df83cea7fff18b8472768c88ad041fa750ff7682a21affe81863cbe77e4"}'
import requests
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
data = {
    "input": {
        "prompt": "a photo of an astronaut riding a horse on mars"
    },
    "version": "ac732df83cea7fff18b8472768c88ad041fa750ff7682a21affe81863cbe77e4"
}
response = requests.post(
    "https://api.replicate.com/v1/predictions",
    headers=headers,
    json=data,
)
print(response.json())
const url = 'https://api.replicate.com/v1/predictions';

const response = await fetch(url, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
  },
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
  "input": {
    "prompt": "a photo of an astronaut riding a horse on mars"
  },
  "version": "ac732df83cea7fff18b8472768c88ad041fa750ff7682a21affe81863cbe77e4"
}),
}); 
const data = await response.json();
console.log(data);
package main

import (
	"fmt"
	"io"
	"net/http"
	"bytes"
	"encoding/json"
)

func main() {
	targetURL := "https://api.replicate.com/v1/predictions"
	jsonData, _ := json.Marshal({"input":{"prompt":"a photo of an astronaut riding a horse on mars"},"version":"ac732df83cea7fff18b8472768c88ad041fa750ff7682a21affe81863cbe77e4"})
	req, _ := http.NewRequest("POST", targetURL, bytes.NewBuffer(jsonData))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
require "net/http"
require "json"

uri = URI("https://api.replicate.com/v1/predictions")

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"

req = Net::HTTP::Post.new(uri)
req["Content-Type"] = "application/json"
req["Authorization"] = "Bearer YOUR_ACCESS_TOKEN"
req["Content-Type"] = "application/json"
req.body = "{\"input\":{\"prompt\":\"a photo of an astronaut riding a horse on mars\"},\"version\":\"ac732df83cea7fff18b8472768c88ad041fa750ff7682a21affe81863cbe77e4\"}"

res = http.request(req)
puts JSON.parse(res.body)
<?php
$url = "https://api.replicate.com/v1/predictions";
$opts = ["http" => [
    "method" => "POST",
    "header" => implode("\r\n", [
        "Content-Type: application/json",
        "Authorization: Bearer YOUR_ACCESS_TOKEN",
        "Content-Type: application/json"
    ]),
    "content" => json_encode({"input":{"prompt":"a photo of an astronaut riding a horse on mars"},"version":"ac732df83cea7fff18b8472768c88ad041fa750ff7682a21affe81863cbe77e4"}),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));

Postman Setup Guide

Get Postman ↗
  1. Get an API token at replicate.com/account/api-tokens
  2. POST to /v1/predictions with model version and inputs
  3. Poll the returned prediction URL until status is "succeeded"
  4. Find model versions at replicate.com/explore

What can you build with Replicate API?

Replicate API is a AI API. Developers commonly use ai APIs for:

  • adding natural language processing to your product
  • generating images, text, or code with AI models
  • building chatbots and virtual assistants
  • running sentiment analysis on customer feedback
  • powering recommendation and personalisation engines

Bearer token. Your app exchanges credentials for a short-lived token, then sends it as an Authorization header. Tokens expire, so your code needs to handle renewal. Replicate API is a paid API — check the provider's pricing page before building a production integration.

New to APIs? Read our beginner's guide

Open documentation ↗