Veo 3.1 API, Pricing & Playground | Vercel AI Gateway
Veo 3.1 Overview
Veo 3.1 is Google's flagship video model in the Veo 3.1 generation on AI Gateway, the quality ceiling of that generation, with strong motion fidelity, native audio-visual synchronization, and image-to-video support for professional production workflows.
Price
$0.20 per second
Code Example
import { experimental_generateVideo as generateVideo } from 'ai';
const result = await generateVideo({
model: 'google/veo-3.1-generate-001',
prompt: 'A serene mountain lake at sunrise.'
});
Getting Started
Generate videos with Veo 3.1 using the experimental_generateVideo function from AI SDK 6 or later. AI Gateway handles routing and polls until the video is ready.
- Install the AI SDK (
pnpm add ai dotenv). - Create an API key from the API Keys page.
- Set it as
AI_GATEWAY_API_KEYin your environment. - Full setup is covered in the video generation quickstart.
Top-level Parameters
Load the supported top-level parameters: prompt, aspectRatio, duration, resolution, and generateAudio.
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt |
string |
No | Text description of the video to generate. |
duration |
`4 | 6 | 8` |
resolution |
string |
No | Resolution ('1280x720', '1920x1080', '3840x2160'). |
aspectRatio |
string |
No | Aspect ratio ('16:9', '9:16'). |
generateAudio |
boolean |
No | Generate synchronized audio with the video. |
Input Limits
| Input | Formats | Sources | Max Count | Max Size |
|---|---|---|---|---|
| Image | jpg, jpeg, png | url, base64 | 3 | 20 MB |
| Video | mp4 | url | 1 | — |
Image to Video
Animate a starting image by passing prompt as an object with image and an optional text field.
import { experimental_generateVideo as generateVideo } from 'ai';
async function main() {
const result = await generateVideo({
model: 'google/veo-3.1-generate-001',
prompt: {
image: 'https://example.com/landscape.png',
text: 'Camera slowly pans across the scene as clouds drift by',
},
duration: 8,
resolution: '1080p',
generateAudio: true,
});
// Save the generated video
fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');
}
main().catch(console.error);
Frequently Asked Questions
- What improved in the Veo 3.1 generation over Veo 3.0?
The 3.1 generation delivers improvements in motion physics accuracy, frame-to-frame object coherence, and audio-visual synchronization precision. - Does Veo 3.1 support image-to-video?
Yes, provide a reference image alongside a text description to animate it. - What audio generation capabilities does Veo 3.1 include?
The model generates ambient environment audio, sound effects, and dialogue synchronized to visual events from text prompt descriptions. - How do I use Veo 3.1 on AI Gateway?
Use the identifiergoogle/veo-3.1-generate-001with the generateVideo interface in the AI SDK.