Getting Youtube video summary via Gemini AI API

I would like to use the Gemini AI API to get a summary of a Youtube video. How can I change this prompt to the right format? Placing the youtube URL in the text prompt causes the summarization of a different video than the URL.

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=API_key" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
  "contents": [{
    "parts":[{"text": "Could you give a summary of this youtube video"}, {"file_data":{"mime_type": "video/youtube", "file_uri": "https://www.youtube.com/watch?v=_fuimO6ErKI"}}]
    }]
   }'

Hi,
You cannot provide YouTube URLs directly, and the specified mime_type value is not correct.

Given the size of a video file kindly have a look how to use the File API in order to upload the video to a temporary location which can be used with the Gemini AI.

See here: استكشاف الإمكانات البصرية باستخدام Gemini API  |  Google AI for Developers

Hi,

The Gemini team(s) are keeping themselves busy.
Direct linking of Youtube videos has been announced.

You’ll add the URL as a fileData part to your request:

Request JSON: 
{
  "model": "models/gemini-2.0-flash-exp",
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Describe this video clip."
        },
        {
          "fileData": {
            "fileUri": "https://www.youtube.com/watch?v=1XALhtem2h0",
            "mimeType": ""
          }
        }
      ]
    }
  ]
}

The mimeType is optional.

Cheers.