Skip to content

Any generation request with video_metadata results in a 500 error #854

Closed as not planned

Description

@kfajdsl

Environment details

  • Programming language: Python (also tested with REST API)
  • OS: macOS
  • Language runtime version: 3.12.9
  • Package version: 1.16.1

Steps to reproduce

  1. Run the following script:
from google import genai
from google.genai import types
from pathlib import Path
import os

client = genai.Client(api_key=os.environ['GEMINI_API_KEY'])

video_path = Path("vid.mp4")
video_bytes = video_path.read_bytes()

response = client.models.generate_content(
    model='models/gemini-2.5-flash-preview-05-20',
    contents=types.Content(
        parts=[
            types.Part(
                inline_data=types.Blob(
                    data=video_bytes,
                    mime_type='video/mp4',
                ),
                video_metadata=types.VideoMetadata(
                    fps=5
                )
            ),
            types.Part(text='Please summarize the video in 3 sentences.')
        ]
    )
)

This also happens with start_offset and end_offset.

Also, note, the docs page seems wrong. It has the following:

            types.Part(
                inline_data=types.Blob(
                    data=video_bytes,
                    mime_type='video/mp4',
                    video_metadata=types.VideoMetadata(fps=5)
            )),

This fails with a Pydantic error when run, and according to the API reference and other examples, video_metadata is a member of Part, not Blob.

Activity

  1. added
    type: bug
    priority: p2
    on May 23, 2025
  2. Madhuvod commented on May 26, 2025

    @Madhuvod

    i think this is a sdk issue no. i have been getting the same errror - 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': '* GenerateContentRequest.contents[1].parts: contents.parts must not be empty.\n', 'status': 'INVALID_ARGUMENT'}}
    MOS Log: Error type: ClientError ; for the code: gemini_api_response = gemini_client.models.generate_content( model=GEMINI_MODEL_NAME, contents=[ AUDIO_ONLY_SYSTEM_PROMPT, types.Part.from_bytes(data=audio_data, mime_type=mime_type) ], config={ "response_mime_type": "application/json", "response_schema": GeminiMOSResponse, } ) ; but the same thing works for google-genai 1.15.0

  3. kfajdsl commented on May 26, 2025

    @kfajdsl
    Author

    @Madhuvod I believe my particular issue is an api issue since I have the same issue when calling the REST API directly rather than using the Python SDK.

  4. Jumaron commented on May 27, 2025

    @Jumaron

    Same Issue, looks like an API Issue.

  5. kiransair commented on May 27, 2025

    @kiransair

    Hi @kfajdsl, Thanks for reporting this issue. While trying to reproduce the error it seems the issue is with gemini-2.5-flash-preview-05-20 but works fine with gemini-2.0-flash. Will bring this issue to the engineering team's attention. Please refer to this gist. Thank You

  6. hkt74 commented on May 28, 2025

    @hkt74
    Contributor

    Hi @kfajdsl

    Your code snippet works for me with model models/gemini-2.5-flash-preview-05-20, (and I agree the docs page is incorrect)

    I tried with this sample video

    Perhaps the issue might be with the video processing itself? Have you had a chance to try it with a different video?

  7. Jumaron commented on May 28, 2025

    @Jumaron

    Hi @kfajdsl

    Your code snippet works for me with model models/gemini-2.5-flash-preview-05-20, (and I agree the docs page is incorrect)

    I tried with this sample video

    Perhaps the issue might be with the video processing itself? Have you had a chance to try it with a different video?

    Super confusing, the video works for me with gemini-2.5-flash-preview-05-20 and flash 2.0.
    But my own video gives the 500 internal error, flash 2.0 works.

  8. Jumaron commented on May 28, 2025

    @Jumaron

    I might have found the issue,
    it seems like the new API only accepts videos with an valid audiotrack, atleast adding an audiotrack to my video solved it for me.
    Having no audio track will result in that error.

  9. Etragas commented on Jun 12, 2025

    @Etragas

    Wow thank you @Jumaron I added empty audio to my video and it worked!

  10. janasangeetha commented on Jul 18, 2025

    @janasangeetha

    Hi @kfajdsl
    Looks like the issue is resolved! Please let us know if you are still facing issue.
    Thank you!

  11. khayyamkhan commented on Jul 19, 2025

    @khayyamkhan

    I have a bit of a dilemna:

    Current setup (Vertex AI SDK):

    • Using vertexai.generative_models.GenerativeModel
    • Limited to 1fps video analysis (no VideoMetadata fps parameter support)
    • Works fine for basic analysis but lacks timing precision

    Desired setup (Google GenAI SDK):

    • Using google.generativeai library with API keys
    • Has VideoMetadata class with fps parameter for 24fps analysis
    • Would give me much better timing precision for shot detection

    The problem is IP protection. I work with unreleased content from major studios (think pre-release studio work etc.) and need to ensure maximum data protection.

    My understanding was that:

    • Vertex AI = enterprise-grade, content not used for training, better IP protection
    • GenAI SDK with API keys = less secure, potentially used for training?

    But I'm honestly not sure if this is accurate or just assumptions I've picked up. The documentation isn't super clear on the security differences between these two approaches.

    Specific questions:

    1. Are there actual security/IP protection differences between the Vertex AI SDK and GenAI SDK?
    2. Does vertexai.generative_models support VideoMetadata fps feature in a way that I'm missing?

    The VideoMetadata fps feature would be incredibly valuable for my work, but I can't risk client IP. If both libraries offer the same enterprise protections, I'd love to switch. If not, I'll stick with Vertex AI.

    Any clarity you can provide would be hugely appreciated!

  12. github-actions commented on Aug 2, 2025

    @github-actions

    This issue has been marked as stale because it has been open for 7 days with no activity. It will be closed in 2 days if no further activity occurs.

  13. github-actions commented on Aug 4, 2025

    @github-actions

    This issue was closed because it has been inactive for 9 days. Please post a new issue if you need further assistance. Thanks!

  14. aleksac99 commented on Aug 18, 2025

    @aleksac99

    might have found the issue,
    it seems like the new API only accepts videos with an valid audiotrack, atleast adding an audiotrack to my video solved it for > me.
    Having no audio track will result in that error.

    Hello everyone,

    I'm facing the same issue when trying to upload a video with no audio track:

    [INFO] google.genai.errors.ServerError: 500 INTERNAL. {'error': {'code': 500, 'message': 'An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting', 'status': 'INTERNAL'}}
    

    Can you please look into this? Thank you!

  15. Districtfine commented on Aug 18, 2025

    @Districtfine

    I did some experimentation and have seen the inverse scenario as well. When a .mp4 file is sent in with an empty video track (ie. an audio-only .mp4) the API will also return a 500:

    google.genai.errors.ServerError: 500 INTERNAL. {'error': {'code': 500, 'message': 'Failed to convert server response to JSON', 'status': 'INTERNAL'}}

  16. janasangeetha commented on Aug 20, 2025

    @janasangeetha

    Hey Users,
    Below are my observations:
    Below code works fine for "video with audio" and "video without audio"

    video_file_name = "<video-file>.mp4"
    video_bytes = open(video_file_name, 'rb').read()
    
    response = client.models.generate_content(
        model='models/gemini-2.5-flash',
        contents=types.Content(
            parts=[
                types.Part(
                    inline_data=types.Blob(
                        data=video_bytes,
                        mime_type='video/mp4'),
                    video_metadata=types.VideoMetadata(fps=5)
                ),
                types.Part(text='Please summarize the video in 3 sentences.')
            ]
        )
    )
    
    print(response.text)
    

    If you are using mp4 without video and only audio then update mime_type='audio/mp4

  17. github-actions commented on Aug 28, 2025

    @github-actions

    This issue has been marked as stale because it has been open for 7 days with no activity. It will be closed in 2 days if no further activity occurs.

  18. github-actions commented on Aug 31, 2025

    @github-actions

    This issue was closed because it has been inactive for 9 days. Please post a new issue if you need further assistance. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: gemini-apipriority: p2status:awaiting user responsestatus:staletype: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions