2. Generate Your First Video
Make a POST request to generate a video:
curl -X POST https://api.veo3gen.app/api/generate \
-H "Authorization: Bearer veo_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"model": "veo3-fast",
"modelVersion": "3.1",
"prompt": "A majestic eagle soaring over snow-capped mountains",
"audio": true,
"options": {
"aspectRatio": "9:16",
"resolution": "1080p"
}
}'Response:
{
"success": true,
"taskId": "veo_1704067200000_abc123",
"status": "pending",
"model": "veo3-fast",
"creditsRequired": 10,
"resolution": "1080p",
"estimatedTime": "1-3 minutes"
}3. Check Generation Status
Use the taskId to check your video's progress:
curl -H "Authorization: Bearer veo_your_api_key_here" \
https://api.veo3gen.app/api/status/veo_1704067200000_abc123Authentication
The API supports three authentication methods:
1. Authorization Header (Recommended)
Authorization: Bearer veo_your_api_key_here2. X-API-Key Header
X-API-Key: veo_your_api_key_here3. Query Parameter (Not recommended)
?api_key=veo_your_api_key_hereAPI Endpoints
POST /api/generate
Generate a new video
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | "veo3-fast" or "veo3-quality"quot;veo3-fast"veo3-fast" or "veo3-quality"quot;, "veo3-fast" or "veo3-quality"quot;veo3-quality"veo3-fast" or "veo3-quality"quot;, or "veo3-fast" or "veo3-quality"quot;veo3-lite"veo3-fast" or "veo3-quality"quot; |
| prompt | string | Yes | Video description (max 2000 chars) |
| audio | boolean | No | Generate audio (default: true) |
| modelVersion | string | No | "3.1" (default). Legacy 3.0 requests are automatically upgraded to 3.1. |
| image | object | No | Input image for image-to-video generation |
| lastFrame | object | No | Last frame for first-and-last-frame (requires veo3-fast/quality 3.1, or veo3-lite) |
Options Object:
| Parameter | Type | Default | Description |
|---|---|---|---|
| resolution | string | "1080p" | "720p", "1080p", or "4k" — 4K requires modelVersion "3.1" + veo3-fast/quality; Lite max 1080p |
| aspectRatio | string | "16:9" | "16:9" or "9:16" |
| seed | number | Random | 0-4294967295 for deterministic results |
| negativePrompt | string | - | What to avoid in the video |
| enhancePrompt | boolean | true | AI prompt enhancement |
GET /api/status/:taskId
Check the status of a video generation task
Completed Response:
{
"success": true,
"taskId": "veo_1704067200000_xyz789",
"status": "completed",
"result": {
"videoUrl": "https://storage.googleapis.com/veo3videosave/video_xyz789.mp4",
"duration": 8,
"resolution": "1080p",
"aspectRatio": "9:16",
"hasAudio": true,
"processingTimeSeconds": 187
},
"credits": {
"required": 30,
"charged": 30,
"refunded": 0
}
}GET /api/logs
Retrieve your generation history with filtering and pagination
| Parameter | Type | Description |
|---|---|---|
| page | number | Page number (default: 1) |
| limit | number | Items per page (max: 100, default: 20) |
| status | string | Filter by status |
| model | string | Filter by model |
🖼️ Image-to-Video Generation
Generate videos from an input image. Works with all active Veo 3.1 Quality, Fast, and Lite models. Perfect for bringing static images to life with motion and animation.
Key Features
- Same credit pricing as text-to-video generation
- Supports JPEG, PNG, and WebP formats
- Works with all active VEO 3.1 models
- Optional prompt for controlling the motion
- All aspect ratios supported (16:9 and 9:16)
Request Format
POST /api/generate
{
"model": "veo3-quality",
"modelVersion": "3.1",
"prompt": "A serene lake with gentle waves and birds flying overhead",
"audio": true,
"image": {
"bytesBase64Encoded": "base64_encoded_image_data_here",
"mimeType": "image/jpeg"
},
"options": {
"resolution": "1080p",
"aspectRatio": "16:9"
}
}Image Object Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| bytesBase64Encoded | string | Yes | Base64-encoded image data |
| mimeType | string | Yes | "image/jpeg", "image/png", or "image/webp" |
💰 Pricing: Image-to-video uses the same credit pricing as text-to-video. No additional cost for using images!
💡 Tip: The prompt is optional for image-to-video, but providing one gives you better control over the motion and animation style.
🎞️ First-and-Last-Frame Generation
Generate a video that smoothly transitions between two images (first and last frame). Requires VEO 3.1 models. Perfect for creating transformations, before/after sequences, and precise video keyframing.
Key Features
- Same credit pricing as regular video generation
- Requires VEO 3.1 models (both fast and quality)
- Control both the start and end of your video
- Perfect for product transformations and storytelling
- Smooth AI-generated transitions between frames
Request Format
POST /api/generate
{
"model": "veo3-quality",
"modelVersion": "3.1", // REQUIRED for first-and-last-frame
"prompt": "A smooth cinematic transition from sunrise to sunset",
"audio": true,
"image": {
"bytesBase64Encoded": "base64_encoded_first_frame_here",
"mimeType": "image/jpeg"
},
"lastFrame": {
"bytesBase64Encoded": "base64_encoded_last_frame_here",
"mimeType": "image/jpeg"
},
"options": {
"resolution": "1080p",
"aspectRatio": "16:9"
}
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| modelVersion | string | Yes | Must be "3.1" for this feature |
| image | object | Yes | First frame image object |
| lastFrame | object | Yes | Last frame image object |
Important: First-and-last-frame generation uses VEO 3.1 models. Legacy 3.0 requests are automatically upgraded to 3.1.
✨ Pro Tip: Use descriptive prompts to guide the transition between frames. For example: "smooth transformation" or "dramatic cinematic transition".
Error Handling
Common Error Types
| Error Type | HTTP Code | Description | Retryable |
|---|---|---|---|
| INVALID_API_KEY | 401 | API key is invalid or inactive | ❌ No |
| INSUFFICIENT_CREDITS | 400 | Not enough credits for generation | ❌ No |
| RATE_LIMIT_EXCEEDED | 429 | Too many requests | ✅ Yes |
| CONTENT_POLICY_VIOLATION | 400 | Content blocked by AI safety | ❌ No |
| SYSTEM_ERROR | 500 | Internal server error | ✅ Yes |
Error Response Format
{
"success": false,
"error": "User-friendly error message",
"errorType": "ERROR_TYPE_CONSTANT",
"details": {
"field": "specific field that caused the error"
}
}Retry Strategy Example:
async function retryableRequest(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
const isRetryable = [
'RATE_LIMIT_EXCEEDED',
'QUOTA_EXCEEDED',
'SYSTEM_ERROR'
].includes(error.errorType);
if (!isRetryable || i === maxRetries - 1) {
throw error;
}
// Exponential backoff
const delay = Math.min(1000 * Math.pow(2, i), 30000);
await new Promise(resolve => setTimeout(resolve, delay));
}
}
}Code Examples
const axios = require('axios');
class VEO3Client {
constructor(apiKey, baseURL = 'https://api.veo3gen.app') {
this.apiKey = apiKey;
this.baseURL = baseURL;
this.client = axios.create({
baseURL,
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
});
}
async generateVideo(prompt, options = {}) {
try {
console.log('Starting video generation...');
console.log(`Prompt: ${prompt}`);
console.log(`Model: ${options.model || 'veo3-fast'}`);
const response = await this.client.post('/api/generate', {
model: options.model || 'veo3-fast',
prompt,
audio: options.audio !== false,
options: {
resolution: options.resolution || '720p',
aspectRatio: options.aspectRatio || '16:9', // '16:9' or '9:16'
...options.veo3Options
}
});
console.log(`Generation started with task ID: ${response.data.taskId}`);
return response.data;
} catch (error) {
console.error('Generation request failed:', error.message);
throw new Error(`Generation failed: ${error.response?.data?.error || error.message}`);
}
}
async pollStatus(taskId, maxWaitTime = 300000) {
const startTime = Date.now();
console.log(`Starting to poll status for task: ${taskId}`);
while (Date.now() - startTime < maxWaitTime) {
try {
const response = await this.client.get(`/api/status/${taskId}`);
const status = response.data;
console.log(`Status check: ${status.status}`);
if (status.status === 'completed') {
console.log('Video generation completed successfully!');
return status;
} else if (status.status === 'failed') {
console.log('Video generation failed');
throw new Error(status.error.message);
}
console.log('Video still processing, waiting 10 seconds...');
// Wait 10 seconds before next poll
await new Promise(resolve => setTimeout(resolve, 10000));
} catch (error) {
console.error('Error during status check:', error.message);
throw new Error(`Status check failed: ${error.response?.data?.error || error.message}`);
}
}
console.log('Video generation timed out');
throw new Error('Video generation timed out');
}
async generateAndWait(prompt, options = {}) {
const generation = await this.generateVideo(prompt, options);
const result = await this.pollStatus(generation.taskId, options.maxWaitTime);
return result;
}
}
// Usage
const client = new VEO3Client('veo_your_api_key_here');
async function example() {
try {
const result = await client.generateAndWait(
'A majestic eagle soaring over mountains',
{
model: 'veo3-quality',
audio: true,
resolution: '1080p',
aspectRatio: '9:16' // Portrait video
}
);
console.log('Video generated!', result.result.videoUrl);
} catch (error) {
console.error('Error:', error.message);
}
}
example();Best Practices
API Key Management
- • Store API keys securely (environment variables)
- • Use different keys for development and production
- • Rotate keys periodically for security
- • Monitor key usage regularly
Rate Limiting
- • Respect rate limits (100 requests/hour)
- • Implement exponential backoff
- • Monitor your usage patterns
- • Request increases if needed
Error Handling
- • Always handle API errors gracefully
- • Implement retry logic for retryable errors
- • Log errors for debugging
- • Provide user-friendly error messages
Cost Optimization
- • Choose the right model (fast vs quality)
- • Only generate audio when needed
- • Cache results when appropriate
- • Monitor credit usage patterns
Pricing & Credits
Credit Pricing — Resolution-Aware
| Model | Resolution | No Audio | With Audio | Time |
|---|---|---|---|---|
| veo3-lite | 720p | 2 credits | 3 credits | 1-2 min |
| veo3-lite | 1080p | 3 credits | 5 credits | 1-2 min |
| veo3-fast | 720p / 1080p | 6 credits | 10 credits | 1-3 min |
| veo3-fast | 4K (3.1 only) | 19 credits | 22 credits | 1-3 min |
| veo3-quality | 720p / 1080p | 13 credits | 26 credits | 2-5 min |
| veo3-quality | 4K (3.1 only) | 26 credits | 38 credits | 2-5 min |
🆕 Veo 3.1 Lite: Lowest credit use — from 2 credits. Limited to 720p/1080p and no 4K. Set model: "veo3-lite".
✨ 4K Resolution: Available for veo3-fast/quality with modelVersion: "3.1". Set options.resolution: "4k". Not supported by veo3-lite.
💰 All generation types (text-to-video, image-to-video, first-and-last-frame) cost the same credits. No extra charge for image inputs!
Rate Limits
Generation Requests
100/hour
Per API key
Status Checks
1000/hour
Per API key