VEO3 API Tutorial 2025: Authentication, Setup & Video Generation (Python + JS)
Google's VEO3 is one of the most advanced video generation models available. This is the complete developer guide — authentication, endpoints, Python and JavaScript code examples, error handling, and everything the official docs do not tell you.
Get your free API key at nexa-api.com — start generating in under 2 minutes.
What is VEO3?
VEO3 is Google's state-of-the-art video generation model capable of producing high-quality, photorealistic videos from text prompts:
- Text-to-video generation up to 30 seconds
- 4K resolution output
- Cinematic quality with natural motion
- Multiple aspect ratios: 16:9, 9:16, 1:1
Getting Your API Key
- Visit nexa-api.com
- Click "Get Free API Key"
- Sign up (no credit card required)
- Copy your API key from the dashboard
Also available on RapidAPI.
Authentication
Method 1: Direct (for testing)
from nexaapi import NexaAPI
client = NexaAPI(api_key="your_api_key_here")
Method 2: Environment Variable (recommended)
export NEXAAPI_KEY="your_api_key_here"
import os
from nexaapi import NexaAPI
client = NexaAPI(api_key=os.environ.get("NEXAAPI_KEY"))
Your First Video Generation
# pip install nexaapi
from nexaapi import NexaAPI
client = NexaAPI(api_key="YOUR_API_KEY")
response = client.video.generate(
model="veo3",
prompt="A cinematic drone shot flying over a tropical beach at sunset",
duration=8
)
print(f"Video URL: {response.url}")
print(f"Cost: ${response.cost}")
5 lines of code. Professional-quality video. No GPU required.
Python Complete Tutorial
from nexaapi import NexaAPI
import os, requests, time
client = NexaAPI(api_key=os.environ.get("NEXAAPI_KEY", "your_api_key_here"))
# Basic generation
response = client.video.generate(
model="veo3",
prompt="A cinematic drone shot flying over a tropical beach at sunset",
duration=8,
resolution="1080p",
fps=24,
aspect_ratio="16:9"
)
print(f"Video URL: {response.url}")
print(f"Cost: ${response.cost}")
# Download the video
video_data = requests.get(response.url).content
with open("my_veo3_video.mp4", "wb") as f:
f.write(video_data)
print("Saved as my_veo3_video.mp4")
# Error handling
try:
response = client.video.generate(model="veo3", prompt="Your prompt", duration=10)
except NexaAPI.RateLimitError:
print("Rate limit hit — wait and retry")
except NexaAPI.AuthenticationError:
print("Invalid API key — check nexa-api.com")
except NexaAPI.APIError as e:
print(f"API error: {e.message}")
# Async generation for longer videos
job = client.video.generate_async(
model="veo3",
prompt="A slow-motion waterfall in a lush forest",
duration=15
)
while True:
status = client.video.get_status(job.job_id)
print(f"Status: {status.state} — {status.progress}%")
if status.state == "completed":
print(f"Done! {status.url}")
break
elif status.state == "failed":
print(f"Failed: {status.error}")
break
time.sleep(5)
JavaScript Complete Tutorial
// npm install nexaapi
import NexaAPI from "nexaapi";
const client = new NexaAPI({
apiKey: process.env.NEXAAPI_KEY || "your_api_key_here"
});
// Basic generation
async function generateVideo() {
const response = await client.video.generate({
model: "veo3",
prompt: "A cinematic drone shot flying over a tropical beach at sunset",
duration: 8,
resolution: "1080p",
fps: 24,
aspectRatio: "16:9"
});
console.log("Video URL:", response.url);
console.log("Cost: $" + response.cost);
return response;
}
// Error handling
async function generateSafe() {
try {
return await client.video.generate({
model: "veo3",
prompt: "Your creative prompt",
duration: 10
});
} catch (error) {
if (error instanceof NexaAPI.RateLimitError) {
console.error("Rate limit — retry after:", error.retryAfter, "seconds");
} else if (error instanceof NexaAPI.AuthenticationError) {
console.error("Invalid API key. Get yours at https://nexa-api.com");
} else {
console.error("API Error:", error.message);
}
}
}
// Express.js integration
import express from "express";
const app = express();
app.use(express.json());
app.post("/generate-video", async (req, res) => {
const { prompt, duration } = req.body;
const response = await client.video.generate({
model: "veo3",
prompt,
duration: duration || 5
});
res.json({ videoUrl: response.url, cost: response.cost });
});
app.listen(3000);
Parameters Reference
| Parameter | Type | Required | Default | Options |
|---|---|---|---|---|
| model | string | Yes | - | "veo3" |
| prompt | string | Yes | - | Max 500 chars |
| duration | integer | No | 5 | 3-30 seconds |
| resolution | string | No | "1080p" | "720p","1080p","4k" |
| fps | integer | No | 24 | 24, 30, 60 |
| aspect_ratio | string | No | "16:9" | "16:9","9:16","1:1" |
Error Handling Best Practices
| Error Code | Meaning | Solution |
|---|---|---|
| 401 | Invalid API key | Check your key at nexa-api.com |
| 429 | Rate limit exceeded | Wait and retry with exponential backoff |
| 400 | Invalid parameters | Check prompt length and parameter values |
| 500 | Server error | Retry after a few seconds |
Rate Limits & Pricing
| Plan | Rate Limit | Price |
|---|---|---|
| Free | 5 req/min | Free (limited) |
| Pro | 60 req/min | ~$0.01/sec of video |
| Enterprise | Custom | Custom |
VEO3 via NexaAPI is significantly cheaper than running your own GPU infrastructure.
Troubleshooting FAQ
Q: Video generation is taking too long?
A: Use generate_async and poll for status. Videos 15+ seconds can take 2-5 minutes.
Q: Getting a 401 error?
A: Check your API key at nexa-api.com. No extra spaces.
Q: Video quality not what I expected?
A: Be more specific in your prompt. Include lighting, camera angle, style, and subject details.
Resources
- NexaAPI: nexa-api.com — Free API key
- RapidAPI: rapidapi.com/user/nexaquency
-
Python SDK:
pip install nexaapi| PyPI -
Node.js SDK:
npm install nexaapi| npm - VEO3 docs reference: veo3gen.co/docs/authentication
Get your free API key at nexa-api.com and generate your first VEO3 video in under 2 minutes.
Top comments (0)