VEO 3.1 - Last Frame Parameter Not Supported

Hi everyone,

I just tried the newly released VEO 3.1 model (veo-3.1-generate-preview), specifically using the first & last frame control which is great.

I literally used the code from the documentation, and also tried to copy the code from AI studio demo.

Unfortunately every time, I end up with the following error. Feels like the last frame parameter isn’t actually implemented yet.

Anyone experiencing a similar problem?

Cheers

Traceback (most recent call last):
  File "c:\Users\master_repo\Sandbox\VEO3\veo3.1_twoimages.py", line 18, in <module>
    operation = client.models.generate_videos(
        model="veo-3.1-generate-preview",
    ...<4 lines>...
        ),
    )
  File "C:\Users\master_repo\Sandbox\venv\Lib\site-packages\google\genai\models.py", line 6969, in generate_videos
    return self._generate_videos(
           ~~~~~~~~~~~~~~~~~~~~~^
        model=model,
        ^^^^^^^^^^^^
    ...<4 lines>...
        config=config,
        ^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\master_repo\Sandbox\venv\Lib\site-packages\google\genai\models.py", line 6389, in _generate_videos
    request_dict = _GenerateVideosParameters_to_mldev(
        self._api_client, parameter_model
    )
  File "C:\Users\master_repo\Sandbox\venv\Lib\site-packages\google\genai\models.py", line 1417, in _GenerateVideosParameters_to_mldev
    _GenerateVideosConfig_to_mldev(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        getv(from_object, ['config']), to_object
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ),
    ^
  File "C:\Users\master_repo\Sandbox\venv\Lib\site-packages\google\genai\models.py", line 1363, in _GenerateVideosConfig_to_mldev
    raise ValueError('last_frame parameter is not supported in Gemini API.')
ValueError: last_frame parameter is not supported in Gemini API.
3 Likes

Yes, same here in Javascript. Only works without the lastFrame. Also tried uploading the lastFrame as image first with the files endpoint, but alas….

The documentation explicitly says it only works with the model: ‘veo-3.1-generate-preview’

Have you solved in some way? I have the same error when I use lastFrame parameter.

Hi @Epicflare , Welcome to AI Forum!
We have tried to reproduce the error you reported, but we were unable to do so. It appears to be working as expected on our end.

Could you please share the code snippet so that we can test it again?

I realized the reason was that I was using an lib version that was not updated enough to handle this feature (while everything else was working perfectly while).

Just a simple lib update :wink:

Staying as close to the python example worked for me.

Note:

  • That I am importing genai’s Image (Image_2) which fixed my problem.
  • Make sure you have a lib version that support lastFrame
  • Make sure you have enough credits
  • Make sure the config parameters satisfies the types.GenerateVideosConfig
      import { GoogleGenAI, Image } from '@google/genai';      

      const ai = new GoogleGenAI({ apiKey: this.apiKey });

      const prompt =
        'Panning wide shot of a calico kitten sleeping in the sunshine';
      // read images as Buffers
      const firstImage: Image = {
        mimeType: 'image/png',
        imageBytes: readFileSync('ghost_girl.png').toString('base64'),
      };

      const lastImage: Image = {
        mimeType: 'image/png',
        imageBytes: readFileSync('empty_tree.png').toString('base64'),
      };

      // Step 2: Generate video with Veo 3.1 using the image.
      let operation = await ai.models.generateVideos({
        model: 'veo-3.1-generate-preview',
        prompt: prompt,
        image: firstImage,
        config: {
          lastFrame: lastImage,
        },
      });

      // 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 video.
      ai.files.download({
        file: operation.response.generatedVideos[0].video,
        downloadPath: 'veo3_with_image_input.mp4',
      });
      console.log(`Generated video saved to veo3_with_image_input.mp4`);

This drove me insane. The duration needs to be set to 8 seconds. If you attempt with last_frame when its set to 4 seconds it will return the error below.

both models support first and last frame as long as the duration is 8.
veo-3.1-fast-generate-preview, veo-3.1-generate-preview

400 INVALID_ARGUMENT. {‘error’: {‘code’: 400, ‘message’: ‘Your use case is currently not supported. Please refer to Gemini API documentation for current model offering.’, ‘status’: ‘INVALID_ARGUMENT’}}

1 Like