API Directory › 🤖 AI & Machine Learning › Replicate
API KeyHTTPSCORS

Replicate API

Run and fine-tune open-source AI models (image, video, audio, text) via API.

Auth
API Key
HTTPS
Yes
CORS
Yes
Open Replicate docs ↗

What it does

Replicate runs open-source AI models as hosted APIs — image and video generation, upscaling, background removal, speech, language models and thousands of community models. You call a model version, get a prediction that runs asynchronously, and poll or receive a webhook when it finishes.

Base URL

https://api.replicate.com/v1

Authentication

Create an account and copy your token (r8_…) from the account page. Send it as Authorization: Bearer r8_…. There is no free tier — you are billed by the second for the hardware each run uses, so cheap models cost fractions of a cent and big video models cost more.

Code examples

curl
curl -s -X POST https://api.replicate.com/v1/predictions \
  -H "Authorization: Bearer $REPLICATE_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"version":"MODEL_VERSION_ID","input":{"prompt":"a red bicycle"}}'
Python
import replicate

output = replicate.run(
    "black-forest-labs/flux-schnell",
    input={"prompt": "a red bicycle, studio light"},
)
print(output)  # list of output image URLs

Rate limits & quotas

No fixed public rate limit, but the REST API caps you around a few hundred requests/minute for creating predictions; the real constraint is spend and GPU queue time. Long-running jobs should use a webhook instead of polling. Set a spend limit in billing.

Key response fields

idPrediction id — use it to poll GET /v1/predictions/{id}
statusstarting, processing, succeeded, failed or canceled
outputModel result — often a URL or list of URLs
metrics.predict_timeSeconds of compute you were billed for
urls.getCanonical URL to fetch the prediction’s current state

Common errors

401Missing or invalid token.
402Billing not set up or spend limit reached.
422Input does not match the model’s schema (wrong field or type).
429Too many predictions created too fast — back off.

When to use it (and alternatives)

Ideal for image/video/audio generation and one-off open models you don’t want to host. For text-only chat the OpenAI and Claude APIs are simpler; for a catalogue of smaller models on a free allowance see Hugging Face.

FAQ

How is Replicate billed?

By run time. Each model runs on a specific GPU or CPU class with a per-second price; your bill is that rate times how long the prediction ran. The model page shows a typical cost per run.

Do I have to poll for the result?

For quick models the SDK’s run() blocks until done. For slow jobs pass a webhook URL when creating the prediction and Replicate will POST the result to you.

What is a model 'version'?

Every published model has immutable version hashes. Pin a version id for reproducible output, or use the owner/name shorthand to always get the latest.

New to APIs?

Short guides for working with this API — and any other.

🛠️ Handy LarzOS tools

Free tools to help you work with this API.

Prompt ImproverLearn Prompt Engineering

Related AI & Machine Learning APIs

← Back

More AI & Machine Learning APIs · All 196 APIs