The REST basics: two endpoints, one Bearer key
The veo3gen API is deliberately small. You authenticate every request with an Authorization: Bearer <your-key> header — create the key on the API dashboard once you have an account — and you only ever talk to two routes:
| Step | Call | What it returns |
|---|---|---|
| 1. Submit | POST /api/generate | HTTP 202 with a taskId, the credits required, an estimated time, and a suggested polling interval |
| 2. Poll | GET /api/status/{taskId} | pending / processing progress, then completed with the video URL — or failed with a typed error and a refund |
The generate body takes a model (veo3-fast, veo3-quality, or veo3-lite), a prompt, an optional audio flag (default true), an optional base64 image for image-to-video, and an options object for resolution (720p/1080p), aspect ratio (16:9 or 9:16), seed, and negative prompt. The full parameter reference lives in the API documentation, with copy-paste clients for Node.js, Python, and PHP.
The async polling pattern, step by step
Video generation takes minutes, not milliseconds, so the API is fire-and-poll rather than request-and-wait. The pattern every integration follows:
Submit the generation from your server
POST the prompt and model to/api/generate. The API validates the request, screens the prompt, deducts credits, and immediately returns 202 with ataskId— it never holds your HTTP connection open while the video renders.Store the taskId and respond to your user
Persist thetaskIdagainst the user or job that requested it, and show a progress state in your UI. The 202 response includes anestimatedTime(1–2 minutes for Lite, 1–3 for Fast, 2–5 for Quality) you can surface directly.Poll the status endpoint with backoff
CallGET /api/status/{taskId}on an interval — the API suggests about 10 seconds. Start shorter and back off exponentially (the code below goes 5s to a 30s cap) so fast generations return quickly without hammering the endpoint on slow ones. While in flight, the response reports aprogressstage and estimated seconds remaining.Handle the terminal state
Oncompleted, readresult.videoUrl— a hosted MP4 you can play in a<video>tag or download to your own storage. Onfailed, read the typederrorobject and move on: the credits have already been refunded.
Here is the entire pattern in dependency-free JavaScript (Node 18+, native fetch):
const BASE = 'https://api.veo3gen.app';
const KEY = process.env.VEO3GEN_API_KEY; // server-side only
async function generateVideo(prompt) {
// 1. Submit — returns HTTP 202 + taskId immediately
const res = await fetch(`${BASE}/api/generate`, {
method: 'POST',
headers: {
Authorization: `Bearer ${KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ model: 'veo3-fast', prompt, audio: true }),
});
const { taskId } = await res.json();
// 2. Poll with exponential backoff (5s -> 30s cap)
let delay = 5000;
const deadline = Date.now() + 10 * 60 * 1000;
while (Date.now() < deadline) {
await new Promise((r) => setTimeout(r, delay));
const status = await fetch(`${BASE}/api/status/${taskId}`, {
headers: { Authorization: `Bearer ${KEY}` },
}).then((r) => r.json());
if (status.status === 'completed') return status.result.videoUrl;
if (status.status === 'failed') {
// credits are auto-refunded — see status.credits.refunded
throw new Error(status.error.message);
}
delay = Math.min(delay * 1.5, 30000);
}
throw new Error('Polling timed out');
}That one function is a production-shaped integration: submit, poll with backoff, hard deadline, typed failure. Wrap it in your own queue or worker if you batch generations, but nothing more is required to go live.
The code above runs against a real key — create yours in two minutes.
Get API AccessError and refund handling: what your integration must expect
Errors come typed, so your integration can branch on errorType instead of parsing messages. The important ones:
| Error type | When it happens | What your app should do |
|---|---|---|
VALIDATION_ERROR | Bad body — unknown model, missing prompt, invalid resolution | Fix the request; nothing was charged |
INSUFFICIENT_CREDITS | Account balance below the cost of the request | Prompt the account owner to top up |
CONTENT_POLICY_VIOLATION | Prompt or output blocked by content screening | Surface the reason; let the user rephrase |
RATE_LIMIT_EXCEEDED | Too many requests for your key or IP | Back off and retry later |
TIMEOUT / SYSTEM_ERROR | Generation exceeded its time budget or an upstream fault | Retry the generation — credits were refunded |
The refund rule is the part that simplifies your bookkeeping: credits are deducted when a generation starts and automatically refunded if it fails — timeouts, network faults, filtered outputs, all of it. You never file a ticket or issue a compensating transaction. Every status response carries a credits object with required, charged, and refunded, so a nightly reconciliation job can verify that every failed task shows charged: 0 or a matching refund. The error object also includes a retryable flag, which tells your worker whether resubmitting the same request is worthwhile.
Budgeting credits: what each generation costs your app
Credit costs are fixed per model and resolution, which makes per-feature budgeting straightforward. For an 8-second video with audio:
| Model | Credits (8s, audio) | Approx. cost per video |
|---|---|---|
| Veo 3.1 Lite | 3 (720p) – 5 (1080p) | ≈ $0.64–$1.35 |
| Veo 3 / 3.1 Fast | 10 (720p or 1080p) | ≈ $2.13–$2.50 |
| Veo 3 / 3.1 Quality | 26 (720p or 1080p) | ≈ $5.55–$6.50 |
| 4K (Veo 3.1 only) | 22 (Fast) / 38 (Quality) | ≈ $1.21–$3.15 |
Shorter clips scale down — 4-second videos cost 0.5x and 6-second videos 0.75x — and the effective price per credit runs $0.213 to $0.250 depending on which pack or subscription you buy (credits are valid at least 30 days from purchase; see Terms). A practical budgeting habit: prototype and iterate on Lite at 3 credits a shot, then re-render the winning prompts on Fast or Quality for production. That typically cuts development-phase spend by two-thirds without touching final output quality.
Frequently asked questions
How do I integrate AI video generation into my app?
Does the veo3gen API use webhooks or polling?
What happens to my credits if a video generation fails?
Can I call the video generation API directly from my frontend?
How many credits does one generated video cost?
How long does a generation take to complete?
Two REST calls between your app and Veo 3 video
Create a key, paste the polling loop above, and generate — auto-refunds on failure, credits from $9.99, no Google Cloud setup.
No credit card required — sign in with Google and start in seconds.