Ana içeriğe geç

Dokümanlar

API dokümanları

İlk görselinizi dört adımda oluşturun. API https://api.cheapvids.com adresindedir ve her çağrı API anahtarınızı gerektirir.

Ayrıntılı kılavuzlar ve API referansı yalnızca İngilizcedir.

Hızlı başlangıç

1. Bir API anahtarı alın

API anahtarları ilk USDT ödemenizden sonra açılır. Hesabınızın geliştirici sayfasında bir tane oluşturun; yalnızca bir kez gösterilir, bu yüzden bir ortam değişkeninde saklayın. Anahtarı sunucunuzda tutun.

2. Bir iş oluşturun

Modeli, prompt'u ve ücretlendirilecek grubu gönderin. plan parametresi zorunludur: "studio" veya "credits". Sistem sizin yerinize asla grup değiştirmez.

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. Sonucu okuyun

İş tamamlanana kadar ?wait=60 ile bekleyin, ardından dosyayı output.url adresinden indirin. CheapVids sonuçları tamamlandıktan sonra sınırlı bir süre boyunca iletir (varsayılan olarak 24 saat), bu yüzden hemen indirin.

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. Ya da bir webhook alın

generation.started, generation.completed ve generation.failed olaylarını almak için bir HTTPS uç noktası kaydedin; olaylar HMAC-SHA256 ile imzalanır. Her olay en fazla 4 kez gönderilir: ilk gönderim ve 10, 60 ve 300 saniye sonraki 3 yeniden deneme.

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

Araçlar