Generate AI Videos Programmatically: A Code-First Guide

You've seen the potential, now let's write the code. This is a hands-on tutorial for developers to start generating videos with our simple REST API.

The Core Concept: A Single API Endpoint

Everything happens through a single, straightforward POST request. There are no complex workflows or multiple endpoints to manage.

POST https://api.veo3gen.app/v1/generate

Content-Type: application/json

Authorization: Bearer YOUR_API_KEY

Code Examples in Your Language

cURL / Command Line

The simplest way to test the API directly from your terminal.


curl -X POST https://api.veo3gen.app/v1/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A robot DJ playing a set in a futuristic nightclub, neon lights, cinematic",
    "model": "veo3-quality"
  }'

Node.js (with Axios)


// npm install axios
const axios = require('axios');

const apiKey = process.env.VEO_API_KEY;
const prompt = "A photorealistic drone shot flying over a dense jungle canopy at sunrise.";

axios.post('https://api.veo3gen.app/v1/generate', {
  prompt: prompt,
}, {
  headers: {
    'Authorization': `Bearer ${apiKey}`
  }
}).then(response => {
  console.log('Video URL:', response.data.video_url);
}).catch(error => {
  console.error('Error:', error.response.data);
});

Python (with Requests)


# pip install requests
import requests
import os

api_key = os.getenv("VEO_API_KEY")
prompt = "An animated, Studio Ghibli-style scene of a train traveling through a lush countryside."

headers = {"Authorization": f"Bearer {api_key}"}
payload = {"prompt": prompt}

response = requests.post("https://api.veo3gen.app/v1/generate", headers=headers, json=payload)

if response.status_code == 200:
    print(f"Video URL: {response.json().get('video_url')}")
else:
    print(f"Error: {response.text}")

PHP (with cURL)


<?php
$apiKey = getenv('VEO_API_KEY');
$prompt = "A majestic whale breaching the ocean surface in slow motion, cinematic lighting.";

$ch = curl_init('https://api.veo3gen.app/v1/generate');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['prompt' => $prompt]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'Authorization: Bearer ' . $apiKey
]);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);

if (isset($result['video_url'])) {
    echo "Video URL: " . $result['video_url'];
} else {
    echo "Error: " . $response;
}
?>

Exploring Key Parameters

The `prompt` is just the beginning. You can fine-tune your generations with several other parameters.

model

Choose between veo3-quality (default, higher fidelity) and veo3-fast (quicker, lower cost, great for previews).

aspect_ratio

Set the dimensions. Common values: "16:9" (YouTube), "9:16" (TikTok), "1:1" (Instagram).

negative_prompt

A string to specify what you *don't* want to see. E.g., "blurry, grainy, deformed".

seed

An integer. If you use the same seed and prompt, you'll get a very similar output, allowing for reproducible results.


// Example with more parameters
{
  "prompt": "A corgi wearing sunglasses on a skateboard, digital art",
  "model": "veo3-quality",
  "aspect_ratio": "1:1",
  "negative_prompt": "ugly, blurry, low quality",
  "seed": 12345
}

Your Toolbox is Ready.

You have the code, the parameters, and the power of a world-class generative model. It's time to build something amazing.