Veo-3.1-fast-generate-preview: 400 Bad Request

, ,

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`);

I have notified the team about this. We are looking into it

I have been facing a similar issue for the last 3 hours.

:movie_camera: VIDEO: Polling for completion…
geminiService.ts?t=1771043164084:359 :movie_camera: VIDEO: Poll #1
geminiService.ts?t=1771043164084:359 :movie_camera: VIDEO: Poll #2
geminiService.ts?t=1771043164084:359 :movie_camera: VIDEO: Poll #3
geminiService.ts?t=1771043164084:359 :movie_camera: VIDEO: Poll #4
geminiService.ts?t=1771043164084:359 :movie_camera: VIDEO: Poll #5
geminiService.ts?t=1771043164084:369 :movie_camera: VIDEO RESPONSE: :white_check_mark: Got video URI {videoUri: ‘https://generativelanguage.googleapis.com/v1beta/files/6zs4a45selk8:download?alt=media’, pollCount: 5}
geminiService.ts?t=1771043164084:371 :movie_camera: VIDEO: Downloading from URI… {videoUri: ‘https://generativelanguage.googleapis.com/v1beta/files/6zs4a45selk8:download?alt=media’}
geminiService.ts?t=1771043164084:372 GET 400 (Bad Request)
(anonymous) @ geminiService.ts?t=1771043164084:372
withRetry @ geminiService.ts?t=1771043164084:15
generateVideoAsset @ geminiService.ts?t=1771043164084:372
await in generateVideoAsset
runPipeline @ App.tsx:370
await in runPipeline
executeDispatch @ react-dom_client.js?v=81091858:13622
runWithFiberInDEV @ react-dom_client.js?v=81091858:997
processDispatchQueue @ react-dom_client.js?v=81091858:13658
(anonymous) @ react-dom_client.js?v=81091858:14071
batchedUpdates$1 @ react-dom_client.js?v=81091858:2626
dispatchEventForPluginEventSystem @ react-dom_client.js?v=81091858:13763
dispatchEvent @ react-dom_client.js?v=81091858:16784
dispatchDiscreteEvent @ react-dom_client.js?v=81091858:16765Understand this error
geminiService.ts?t=1771043164084:384 :movie_camera: VIDEO DOWNLOAD FAILED:

It appears to be working now. Will I still get billed for all the generated videos I couldn’t download?