Skip to main content
This quick start shows how to call ppt.video with a minimal fetch request: create a google-veo-3.1 generation with a prompt, receive an id, and poll until it finishes.

Send your first request

Use any runtime that supports fetch. Replace placeholders before running.
const API_KEY = "<YOUR_API_KEY>";
const BASE_API_URL = "https://open.ppt.video/api";

async function createTask() {
  const res = await fetch(`${BASE_API_URL}/v1/generation/google/veo-3.1`, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${API_KEY}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      prompt: "sunrise over mountains in watercolor style"
    })
  });

  if (!res.ok) {
    throw new Error(`create failed: ${res.status} ${await res.text()}`);
  }

  const data = await res.json(); // { id, status, ... }
  console.log("created task:", data.id);
  return data.id;
}

Poll for the result

Poll the generation by id until it completes or fails.
const API_KEY = "<YOUR_API_KEY>";
const BASE_API_URL = "https://open.ppt.video/api";

async function pollTask(id: string) {
  for (let i = 0; i < 20; i++) {
    const res = await fetch(`${BASE_API_URL}/v1/generation/${id}`, {
      headers: { Authorization: `Bearer ${API_KEY}` }
    });

    if (!res.ok) {
      throw new Error(`poll failed: ${res.status} ${await res.text()}`);
    }

    const task = await res.json(); // { status, outputUrl?, error? }

    if (task.status === "succeeded") {
      console.log("done:", task.outputUrl ?? task);
      return task;
    }

    if (task.status === "failed") {
      throw new Error(`task failed: ${task.error ?? "unknown error"}`);
    }

    await new Promise((r) => setTimeout(r, 3000));
  }

  throw new Error("polling timed out");
}

// Example usage
(async () => {
  const id = await createTask();
  await pollTask(id);
})();