This sample shows you how to process images, video, audio, and text at the same time. This sample works with Gemini 1.5 Pro only.

## Code sample

### C#


Before trying this sample, follow the C# setup instructions in the
[Vertex AI quickstart using
client libraries](https://docs.cloud.google.com/vertex-ai/docs/start/client-libraries).


For more information, see the
[Vertex AI C# API
reference documentation](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.AIPlatform.V1/latest).


To authenticate to Vertex AI, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment).


    using https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.AIPlatform.V1/latest/Google.Cloud.AIPlatform.V1.html;
    using System;
    using System.Threading.Tasks;

    public class MultimodalAllInput
    {
        public async Task<string> AnswerFromMultimodalInput(
            string projectId = "your-project-id",
            string location = "us-central1",
            string publisher = "google",
            string model = "gemini-2.0-flash-001")
        {

            var predictionServiceClient = new https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.AIPlatform.V1/latest/Google.Cloud.AIPlatform.V1.PredictionServiceClientBuilder.html
            {
                Endpoint = $"{location}-aiplatform.googleapis.com"
            }.Build();

            string prompt = "Watch each frame in the video carefully and answer the questions.\n"
                      + "Only base your answers strictly on what information is available in "
                      + "the video attached. Do not make up any information that is not part "
                      + "of the video and do not be too verbose, be to the point.\n\n"
                      + "Questions:\n"
                      + "- When is the moment in the image happening in the video? "
                      + "Provide a timestamp.\n"
                      + "- What is the context of the moment and what does the narrator say about it?";

            var generateContentRequest = new https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.AIPlatform.V1/latest/Google.Cloud.AIPlatform.V1.GenerateContentRequest.html
            {
                Model = $"projects/{projectId}/locations/{location}/publishers/{publisher}/models/{model}",
                Contents =
                {
                    new https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.AIPlatform.V1/latest/Google.Cloud.AIPlatform.V1.Content.html
                    {
                        Role = "USER",
                        Parts =
                        {
                            new https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.AIPlatform.V1/latest/Google.Cloud.AIPlatform.V1.Part.html { Text = prompt },
                            new https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.AIPlatform.V1/latest/Google.Cloud.AIPlatform.V1.Part.html { FileData = new() { MimeType = "video/mp4", FileUri = "gs://cloud-samples-data/generative-ai/video/behind_the_scenes_pixel.mp4" } },
                            new https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.AIPlatform.V1/latest/Google.Cloud.AIPlatform.V1.Part.html { FileData = new() { MimeType = "image/png", FileUri = "gs://cloud-samples-data/generative-ai/image/a-man-and-a-dog.png" } }
                        }
                    }
                }
            };

            https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.AIPlatform.V1/latest/Google.Cloud.AIPlatform.V1.GenerateContentResponse.html response = await predictionServiceClient.GenerateContentAsync(generateContentRequest);

            string responseText = response.https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.AIPlatform.V1/latest/Google.Cloud.AIPlatform.V1.GenerateContentResponse.html#Google_Cloud_AIPlatform_V1_GenerateContentResponse_Candidates[0].https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.AIPlatform.V1/latest/Google.Cloud.AIPlatform.V1.Content.html.Parts[0].Text;
            Console.WriteLine(responseText);

            return responseText;
        }
    }

### Node.js


Before trying this sample, follow the Node.js setup instructions in the
[Vertex AI quickstart using
client libraries](https://docs.cloud.google.com/vertex-ai/docs/start/client-libraries).


For more information, see the
[Vertex AI Node.js API
reference documentation](https://docs.cloud.google.com/nodejs/docs/reference/aiplatform/latest).


To authenticate to Vertex AI, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment).

    const {GoogleGenAI} = require('@google/genai');

    /**
     * TODO(developer): Update these variables before running the sample.
     */
    async function analyze_all_modalities(
      projectId = 'PROJECT_ID',
      model = 'gemini-2.5-flash'
    ) {
      const client = new GoogleGenAI({
        vertexai: true,
        project: projectId,
        location: 'us-central1',
      });

      const videoFilePart = {
        fileData: {
          fileUri:
            'gs://cloud-samples-data/generative-ai/video/behind_the_scenes_pixel.mp4',
          mimeType: 'video/mp4',
        },
      };
      const imageFilePart = {
        fileData: {
          fileUri:
            'gs://cloud-samples-data/generative-ai/image/a-man-and-a-dog.png',
          mimeType: 'image/png',
        },
      };

      const textPart = {
        text: `
        Watch each frame in the video carefully and answer the questions.
        Only base your answers strictly on what information is available in the video attached.
        Do not make up any information that is not part of the video and do not be too
        verbose, be to the point.

        Questions:
        - When is the moment in the image happening in the video? Provide a timestamp.
        - What is the context of the moment and what does the narrator say about it?`,
      };

      const response = await client.models.generateContent({
        model: model,
        contents: [videoFilePart, imageFilePart, textPart],
      });

      console.log(response.text);
    }

## What's next


To search and filter code samples for other Google Cloud products, see the
[Google Cloud sample browser](https://docs.cloud.google.com/docs/samples?product=generativeaionvertexai).