Skip to main content

Documentation

API documentation

Create your first image in four steps. The API lives at https://api.cheapvids.com and every call needs your API key.

Quick start

1. Get an API key

API keys unlock after your first USDT payment. Create one on the developer page of your account; it is shown once, so store it in an environment variable. Keep it on your server.

2. Create a job

Send the model, the prompt and the plan group to charge. The plan is required: "studio" or "credits". The system never switches group for you.

curl https://api.cheapvids.com/v1/generations \
  -H "Authorization: Bearer $CHEAPVIDS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"plan":"credits","model":"nano-banana-2","params":{"prompt":"A lighthouse at dusk"}}'

3. Read the result

Wait with ?wait=60 until the job is completed, then download the file from output.url. CheapVids relays results for a limited window after completion (24 hours by default), so download right away.

curl "https://api.cheapvids.com/v1/generations/$GENERATION_ID?wait=60" \
  -H "Authorization: Bearer $CHEAPVIDS_API_KEY"

# status "completed": download output.url right away
curl -L "$OUTPUT_URL" -o result.png
import os, uuid, requests

API = "https://api.cheapvids.com/v1"
s = requests.Session()
s.headers["Authorization"] = f"Bearer {os.environ['CHEAPVIDS_API_KEY']}"

body = {"plan": "credits", "model": "nano-banana-2", "params": {"prompt": "A lighthouse at dusk"}}
r = s.post(f"{API}/generations", json=body, headers={"Idempotency-Key": str(uuid.uuid4())}, timeout=120)
r.raise_for_status()
job = r.json()
while job["status"] not in ("completed", "failed", "cancelled"):
    r = s.get(f"{API}/generations/{job['id']}", params={"wait": 60}, timeout=90)
    r.raise_for_status()
    job = r.json()
if job["status"] == "completed":
    r = s.get(f"{API}/generations/{job['id']}/content", timeout=120)
    r.raise_for_status()
    open("result.png", "wb").write(r.content)
import { writeFile } from "node:fs/promises";

const API = "https://api.cheapvids.com/v1";
const auth = { Authorization: "Bearer " + process.env.CHEAPVIDS_API_KEY };
async function call(path, init = {}) {
  const res = await fetch(API + path, { ...init, headers: { ...auth, ...init.headers } });
  if (!res.ok) throw new Error(res.status + " " + (await res.text()));
  return res;
}

const body = { plan: "credits", model: "nano-banana-2", params: { prompt: "A lighthouse at dusk" } };
let job = await (await call("/generations", {
  method: "POST",
  headers: { "Content-Type": "application/json", "Idempotency-Key": crypto.randomUUID() },
  body: JSON.stringify(body),
})).json();
while (!["completed", "failed", "cancelled"].includes(job.status)) {
  job = await (await call("/generations/" + job.id + "?wait=60")).json();
}
if (job.status === "completed") {
  const res = await call("/generations/" + job.id + "/content");
  await writeFile("result.png", Buffer.from(await res.arrayBuffer()));
}

4. Or receive a webhook

Register an HTTPS endpoint to get generation.started, generation.completed and generation.failed events, signed with HMAC-SHA256. Each event is sent at most 4 times: the first send and 3 retries after 10, 60 and 300 seconds.

X-CheapVids-Event: generation.completed
X-CheapVids-Delivery: 0190a1b2-0000-7000-8000-000000000001
X-CheapVids-Signature: t=1760000000,v1=64e08ed860b53ecdca19eb0ef68dccefd1c7f3135a0a0e273d34a878d48b8ed5

Tools