Updated July 2026

How to Integrate AI Video Generation in Your App

To integrate AI video generation, your server makes two REST calls: POST https://api.veo3gen.app/api/generate with a Bearer API key and a prompt, then polls GET /api/status/{taskId} until the video URL is ready. Failed generations refund their credits automatically. Here is the complete wiring, with code.

Key takeaways

  • The whole integration is two endpoints: submit a generation, poll its status. No SDK or webhook setup required.
  • Generation is asynchronous — the API returns a taskId in an HTTP 202 immediately; videos take about 1–5 minutes depending on model.
  • Every failure path auto-refunds credits; the status response reports charged and refunded so you can reconcile.
  • Keep your API key in a server-side environment variable — never in frontend or mobile bundles.
  • Budget 3–26 credits per 8-second video (Lite / Fast / Quality), roughly $0.17–$0.83 each depending on plan.
Veo 3 REST API

Get an API key and ship your first video today

Bearer-token REST API for Veo 3 and 3.1 — no Google Cloud project, no quota requests. Failed generations auto-refund.

No credit card required — sign in with Google and start in seconds.

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:

StepCallWhat it returns
1. SubmitPOST /api/generateHTTP 202 with a taskId, the credits required, an estimated time, and a suggested polling interval
2. PollGET /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:

  1. 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 a taskId — it never holds your HTTP connection open while the video renders.
  2. Store the taskId and respond to your user

    Persist the taskId against the user or job that requested it, and show a progress state in your UI. The 202 response includes an estimatedTime (1–2 minutes for Lite, 1–3 for Fast, 2–5 for Quality) you can surface directly.
  3. Poll the status endpoint with backoff

    Call GET /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 a progress stage and estimated seconds remaining.
  4. Handle the terminal state

    On completed, read result.videoUrl — a hosted MP4 you can play in a <video> tag or download to your own storage. On failed, read the typed error object 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 Access

Error 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 typeWhen it happensWhat your app should do
VALIDATION_ERRORBad body — unknown model, missing prompt, invalid resolutionFix the request; nothing was charged
INSUFFICIENT_CREDITSAccount balance below the cost of the requestPrompt the account owner to top up
CONTENT_POLICY_VIOLATIONPrompt or output blocked by content screeningSurface the reason; let the user rephrase
RATE_LIMIT_EXCEEDEDToo many requests for your key or IPBack off and retry later
TIMEOUT / SYSTEM_ERRORGeneration exceeded its time budget or an upstream faultRetry 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:

ModelCredits (8s, audio)Approx. cost per video
Veo 3.1 Lite3 (720p) – 5 (1080p)≈ $0.64–$1.35
Veo 3 / 3.1 Fast10 (720p or 1080p)≈ $2.13–$2.50
Veo 3 / 3.1 Quality26 (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?

Two REST calls: send POST https://api.veo3gen.app/api/generate with your API key as a Bearer token and a JSON body containing a model and prompt. The API responds immediately (HTTP 202) with a taskId. Then poll GET https://api.veo3gen.app/api/status/{taskId} every few seconds until status is "completed" and the response contains the video URL.

Does the veo3gen API use webhooks or polling?

Polling. Generation is asynchronous: the generate endpoint returns a taskId right away, and your server polls the status endpoint (the API suggests roughly every 10 seconds) until the task completes or fails. No webhook infrastructure, public callback URL, or queue is required — a simple polling loop with backoff is the whole integration.

What happens to my credits if a video generation fails?

They are refunded automatically. Credits are deducted when a generation starts; if it fails for any reason — timeout, network error, content filtering, system error — the API refunds them without any action on your side. The status response includes a credits object showing required, charged, and refunded amounts, so your app can reconcile every task.

Can I call the video generation API directly from my frontend?

No — never ship your API key in client-side code. Anything bundled into a browser app or mobile client can be extracted, and a leaked key lets strangers burn your credits. Keep the key in a server-side environment variable and expose your own thin endpoint that your frontend calls; your server talks to api.veo3gen.app.

How many credits does one generated video cost?

An 8-second video with audio costs 3–5 credits on Veo 3.1 Lite (720p–1080p), 10 credits on Fast, and 26 on Quality; 4K runs 22 (Fast) or 38 (Quality) on Veo 3.1. Shorter videos cost less: 4-second clips are 0.5x and 6-second clips 0.75x. At $0.213–$0.250 per credit depending on plan, a Fast video works out to roughly $2.13–$2.50.

How long does a generation take to complete?

The API estimates 1–2 minutes for Veo 3.1 Lite, 1–3 minutes for Fast, and 2–5 minutes for Quality. Your polling loop should tolerate the upper end; generations that exceed the server-side timeout are failed and auto-refunded, so a stuck task never silently eats credits.
Ship it

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.