Rate Limits
Understanding and working with VEO3 API rate limits to ensure optimal performance and reliability.
Rate Limit Overview
VEO3 API implements rate limiting to ensure fair usage and maintain service quality
Requests per Minute
60
Maximum requests per minute per API key
Concurrent Requests
10
Maximum concurrent requests
Video Generation Queue
5
Maximum videos in generation queue
Daily Limit
1000
Maximum requests per day
Rate Limit Headers
Every API response includes rate limit information in headers
Response Headers
X-RateLimit-Limit: 60 X-RateLimit-Remaining: 45 X-RateLimit-Reset: 1640995200 X-RateLimit-Retry-After: 60
Header Descriptions
X-RateLimit-Limit- Maximum requests allowedX-RateLimit-Remaining- Requests remaining in current windowX-RateLimit-Reset- Unix timestamp when limit resetsX-RateLimit-Retry-After- Seconds to wait before retrying
Status Codes
- 200 - Request successful
- 429 - Rate limit exceeded
- 503 - Service temporarily unavailable
Rate Limit Errors
Understanding and handling rate limit error responses
When rate limits are exceeded, the API returns a 429 status code with detailed error information.
429 Error Response
{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Rate limit exceeded. Maximum 60 requests per minute allowed.",
"details": {
"limit": 60,
"remaining": 0,
"reset": 1640995200,
"retry_after": 60
}
}
}Handling Rate Limits
Best practices and code examples for handling rate limits in different programming languages
JavaScript/Node.js
async function makeRequestWithRetry(url, options, maxRetries = 3) {
for (let attempt = 0; attempt <= maxRetries; attempt++) {
try {
const response = await fetch(url, options);
// Check rate limit headers
const remaining = response.headers.get('X-RateLimit-Remaining');
const resetTime = response.headers.get('X-RateLimit-Reset');
if (response.status === 429) {
const retryAfter = response.headers.get('X-RateLimit-Retry-After');
console.log(`Rate limited. Retrying in ${retryAfter} seconds...`);
if (attempt < maxRetries) {
await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
continue;
}
throw new Error('Rate limit exceeded after max retries');
}
// Log remaining requests
console.log(`Requests remaining: ${remaining}`);
return response;
} catch (error) {
if (attempt === maxRetries) throw error;
await new Promise(resolve => setTimeout(resolve, 1000));
}
}
}
// Usage example
const response = await makeRequestWithRetry('https://api.veo3gen.co/v1/generate', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
prompt: "A serene sunset over mountains",
model: "veo-3.0-generate"
})
});
Python
import requests
import time
from typing import Dict, Any
class VEO3Client:
def __init__(self, api_key: str):
self.api_key = api_key
self.base_url = "https://api.veo3gen.co/v1"
self.headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
def make_request_with_retry(self, endpoint: str, data: Dict[Any, Any], max_retries: int = 3):
url = f"{self.base_url}/{endpoint}"
for attempt in range(max_retries + 1):
try:
response = requests.post(url, json=data, headers=self.headers)
# Check rate limit headers
remaining = response.headers.get('X-RateLimit-Remaining')
reset_time = response.headers.get('X-RateLimit-Reset')
if response.status_code == 429:
retry_after = int(response.headers.get('X-RateLimit-Retry-After', 60))
print(f"Rate limited. Retrying in {retry_after} seconds...")
if attempt < max_retries:
time.sleep(retry_after)
continue
else:
raise Exception("Rate limit exceeded after max retries")
# Log remaining requests
print(f"Requests remaining: {remaining}")
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
if attempt == max_retries:
raise e
time.sleep(1)
def generate_video(self, prompt: str, model: str = "veo-3.0-generate"):
data = {
"prompt": prompt,
"model": model
}
return self.make_request_with_retry("generate", data)
# Usage
client = VEO3Client("YOUR_API_KEY")
result = client.generate_video("A serene sunset over mountains")
cURL with Rate Limit Handling
#!/bin/bash
API_KEY="YOUR_API_KEY"
BASE_URL="https://api.veo3gen.co/v1"
MAX_RETRIES=3
make_request() {
local endpoint=$1
local data=$2
local retry_count=0
while [ $retry_count -le $MAX_RETRIES ]; do
response=$(curl -s -w "%{http_code}" -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-H "X-RateLimit-Remaining:" \
-H "X-RateLimit-Reset:" \
-H "X-RateLimit-Retry-After:" \
-d "$data" \
"$BASE_URL/$endpoint")
http_code=$(echo "$response" | tail -c 4)
body=$(echo "$response" | head -c -4)
if [ "$http_code" -eq 429 ]; then
retry_after=$(echo "$response" | grep -o 'X-RateLimit-Retry-After: [0-9]*' | cut -d' ' -f2)
echo "Rate limited. Retrying in $retry_after seconds..."
sleep $retry_after
((retry_count++))
elif [ "$http_code" -eq 200 ]; then
echo "$body"
return 0
else
echo "Error: HTTP $http_code"
echo "$body"
return 1
fi
done
echo "Max retries exceeded"
return 1
}
# Usage
data='{"prompt": "A serene sunset over mountains", "model": "veo-3.0-generate"}'
make_request "generate" "$data"Best Practices
Optimize your application for rate limit compliance
Do
- • Implement exponential backoff for retries
- • Monitor rate limit headers in responses
- • Cache responses when possible
- • Use batch requests for multiple operations
- • Implement request queuing in your application
- • Set appropriate timeouts for requests
Don't
- • Ignore rate limit headers
- • Make requests faster than limits allow
- • Retry immediately after 429 errors
- • Use multiple API keys to bypass limits
- • Make unnecessary duplicate requests
- • Implement aggressive retry strategies
Important: Attempting to bypass rate limits may result in API key suspension. Always respect the limits and implement proper retry logic.
Rate Limit Monitoring
Track and monitor your API usage to stay within limits
Simple Rate Limit Monitor (JavaScript)
class RateLimitMonitor {
constructor() {
this.requests = [];
this.windowSize = 60000; // 1 minute
}
canMakeRequest() {
const now = Date.now();
// Remove old requests outside the window
this.requests = this.requests.filter(time => now - time < this.windowSize);
return this.requests.length < 60; // 60 requests per minute
}
recordRequest() {
this.requests.push(Date.now());
}
getTimeUntilReset() {
if (this.requests.length === 0) return 0;
const oldestRequest = Math.min(...this.requests);
return Math.max(0, this.windowSize - (Date.now() - oldestRequest));
}
}
// Usage
const monitor = new RateLimitMonitor();
async function makeApiCall() {
if (!monitor.canMakeRequest()) {
const waitTime = monitor.getTimeUntilReset();
console.log(`Rate limit would be exceeded. Wait ${waitTime}ms`);
return;
}
monitor.recordRequest();
// Make your API call here
}Enterprise Rate Limits
Higher limits available for enterprise customers
Standard
- 60 requests/minute
- 10 concurrent requests
- 1,000 requests/day
Pro
- 300 requests/minute
- 50 concurrent requests
- 10,000 requests/day
Enterprise
- Custom limits
- Dedicated resources
- Priority support
Contact our sales team for enterprise pricing and custom rate limits that meet your specific requirements.