This guide shows you how to add audio to your requests to Gemini to perform tasks like summarization and transcription by using the Google Cloud console and the Vertex AI API. This page covers the following topics: The following table lists the models that support audio understanding: The quota metric is
To see a list of languages that Gemini models support, see
Google models. To learn
more about how to design multimodal prompts, see
Design multimodal prompts.
If you're looking for a way to use Gemini directly from your mobile and
web apps, see the
Firebase AI Logic client SDKs for
Swift, Android, Web, Flutter, and Unity apps. In the Google Cloud console, you can add an audio file to your prompt from several sources. The following table describes the available options. The following example shows you how to use an audio file to summarize a podcast. In the Vertex AI section of the Google Cloud console, go to
the Vertex AI Studio page. Click Create prompt. Optional: Configure the model and parameters: Optional: To configure advanced parameters, click Advanced and
configure as follows:
Top-K: Use the slider or textbox to enter a value for top-K. For each token selection step, the top-K tokens with the highest
probabilities are sampled. Then tokens are further filtered based on top-P with
the final token selected using temperature sampling. Specify a lower value for less random responses and a higher value for more
random responses. If the model returns a response that's too generic, too short, or the model gives a fallback
response, try increasing the temperature. Specify a lower value for shorter responses and a higher value for potentially longer
responses. Click Insert Media, and select a source for your file. Select the file that you want to upload and click Open. Enter the URL of the file that you want to use and click Insert. Select the bucket and then the file from the bucket that
you want to import and click Select. Click Select. The file thumbnail displays in the Prompt pane. The total
number of tokens also displays. If your prompt data exceeds the
token limit, the
tokens are truncated and aren't included in processing your data. Enter your text prompt in the Prompt pane. Optional: To view the Token ID to text and Token IDs, click the
tokens count in the Prompt pane. Click Submit. Optional: To save your prompt to My prompts, click Optional: To get the Python code or a curl command for your prompt, click
To learn more, see the
SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
Learn how to install or update the Go.
To learn more, see the
SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
After you
set up your environment,
you can use REST to test a text prompt. The following sample sends a request to the publisher
model endpoint.
Before using any of the request data,
make the following replacements:
When specifying a
If you don't have an audio file in Cloud Storage, then you can use the following
publicly available file:
Click to expand MIME types To send your request, choose one of these options:
Save the request body in a file named
Then execute the following command to send your REST request:
Save the request body in a file named
Then execute the following command to send your REST request:
You should receive a JSON response similar to the following.
Supported models
Model
Media details
MIME types
Gemini 2.5 Flash-Lite
audio/x-aac
audio/flac
audio/mp3
audio/m4a
audio/mpeg
audio/mpga
audio/mp4
audio/opus
audio/pcm
audio/wav
audio/webm
Gemini 2.5 Flash with Live API native audio
audio/x-aac
audio/flac
audio/mp3
audio/m4a
audio/mpeg
audio/mpga
audio/mp4
audio/opus
audio/pcm
audio/wav
audio/webm
Gemini 2.0 Flash with Live API
audio/x-aac
audio/flac
audio/mp3
audio/m4a
audio/mpeg
audio/mpga
audio/mp4
audio/opus
audio/pcm
audio/wav
audio/webm
Gemini 2.0 Flash with image generation
audio/x-aac
audio/flac
audio/mp3
audio/m4a
audio/mpeg
audio/mpga
audio/mp4
audio/opus
audio/pcm
audio/wav
audio/webm
Gemini 2.5 Pro
audio/x-aac
audio/flac
audio/mp3
audio/m4a
audio/mpeg
audio/mpga
audio/mp4
audio/opus
audio/pcm
audio/wav
audio/webm
Gemini 2.5 Flash
audio/x-aac
audio/flac
audio/mp3
audio/m4a
audio/mpeg
audio/mpga
audio/mp4
audio/opus
audio/pcm
audio/wav
audio/webm
Gemini 2.0 Flash
audio/x-aac
audio/flac
audio/mp3
audio/m4a
audio/mpeg
audio/mpga
audio/mp4
audio/opus
audio/pcm
audio/wav
audio/webm
Gemini 2.0 Flash-Lite
audio/x-aac
audio/flac
audio/mp3
audio/m4a
audio/mpeg
audio/mpga
audio/mp4
audio/opus
audio/pcm
audio/wav
audio/webm
generate_content_audio_input_per_base_model_id_and_resolution
.Add audio to a request
Method
Description
Use Case
Upload
Upload an audio file directly from your local computer.
Best for quick tests with local files.
By URL
Provide a public URL to an audio file. The model fetches the file from the URL.
Useful when audio is hosted online but not in Cloud Storage.
Cloud Storage
Use an audio file stored in a Cloud Storage bucket.
Recommended for production, larger files, and integrating with other Google Cloud services.
Google Drive
Select an audio file directly from your Google Drive.
Convenient for files already stored in your personal or shared Drive.
Console
To send a multimodal prompt by using the Google Cloud console, do the
following:
Click to expand advanced configurations
1
means the next selected token is the most probable among all
tokens in the model's vocabulary (also called greedy decoding), while a top-K of
3
means that the next token is selected from among the three most
probable tokens by using temperature.
0
.
The temperature is used for sampling during response generation, which occurs when
and topP
topK
are applied. Temperature controls the degree of randomness in token selection.
Lower temperatures are good for prompts that require a less open-ended or creative response, while
higher temperatures can lead to more diverse or creative results. A temperature of 0
means that the highest probability tokens are always selected. In this case, responses for a given
prompt are mostly deterministic, but a small amount of variation is still possible.
Upload
By URL
Cloud Storage
Google Drive
Python
Install
pip install --upgrade google-genai
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_VERTEXAI=True
Go
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_VERTEXAI=True
REST
PROJECT_ID
: Your project ID.FILE_URI
:
The URI or URL of the file to include in the prompt. Acceptable values include the following:
gemini-2.0-flash
and gemini-2.0-flash-lite
, the size limit is 2 GB.fileURI
, you must also specify the media type
(mimeType
) of the file. If VPC Service Controls is enabled, specifying a media file
URL for fileURI
is not supported.gs://cloud-samples-data/generative-ai/audio/pixel.mp3
with a mime type of
audio/mp3
. To listen to this audio,
open the sample MP3
file.
MIME_TYPE
:
The media type of the file specified in the data
or fileUri
fields. Acceptable values include the following:
application/pdf
audio/mpeg
audio/mp3
audio/wav
image/png
image/jpeg
image/webp
text/plain
video/mov
video/mpeg
video/mp4
video/mpg
video/avi
video/wmv
video/mpegps
video/flv
TEXT
Please provide a summary for the audio. Provide chapter titles, be concise and short, no
need to provide chapter summaries. Do not make up any information that is not part of the
audio and do not be verbose.
curl
request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
cat > request.json << 'EOF'
{
"contents": {
"role": "USER",
"parts": [
{
"fileData": {
"fileUri": "FILE_URI",
"mimeType": "MIME_TYPE"
}
},
{
"text": "TEXT"
}
]
}
}
EOF
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/global/publishers/google/models/gemini-2.0-flash:generateContent"PowerShell
request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
@'
{
"contents": {
"role": "USER",
"parts": [
{
"fileData": {
"fileUri": "FILE_URI",
"mimeType": "MIME_TYPE"
}
},
{
"text": "TEXT"
}
]
}
}
'@ | Out-File -FilePath request.json -Encoding utf8
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/global/publishers/google/models/gemini-2.0-flash:generateContent" | Select-Object -Expand Content
generateContent
method to request that the response is returned after it's fully generated.
To reduce the perception of latency to a human audience, stream the response as it's being
generated by using the
streamGenerateContent
method.
gemini-2.0-flash
). This sample might support other
models as well.
Transcribe audio
The following example shows you how to use an audio file to transcribe an interview. To
enable timestamp understanding for audio-only files, enable the audioTimestamp
parameter in GenerationConfig
.
Console
To send a multimodal prompt by using the Google Cloud console, do the following:In the Vertex AI section of the Google Cloud console, go to the Vertex AI Studio page.
Click Create prompt.
Optional: Configure the model and parameters:
- Model: Select a model.
Optional: To configure advanced parameters, click Advanced and configure as follows:
Click to expand advanced configurations
Top-K: Use the slider or textbox to enter a value for top-K.
Top-K changes how the model selects tokens for output. A top-K of1
means the next selected token is the most probable among all tokens in the model's vocabulary (also called greedy decoding), while a top-K of3
means that the next token is selected from among the three most probable tokens by using temperature.For each token selection step, the top-K tokens with the highest probabilities are sampled. Then tokens are further filtered based on top-P with the final token selected using temperature sampling.
Specify a lower value for less random responses and a higher value for more random responses.
- Top-P: Use the slider or textbox to enter a value for top-P.
Tokens are selected from most probable to the least until the sum of their
probabilities equals the value of top-P. For the least variable results,
set top-P to
0
. - Max responses: Use the slider or textbox to enter a value for the number of responses to generate.
- Streaming responses: Enable to print responses as they're generated.
- Safety filter threshold: Select the threshold of how likely you are to see responses that could be harmful.
- Enable Grounding: Grounding isn't supported for multimodal prompts.
- Region: Select the region that you want to use.
- Temperature: Use the slider or textbox to enter a value for
temperature.
The temperature is used for sampling during response generation, which occurs when
andtopP
topK
are applied. Temperature controls the degree of randomness in token selection. Lower temperatures are good for prompts that require a less open-ended or creative response, while higher temperatures can lead to more diverse or creative results. A temperature of0
means that the highest probability tokens are always selected. In this case, responses for a given prompt are mostly deterministic, but a small amount of variation is still possible.If the model returns a response that's too generic, too short, or the model gives a fallback response, try increasing the temperature.
</li> <li>**Output token limit**: Use the slider or textbox to enter a value for the max output limit. Maximum number of tokens that can be generated in the response. A token is approximately four characters. 100 tokens correspond to roughly 60-80 words.Specify a lower value for shorter responses and a higher value for potentially longer responses.
</li> <li>**Add stop sequence**: Optional. Enter a stop sequence, which is a series of characters that includes spaces. If the model encounters a stop sequence, the response generation stops. The stop sequence isn't included in the response, and you can add up to five stop sequences.</li> </ul>
Click Insert Media, and select a source for your file.
Upload
Select the file that you want to upload and click Open.
By URL
Enter the URL of the file that you want to use and click Insert.
Cloud Storage
Select the bucket and then the file from the bucket that you want to import and click Select.
Google Drive
- Choose an account and give consent to Vertex AI Studio to access your account the first time you select this option. You can upload multiple files that have a total size of up to 10 MB. A single file can't exceed 7 MB.
- Click the file that you want to add.
Click Select.
The file thumbnail displays in the Prompt pane. The total number of tokens also displays. If your prompt data exceeds the token limit, the tokens are truncated and aren't included in processing your data.
Enter your text prompt in the Prompt pane.
Optional: To view the Token ID to text and Token IDs, click the tokens count in the Prompt pane.
Click Submit.
Optional: To save your prompt to My prompts, click
Save.Optional: To get the Python code or a curl command for your prompt, click
Build with code > Get code.
Python
Install
pip install --upgrade google-genai
To learn more, see the SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values # with appropriate values for your project. export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT export GOOGLE_CLOUD_LOCATION=global export GOOGLE_GENAI_USE_VERTEXAI=True
Go
Learn how to install or update the Go.
To learn more, see the SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values # with appropriate values for your project. export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT export GOOGLE_CLOUD_LOCATION=global export GOOGLE_GENAI_USE_VERTEXAI=True
REST
After you set up your environment, you can use REST to test a text prompt. The following sample sends a request to the publisher model endpoint.
Before using any of the request data, make the following replacements:
PROJECT_ID
: .FILE_URI
: The URI or URL of the file to include in the prompt. Acceptable values include the following:- Cloud Storage bucket URI: The object must either be publicly readable or reside in
the same Google Cloud project that's sending the request. For
gemini-2.0-flash
andgemini-2.0-flash-lite
, the size limit is 2 GB. - HTTP URL: The file URL must be publicly readable. You can specify one video file, one audio file, and up to 10 image files per request. Audio files, video files, and documents can't exceed 15 MB.
- YouTube video URL:The YouTube video must be either owned by the account that you used to sign in to the Google Cloud console or is public. Only one YouTube video URL is supported per request.
When specifying a
fileURI
, you must also specify the media type (mimeType
) of the file. If VPC Service Controls is enabled, specifying a media file URL forfileURI
is not supported.If you don't have an audio file in Cloud Storage, then you can use the following publicly available file:
gs://cloud-samples-data/generative-ai/audio/pixel.mp3
with a mime type ofaudio/mp3
. To listen to this audio, open the sample MP3 file.- Cloud Storage bucket URI: The object must either be publicly readable or reside in
the same Google Cloud project that's sending the request. For
MIME_TYPE
: The media type of the file specified in thedata
orfileUri
fields. Acceptable values include the following:Click to expand MIME types
application/pdf
audio/mpeg
audio/mp3
audio/wav
image/png
image/jpeg
image/webp
text/plain
video/mov
video/mpeg
video/mp4
video/mpg
video/avi
video/wmv
video/mpegps
video/flv
The text instructions to include in the prompt. For example,TEXT
Can you transcribe this interview, in the format of timecode, speaker, caption. Use speaker A, speaker B, etc. to identify speakers.
To send your request, choose one of these options:
curl
Save the request body in a file named request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
cat > request.json << 'EOF' { "contents": { "role": "USER", "parts": [ { "fileData": { "fileUri": "FILE_URI", "mimeType": "MIME_TYPE" } }, { "text": "TEXT" } ] }, "generatationConfig": { "audioTimestamp": true } } EOF
Then execute the following command to send your REST request:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/global/publishers/google/models/gemini-2.0-flash:generateContent"
PowerShell
Save the request body in a file named request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
@' { "contents": { "role": "USER", "parts": [ { "fileData": { "fileUri": "FILE_URI", "mimeType": "MIME_TYPE" } }, { "text": "TEXT" } ] }, "generatationConfig": { "audioTimestamp": true } } '@ | Out-File -FilePath request.json -Encoding utf8
Then execute the following command to send your REST request:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/global/publishers/google/models/gemini-2.0-flash:generateContent" | Select-Object -Expand Content
You should receive a JSON response similar to the following.
Note the following in the URL for this sample:- Use the
generateContent
method to request that the response is returned after it's fully generated. To reduce the perception of latency to a human audience, stream the response as it's being generated by using thestreamGenerateContent
method. - The multimodal model ID is located at the end of the URL before the method
(for example,
gemini-2.0-flash
). This sample might support other models as well.
Set optional model parameters
Each model has a set of optional parameters that you can set. For more information, see Content generation parameters.
Limitations
While Gemini multimodal models are powerful in many multimodal use cases, it's important to understand the limitations of the models:
- Non-speech sound recognition: The models that support audio might make mistakes recognizing sound that's not speech.
- Audio-only timestamps: To accurately generate
timestamps for audio-only files, you must configure the
audio_timestamp
parameter ingeneration_config
.
What's next
- Explore what you can do with Gemini multimodal models. New customers get $300 in free Google Cloud credits to get started.
- Learn how to send chat prompt requests.
- Learn about responsible AI best practices and Vertex AI's safety filters.