The sample code in the documentation doesn’t allow the generated file to be downloaded: https://ai.google.dev/gemini-api/docs/video?example=dialogue#aspect-ratio
```
$ node generate-veo-video.mjs
Waiting for video generation to complete…
Waiting for video generation to complete…
Waiting for video generation to complete…
Waiting for video generation to complete…
Waiting for video generation to complete…
Waiting for video generation to complete…
Waiting for video generation to complete…
Generated video saved to pizza_making.mp4
file:///media/leon/oldlarge/Downloads/node_modules/@google/genai/dist/node/index.mjs:12202
const apiError = new ApiError({
^
ApiError: {“error”:{“message”:“Bad Request”,“code”:400,“status”:“Bad Request”}}
at throwErrorIfNotOK (file:///media/leon/oldlarge/Downloads/node_modules/@google/genai/dist/node/index.mjs:12202:30)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async file:///media/leon/oldlarge/Downloads/node_modules/@google/genai/dist/node/index.mjs:11905:13
at async downloadFile (file:///media/leon/oldlarge/Downloads/node_modules/@google/genai/dist/node/index.mjs:18178:16)
at async NodeDownloader.download (file:///media/leon/oldlarge/Downloads/node_modules/@google/genai/dist/node/index.mjs:18154:30)
at async ApiClient.downloadFile (file:///media/leon/oldlarge/Downloads/node_modules/@google/genai/dist/node/index.mjs:12150:9)
at async NodeFiles.download (file:///media/leon/oldlarge/Downloads/node_modules/@google/genai/dist/node/index.mjs:6950:9) {
status: 400
}
Node.js v22.13.1
```
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({});
const prompt = `A montage of pizza making: a chef tossing and flattening the floury dough, ladling rich red tomato sauce in a spiral, sprinkling mozzarella cheese and pepperoni, and a final shot of the bubbling golden-brown pizza, upbeat electronic music with a rhythmical beat is playing, high energy professional video.`;
let operation = await ai.models.generateVideos({
model: "veo-3.1-fast-generate-preview",
prompt: prompt,
config: {
aspectRatio: "9:16",
},
});
// Poll the operation status until the video is ready.
while (!operation.done) {
console.log("Waiting for video generation to complete...")
await new Promise((resolve) => setTimeout(resolve, 10000));
operation = await ai.operations.getVideosOperation({
operation: operation,
});
}
// Download the generated video.
ai.files.download({
file: operation.response.generatedVideos[0].video,
downloadPath: "pizza_making.mp4",
});
console.log(`Generated video saved to pizza_making.mp4`);