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",
"prompt": "A majestic eagle soaring over snow-capped mountains",
"audio": true
}'
Response:
{
"success": true,
"taskId": "veo_1704067200000_abc123",
"status": "pending",
"model": "veo3-fast",
"creditsRequired": 15,
"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_abc123
Authentication
The API supports three authentication methods:
1. Authorization Header (Recommended)
Authorization: Bearer veo_your_api_key_here
2. X-API-Key Header
X-API-Key: veo_your_api_key_here
3. Query Parameter (Not recommended)
?api_key=veo_your_api_key_here
API Endpoints
POST /api/generate
Generate a new video
Parameter | Type | Required | Description |
---|---|---|---|
model | string | Yes | "veo3-fast" or "veo3-quality" |
prompt | string | Yes | Video description (max 2000 chars) |
audio | boolean | No | Generate audio (default: true) |
Options Object:
Parameter | Type | Default | Description |
---|---|---|---|
resolution | string | "720p" | "720p" or "1080p" |
aspectRatio | string | "16:9" | "16:9" only (fixed) |
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": "16:9",
"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 |
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',
...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'
}
);
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
Video Generation Models
Model | Quality | Without Audio | With Audio | Generation Time |
---|---|---|---|---|
veo3-fast | Good | 10 credits | 15 credits | 1-3 minutes |
veo3-quality | High | 20 credits | 30 credits | 2-5 minutes |
Rate Limits
Generation Requests
100/hour
Per API key
Status Checks
1000/hour
Per API key