Migrate
Migrate from Replicate
OpenAI-compatible alternative to Replicate's async-by-default model. Same access to FLUX / Stable Diffusion / Llama / etc., but sync chat completions and unified billing.
CLI automation for Replicate isn't shipped yet — you'll do this manually below. PRs welcome at packages/aig-cli/src/commands/migrate.ts.
TL;DR — three lines
# 1. set your AIgateway key export AIGATEWAY_API_KEY="sk-aig-..." # 2. change the base URL base_url="https://api.aigateway.sh/v1" # was https://api.replicate.com/v1 # 3. search-and-replace the env var name
What changes, line-by-line
The table below is what aig migrate replicate rewrites. If you're doing it by hand, do these in order.
| Thing | Replicate | AIgateway |
|---|---|---|
| Base URL | https://api.replicate.com/v1 | https://api.aigateway.sh/v1 |
| API key env var | REPLICATE_API_TOKEN | AIGATEWAY_API_KEY |
| Auth header | Token … | Authorization: Bearer … |
| Request shape | Custom Replicate JSON | OpenAI-compatible (chat/images/etc.) |
| Polling | Required for most models | Streaming for text, async-job pattern for video |
Before / after — Python (OpenAI SDK)
BEFORE · Replicate
from openai import OpenAI
client = OpenAI(
base_url="https://api.replicate.com/v1",
api_key=os.environ["REPLICATE_API_TOKEN"],
)
r = client.chat.completions.create(
model="anthropic/claude-opus-4.7",
messages=[{"role": "user", "content": "Hi"}],
)AFTER · AIgateway
from openai import OpenAI
client = OpenAI(
base_url="https://api.aigateway.sh/v1",
api_key=os.environ["AIGATEWAY_API_KEY"],
)
r = client.chat.completions.create(
model="anthropic/claude-opus-4.7",
messages=[{"role": "user", "content": "Hi"}],
)Behavioral notes
- Replicate's custom request shape doesn't map 1:1 — you'll need to rewrite the request bodies, not just the URL. Text models go to /v1/chat/completions, images to /v1/images/generations, video to /v1/videos/generations.
- Webhooks: Replicate uses URL-callback webhooks on completion; AIgateway has the same pattern for async jobs at /v1/jobs.
- No CLI automation — manual rewrite. See /docs/images and /docs/async-jobs for the equivalent shapes.
Credit match
Email your last invoice from Replicate to switch@aigateway.sh and we match the credit up to $1,000 (24-hour turnaround). Or read the full pitch at /switch/replicate.
What to read next
- BYOK — bring your existing Replicate provider keys; pay 0% on those routes.
- Sub-accounts — per-customer keys with spend caps; the closest analogue to workspace-isolated keys.
- All migration guides — same docs for OpenRouter, Portkey, Helicone, LiteLLM, Together, Replicate, Fireworks, Requesty.