Repository Public
1<br />23> [!WARNING]4> **Preview:** The Live API is in preview.56This is a comprehensive guide that covers capabilities and configurations7available with the Live API.8See [Get started with Live API](https://ai.google.dev/gemini-api/docs/live) page for a9overview and sample code for common use cases.1011## Before you begin1213- **Familiarize yourself with core concepts:** If you haven't already done so, read the [Get started with Live API](https://ai.google.dev/gemini-api/docs/live) page first. This will introduce you to the fundamental principles of the Live API, how it works, and the different [implementation approaches](https://ai.google.dev/gemini-api/docs/live#implementation-approach).14- **Try the Live API in AI Studio:** You may find it useful to try the Live API in [Google AI Studio](https://aistudio.google.com/app/live) before you start building. To use the Live API in Google AI Studio, select **Stream**.1516## Establishing a connection1718The following example shows how to create a connection with an API key:1920### Python2122 import asyncio23 from google import genai2425 client = genai.Client()2627 model = "gemini-2.5-flash-native-audio-preview-12-2025"28 config = {"response_modalities": ["AUDIO"]}2930 async def main():31 async with client.aio.live.connect(model=model, config=config) as session:32 print("Session started")33 # Send content...3435 if __name__ == "__main__":36 asyncio.run(main())3738### JavaScript3940 import { GoogleGenAI, Modality } from '@google/genai';4142 const ai = new GoogleGenAI({});43 const model = 'gemini-2.5-flash-native-audio-preview-12-2025';44 const config = { responseModalities: [Modality.AUDIO] };4546 async function main() {4748 const session = await ai.live.connect({49 model: model,50 callbacks: {51 onopen: function () {52 console.debug('Opened');53 },54 onmessage: function (message) {55 console.debug(message);56 },57 onerror: function (e) {58 console.debug('Error:', e.message);59 },60 onclose: function (e) {61 console.debug('Close:', e.reason);62 },63 },64 config: config,65 });6667 console.debug("Session started");68 // Send content...6970 session.close();71 }7273 main();7475## Interaction modalities7677The following sections provide examples and supporting context for the different78input and output modalities available in Live API.7980### Sending and receiving audio8182The most common audio example, **audio-to-audio** , is covered in the83[Getting started](https://ai.google.dev/gemini-api/docs/live#audio-to-audio) guide.8485### Audio formats8687Audio data in the Live API is always raw, little-endian,8816-bit PCM. Audio output always uses a sample rate of 24kHz. Input audio89is natively 16kHz, but the Live API will resample if needed90so any sample rate can be sent. To convey the sample rate of input audio, set91the MIME type of each audio-containing [Blob](https://ai.google.dev/api/caching#Blob) to a value92like `audio/pcm;rate=16000`.9394### Sending text9596Here's how you can send text:9798### Python99100 message = "Hello, how are you?"101 await session.send_client_content(turns=message, turn_complete=True)102103### JavaScript104105 const message = 'Hello, how are you?';106 session.sendClientContent({ turns: message, turnComplete: true });107108#### Incremental content updates109110Use incremental updates to send text input, establish session context, or111restore session context. For short contexts you can send turn-by-turn112interactions to represent the exact sequence of events:113114### Python115116 turns = [117 {"role": "user", "parts": [{"text": "What is the capital of France?"}]},118 {"role": "model", "parts": [{"text": "Paris"}]},119 ]120121 await session.send_client_content(turns=turns, turn_complete=False)122123 turns = [{"role": "user", "parts": [{"text": "What is the capital of Germany?"}]}]124125 await session.send_client_content(turns=turns, turn_complete=True)126127### JavaScript128129 let inputTurns = [130 { "role": "user", "parts": [{ "text": "What is the capital of France?" }] },131 { "role": "model", "parts": [{ "text": "Paris" }] },132 ]133134 session.sendClientContent({ turns: inputTurns, turnComplete: false })135136 inputTurns = [{ "role": "user", "parts": [{ "text": "What is the capital of Germany?" }] }]137138 session.sendClientContent({ turns: inputTurns, turnComplete: true })139140For longer contexts it's recommended to provide a single message summary to free141up the context window for subsequent interactions. See [Session Resumption](https://ai.google.dev/gemini-api/docs/live-session#session-resumption) for another method for142loading session context.143144### Audio transcriptions145146In addition to the model response, you can also receive transcriptions of147both the audio output and the audio input.148149To enable transcription of the model's audio output, send150`output_audio_transcription` in the setup config. The transcription language is151inferred from the model's response.152153### Python154155 import asyncio156 from google import genai157 from google.genai import types158159 client = genai.Client()160 model = "gemini-2.5-flash-native-audio-preview-12-2025"161162 config = {163 "response_modalities": ["AUDIO"],164 "output_audio_transcription": {}165 }166167 async def main():168 async with client.aio.live.connect(model=model, config=config) as session:169 message = "Hello? Gemini are you there?"170171 await session.send_client_content(172 turns={"role": "user", "parts": [{"text": message}]}, turn_complete=True173 )174175 async for response in session.receive():176 if response.server_content.model_turn:177 print("Model turn:", response.server_content.model_turn)178 if response.server_content.output_transcription:179 print("Transcript:", response.server_content.output_transcription.text)180181 if __name__ == "__main__":182 asyncio.run(main())183184### JavaScript185186 import { GoogleGenAI, Modality } from '@google/genai';187188 const ai = new GoogleGenAI({});189 const model = 'gemini-2.5-flash-native-audio-preview-12-2025';190191 const config = {192 responseModalities: [Modality.AUDIO],193 outputAudioTranscription: {}194 };195196 async function live() {197 const responseQueue = [];198199 async function waitMessage() {200 let done = false;201 let message = undefined;202 while (!done) {203 message = responseQueue.shift();204 if (message) {205 done = true;206 } else {207 await new Promise((resolve) => setTimeout(resolve, 100));208 }209 }210 return message;211 }212213 async function handleTurn() {214 const turns = [];215 let done = false;216 while (!done) {217 const message = await waitMessage();218 turns.push(message);219 if (message.serverContent && message.serverContent.turnComplete) {220 done = true;221 }222 }223 return turns;224 }225226 const session = await ai.live.connect({227 model: model,228 callbacks: {229 onopen: function () {230 console.debug('Opened');231 },232 onmessage: function (message) {233 responseQueue.push(message);234 },235 onerror: function (e) {236 console.debug('Error:', e.message);237 },238 onclose: function (e) {239 console.debug('Close:', e.reason);240 },241 },242 config: config,243 });244245 const inputTurns = 'Hello how are you?';246 session.sendClientContent({ turns: inputTurns });247248 const turns = await handleTurn();249250 for (const turn of turns) {251 if (turn.serverContent && turn.serverContent.outputTranscription) {252 console.debug('Received output transcription: %s\n', turn.serverContent.outputTranscription.text);253 }254 }255256 session.close();257 }258259 async function main() {260 await live().catch((e) => console.error('got error', e));261 }262263 main();264265To enable transcription of the model's audio input, send266`input_audio_transcription` in setup config.267268### Python269270 import asyncio271 from pathlib import Path272 from google import genai273 from google.genai import types274275 client = genai.Client()276 model = "gemini-2.5-flash-native-audio-preview-12-2025"277278 config = {279 "response_modalities": ["AUDIO"],280 "input_audio_transcription": {},281 }282283 async def main():284 async with client.aio.live.connect(model=model, config=config) as session:285 audio_data = Path("16000.pcm").read_bytes()286287 await session.send_realtime_input(288 audio=types.Blob(data=audio_data, mime_type='audio/pcm;rate=16000')289 )290291 async for msg in session.receive():292 if msg.server_content.input_transcription:293 print('Transcript:', msg.server_content.input_transcription.text)294295 if __name__ == "__main__":296 asyncio.run(main())297298### JavaScript299300 import { GoogleGenAI, Modality } from '@google/genai';301 import * as fs from "node:fs";302 import pkg from 'wavefile';303 const { WaveFile } = pkg;304305 const ai = new GoogleGenAI({});306 const model = 'gemini-2.5-flash-native-audio-preview-12-2025';307308 const config = {309 responseModalities: [Modality.AUDIO],310 inputAudioTranscription: {}311 };312313 async function live() {314 const responseQueue = [];315316 async function waitMessage() {317 let done = false;318 let message = undefined;319 while (!done) {320 message = responseQueue.shift();321 if (message) {322 done = true;323 } else {324 await new Promise((resolve) => setTimeout(resolve, 100));325 }326 }327 return message;328 }329330 async function handleTurn() {331 const turns = [];332 let done = false;333 while (!done) {334 const message = await waitMessage();335 turns.push(message);336 if (message.serverContent && message.serverContent.turnComplete) {337 done = true;338 }339 }340 return turns;341 }342343 const session = await ai.live.connect({344 model: model,345 callbacks: {346 onopen: function () {347 console.debug('Opened');348 },349 onmessage: function (message) {350 responseQueue.push(message);351 },352 onerror: function (e) {353 console.debug('Error:', e.message);354 },355 onclose: function (e) {356 console.debug('Close:', e.reason);357 },358 },359 config: config,360 });361362 // Send Audio Chunk363 const fileBuffer = fs.readFileSync("16000.wav");364365 // Ensure audio conforms to API requirements (16-bit PCM, 16kHz, mono)366 const wav = new WaveFile();367 wav.fromBuffer(fileBuffer);368 wav.toSampleRate(16000);369 wav.toBitDepth("16");370 const base64Audio = wav.toBase64();371372 // If already in correct format, you can use this:373 // const fileBuffer = fs.readFileSync("sample.pcm");374 // const base64Audio = Buffer.from(fileBuffer).toString('base64');375376 session.sendRealtimeInput(377 {378 audio: {379 data: base64Audio,380 mimeType: "audio/pcm;rate=16000"381 }382 }383 );384385 const turns = await handleTurn();386 for (const turn of turns) {387 if (turn.text) {388 console.debug('Received text: %s\n', turn.text);389 }390 else if (turn.data) {391 console.debug('Received inline data: %s\n', turn.data);392 }393 else if (turn.serverContent && turn.serverContent.inputTranscription) {394 console.debug('Received input transcription: %s\n', turn.serverContent.inputTranscription.text);395 }396 }397398 session.close();399 }400401 async function main() {402 await live().catch((e) => console.error('got error', e));403 }404405 main();406407### Stream audio and video408409> [!NOTE]410> To see an example of how to use411> the Live API in a streaming audio and video format,412> run the "Live API - Get Started" file in the cookbooks repository:413>414>415> [View416> on Colab](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Get_started_LiveAPI.py)417418### Change voice and language419420[Native audio output](https://ai.google.dev/gemini-api/docs/live-guide#native-audio-output) models support any of the voices421available for our [Text-to-Speech (TTS)](https://ai.google.dev/gemini-api/docs/speech-generation#voices)422models. You can listen to all the voices in [AI Studio](https://aistudio.google.com/app/live).423424To specify a voice, set the voice name within the `speechConfig` object as part425of the session configuration:426427### Python428429 config = {430 "response_modalities": ["AUDIO"],431 "speech_config": {432 "voice_config": {"prebuilt_voice_config": {"voice_name": "Kore"}}433 },434 }435436### JavaScript437438 const config = {439 responseModalities: [Modality.AUDIO],440 speechConfig: { voiceConfig: { prebuiltVoiceConfig: { voiceName: "Kore" } } }441 };442443> [!NOTE]444> **Note:** If you're using the `generateContent` API, the set of available voices is slightly different. See the [audio generation guide](https://ai.google.dev/gemini-api/docs/audio-generation#voices) for `generateContent` audio generation voices.445446The Live API supports [multiple languages](https://ai.google.dev/gemini-api/docs/live-guide#supported-languages).447[Native audio output](https://ai.google.dev/gemini-api/docs/live-guide#native-audio-output) models automatically choose448the appropriate language and don't support explicitly setting the language449code.450451## Native audio capabilities452453Our latest models feature [native audio output](https://ai.google.dev/gemini-api/docs/models/gemini-2.5-flash-native-audio-preview-12-2025),454which provides natural, realistic-sounding speech and improved multilingual455performance. Native audio also enables advanced features like [affective456(emotion-aware) dialogue](https://ai.google.dev/gemini-api/docs/live-guide#affective-dialog), [proactive audio](https://ai.google.dev/gemini-api/docs/live-guide#proactive-audio)457(where the model intelligently decides when to respond to input),458and ["thinking"](https://ai.google.dev/gemini-api/docs/live-guide#native-audio-output-thinking).459460### Affective dialog461462This feature lets Gemini adapt its response style to the input expression and463tone.464465To use affective dialog, set the api version to `v1alpha` and set466`enable_affective_dialog` to `true`in the setup message:467468### Python469470 client = genai.Client(http_options={"api_version": "v1alpha"})471472 config = types.LiveConnectConfig(473 response_modalities=["AUDIO"],474 enable_affective_dialog=True475 )476477### JavaScript478479 const ai = new GoogleGenAI({ httpOptions: {"apiVersion": "v1alpha"} });480481 const config = {482 responseModalities: [Modality.AUDIO],483 enableAffectiveDialog: true484 };485486### Proactive audio487488When this feature is enabled, Gemini can proactively decide not to respond489if the content is not relevant.490491To use it, set the api version to `v1alpha` and configure the `proactivity`492field in the setup message and set `proactive_audio` to `true`:493494### Python495496 client = genai.Client(http_options={"api_version": "v1alpha"})497498 config = types.LiveConnectConfig(499 response_modalities=["AUDIO"],500 proactivity={'proactive_audio': True}501 )502503### JavaScript504505 const ai = new GoogleGenAI({ httpOptions: {"apiVersion": "v1alpha"} });506507 const config = {508 responseModalities: [Modality.AUDIO],509 proactivity: { proactiveAudio: true }510 }511512### Thinking513514The latest native audio output model `gemini-2.5-flash-native-audio-preview-12-2025`515supports [thinking capabilities](https://ai.google.dev/gemini-api/docs/thinking), with dynamic516thinking enabled by default.517518The `thinkingBudget` parameter guides the model on the number of thinking tokens519to use when generating a response. You can disable thinking by setting520`thinkingBudget` to `0`. For more info on the `thinkingBudget` configuration521details of the model, see the [thinking budgets documentation](https://ai.google.dev/gemini-api/docs/thinking#set-budget).522523### Python524525 model = "gemini-2.5-flash-native-audio-preview-12-2025"526527 config = types.LiveConnectConfig(528 response_modalities=["AUDIO"]529 thinking_config=types.ThinkingConfig(530 thinking_budget=1024,531 )532 )533534 async with client.aio.live.connect(model=model, config=config) as session:535 # Send audio input and receive audio536537### JavaScript538539 const model = 'gemini-2.5-flash-native-audio-preview-12-2025';540 const config = {541 responseModalities: [Modality.AUDIO],542 thinkingConfig: {543 thinkingBudget: 1024,544 },545 };546547 async function main() {548549 const session = await ai.live.connect({550 model: model,551 config: config,552 callbacks: ...,553 });554555 // Send audio input and receive audio556557 session.close();558 }559560 main();561562Additionally, you can enable thought summaries by setting `includeThoughts` to563`true` in your configuration. See [thought summaries](https://ai.google.dev/gemini-api/docs/thinking#summaries)564for more info:565566### Python567568 model = "gemini-2.5-flash-native-audio-preview-12-2025"569570 config = types.LiveConnectConfig(571 response_modalities=["AUDIO"]572 thinking_config=types.ThinkingConfig(573 thinking_budget=1024,574 include_thoughts=True575 )576 )577578### JavaScript579580 const model = 'gemini-2.5-flash-native-audio-preview-12-2025';581 const config = {582 responseModalities: [Modality.AUDIO],583 thinkingConfig: {584 thinkingBudget: 1024,585 includeThoughts: true,586 },587 };588589## Voice Activity Detection (VAD)590591Voice Activity Detection (VAD) allows the model to recognize when a person is592speaking. This is essential for creating natural conversations, as it allows a593user to interrupt the model at any time.594595When VAD detects an interruption, the ongoing generation is canceled and596discarded. Only the information already sent to the client is retained in the597session history. The server then sends a [`BidiGenerateContentServerContent`](https://ai.google.dev/api/live#bidigeneratecontentservercontent) message to report the interruption.598599The Gemini server then discards any pending function calls and sends a600`BidiGenerateContentServerContent` message with the IDs of the canceled calls.601602### Python603604 async for response in session.receive():605 if response.server_content.interrupted is True:606 # The generation was interrupted607608 # If realtime playback is implemented in your application,609 # you should stop playing audio and clear queued playback here.610611### JavaScript612613 const turns = await handleTurn();614615 for (const turn of turns) {616 if (turn.serverContent && turn.serverContent.interrupted) {617 // The generation was interrupted618619 // If realtime playback is implemented in your application,620 // you should stop playing audio and clear queued playback here.621 }622 }623624### Automatic VAD625626By default, the model automatically performs VAD on627a continuous audio input stream. VAD can be configured with the628[`realtimeInputConfig.automaticActivityDetection`](https://ai.google.dev/api/live#RealtimeInputConfig.AutomaticActivityDetection)629field of the [setup configuration](https://ai.google.dev/api/live#BidiGenerateContentSetup).630631When the audio stream is paused for more than a second (for example,632because the user switched off the microphone), an633[`audioStreamEnd`](https://ai.google.dev/api/live#BidiGenerateContentRealtimeInput.FIELDS.bool.BidiGenerateContentRealtimeInput.audio_stream_end)634event should be sent to flush any cached audio. The client can resume sending635audio data at any time.636637### Python638639 # example audio file to try:640 # URL = "https://storage.googleapis.com/generativeai-downloads/data/hello_are_you_there.pcm"641 # !wget -q $URL -O sample.pcm642 import asyncio643 from pathlib import Path644 from google import genai645 from google.genai import types646647 client = genai.Client()648 model = "gemini-live-2.5-flash-preview"649650 config = {"response_modalities": ["TEXT"]}651652 async def main():653 async with client.aio.live.connect(model=model, config=config) as session:654 audio_bytes = Path("sample.pcm").read_bytes()655656 await session.send_realtime_input(657 audio=types.Blob(data=audio_bytes, mime_type="audio/pcm;rate=16000")658 )659660 # if stream gets paused, send:661 # await session.send_realtime_input(audio_stream_end=True)662663 async for response in session.receive():664 if response.text is not None:665 print(response.text)666667 if __name__ == "__main__":668 asyncio.run(main())669670### JavaScript671672 // example audio file to try:673 // URL = "https://storage.googleapis.com/generativeai-downloads/data/hello_are_you_there.pcm"674 // !wget -q $URL -O sample.pcm675 import { GoogleGenAI, Modality } from '@google/genai';676 import * as fs from "node:fs";677678 const ai = new GoogleGenAI({});679 const model = 'gemini-live-2.5-flash-preview';680 const config = { responseModalities: [Modality.TEXT] };681682 async function live() {683 const responseQueue = [];684685 async function waitMessage() {686 let done = false;687 let message = undefined;688 while (!done) {689 message = responseQueue.shift();690 if (message) {691 done = true;692 } else {693 await new Promise((resolve) => setTimeout(resolve, 100));694 }695 }696 return message;697 }698699 async function handleTurn() {700 const turns = [];701 let done = false;702 while (!done) {703 const message = await waitMessage();704 turns.push(message);705 if (message.serverContent && message.serverContent.turnComplete) {706 done = true;707 }708 }709 return turns;710 }711712 const session = await ai.live.connect({713 model: model,714 callbacks: {715 onopen: function () {716 console.debug('Opened');717 },718 onmessage: function (message) {719 responseQueue.push(message);720 },721 onerror: function (e) {722 console.debug('Error:', e.message);723 },724 onclose: function (e) {725 console.debug('Close:', e.reason);726 },727 },728 config: config,729 });730731 // Send Audio Chunk732 const fileBuffer = fs.readFileSync("sample.pcm");733 const base64Audio = Buffer.from(fileBuffer).toString('base64');734735 session.sendRealtimeInput(736 {737 audio: {738 data: base64Audio,739 mimeType: "audio/pcm;rate=16000"740 }741 }742743 );744745 // if stream gets paused, send:746 // session.sendRealtimeInput({ audioStreamEnd: true })747748 const turns = await handleTurn();749 for (const turn of turns) {750 if (turn.text) {751 console.debug('Received text: %s\n', turn.text);752 }753 else if (turn.data) {754 console.debug('Received inline data: %s\n', turn.data);755 }756 }757758 session.close();759 }760761 async function main() {762 await live().catch((e) => console.error('got error', e));763 }764765 main();766767With `send_realtime_input`, the API will respond to audio automatically based768on VAD. While `send_client_content` adds messages to the model context in769order, `send_realtime_input` is optimized for responsiveness at the expense of770deterministic ordering.771772### Automatic VAD configuration773774For more control over the VAD activity, you can configure the following775parameters. See [API reference](https://ai.google.dev/api/live#automaticactivitydetection) for more776info.777778### Python779780 from google.genai import types781782 config = {783 "response_modalities": ["TEXT"],784 "realtime_input_config": {785 "automatic_activity_detection": {786 "disabled": False, # default787 "start_of_speech_sensitivity": types.StartSensitivity.START_SENSITIVITY_LOW,788 "end_of_speech_sensitivity": types.EndSensitivity.END_SENSITIVITY_LOW,789 "prefix_padding_ms": 20,790 "silence_duration_ms": 100,791 }792 }793 }794795### JavaScript796797 import { GoogleGenAI, Modality, StartSensitivity, EndSensitivity } from '@google/genai';798799 const config = {800 responseModalities: [Modality.TEXT],801 realtimeInputConfig: {802 automaticActivityDetection: {803 disabled: false, // default804 startOfSpeechSensitivity: StartSensitivity.START_SENSITIVITY_LOW,805 endOfSpeechSensitivity: EndSensitivity.END_SENSITIVITY_LOW,806 prefixPaddingMs: 20,807 silenceDurationMs: 100,808 }809 }810 };811812### Disable automatic VAD813814Alternatively, the automatic VAD can be disabled by setting815`realtimeInputConfig.automaticActivityDetection.disabled` to `true` in the setup816message. In this configuration the client is responsible for detecting user817speech and sending818[`activityStart`](https://ai.google.dev/api/live#BidiGenerateContentRealtimeInput.FIELDS.BidiGenerateContentRealtimeInput.ActivityStart.BidiGenerateContentRealtimeInput.activity_start)819and [`activityEnd`](https://ai.google.dev/api/live#BidiGenerateContentRealtimeInput.FIELDS.BidiGenerateContentRealtimeInput.ActivityEnd.BidiGenerateContentRealtimeInput.activity_end)820messages at the appropriate times. An `audioStreamEnd` isn't sent in821this configuration. Instead, any interruption of the stream is marked by822an `activityEnd` message.823824### Python825826 config = {827 "response_modalities": ["TEXT"],828 "realtime_input_config": {"automatic_activity_detection": {"disabled": True}},829 }830831 async with client.aio.live.connect(model=model, config=config) as session:832 # ...833 await session.send_realtime_input(activity_start=types.ActivityStart())834 await session.send_realtime_input(835 audio=types.Blob(data=audio_bytes, mime_type="audio/pcm;rate=16000")836 )837 await session.send_realtime_input(activity_end=types.ActivityEnd())838 # ...839840### JavaScript841842 const config = {843 responseModalities: [Modality.TEXT],844 realtimeInputConfig: {845 automaticActivityDetection: {846 disabled: true,847 }848 }849 };850851 session.sendRealtimeInput({ activityStart: {} })852853 session.sendRealtimeInput(854 {855 audio: {856 data: base64Audio,857 mimeType: "audio/pcm;rate=16000"858 }859 }860861 );862863 session.sendRealtimeInput({ activityEnd: {} })864865## Token count866867You can find the total number of consumed tokens in the868[usageMetadata](https://ai.google.dev/api/live#usagemetadata) field of the returned server message.869870### Python871872 async for message in session.receive():873 # The server will periodically send messages that include UsageMetadata.874 if message.usage_metadata:875 usage = message.usage_metadata876 print(877 f"Used {usage.total_token_count} tokens in total. Response token breakdown:"878 )879 for detail in usage.response_tokens_details:880 match detail:881 case types.ModalityTokenCount(modality=modality, token_count=count):882 print(f"{modality}: {count}")883884### JavaScript885886 const turns = await handleTurn();887888 for (const turn of turns) {889 if (turn.usageMetadata) {890 console.debug('Used %s tokens in total. Response token breakdown:\n', turn.usageMetadata.totalTokenCount);891892 for (const detail of turn.usageMetadata.responseTokensDetails) {893 console.debug('%s\n', detail);894 }895 }896 }897898## Media resolution899900You can specify the media resolution for the input media by setting the901`mediaResolution` field as part of the session configuration:902903### Python904905 from google.genai import types906907 config = {908 "response_modalities": ["AUDIO"],909 "media_resolution": types.MediaResolution.MEDIA_RESOLUTION_LOW,910 }911912### JavaScript913914 import { GoogleGenAI, Modality, MediaResolution } from '@google/genai';915916 const config = {917 responseModalities: [Modality.TEXT],918 mediaResolution: MediaResolution.MEDIA_RESOLUTION_LOW,919 };920921## Limitations922923Consider the following limitations of the Live API924when you plan your project.925926### Response modalities927928You can only set one response modality (`TEXT` or `AUDIO`) per session in the929session configuration. Setting both results in a config error message. This930means that you can configure the model to respond with either text or audio,931but not both in the same session.932933### Client authentication934935The Live API only provides server-to-server authentication936by default. If you're implementing your Live API application937using a [client-to-server approach](https://ai.google.dev/gemini-api/docs/live#implementation-approach), you need to use938[ephemeral tokens](https://ai.google.dev/gemini-api/docs/ephemeral-tokens) to mitigate security939risks.940941### Session duration942943Audio-only sessions are limited to 15 minutes,944and audio plus video sessions are limited to 2 minutes.945However, you can configure different [session management techniques](https://ai.google.dev/gemini-api/docs/live-session) for unlimited extensions on session duration.946947### Context window948949A session has a context window limit of:950951- 128k tokens for [native audio output](https://ai.google.dev/gemini-api/docs/live-guide#native-audio-output) models952- 32k tokens for other Live API models953954## Supported languages955956Live API supports the following 70 languages.957958> [!NOTE]959> **Note:** [Native audio output](https://ai.google.dev/gemini-api/docs/live-guide#native-audio-output) models can switch between languages naturally during conversation. You can also restrict the languages it speaks in by specifying it in the system instructions.960961| Language | BCP-47 Code | Language | BCP-47 Code |962|---|---|---|---|963| Afrikaans | `af` | Kannada | `kn` |964| Albanian | `sq` | Kazakh | `kk` |965| Amharic | `am` | Khmer | `km` |966| Arabic | `ar` | Korean | `ko` |967| Armenian | `hy` | Lao | `lo` |968| Assamese | `as` | Latvian | `lv` |969| Azerbaijani | `az` | Lithuanian | `lt` |970| Basque | `eu` | Macedonian | `mk` |971| Belarusian | `be` | Malay | `ms` |972| Bengali | `bn` | Malayalam | `ml` |973| Bosnian | `bs` | Marathi | `mr` |974| Bulgarian | `bg` | Mongolian | `mn` |975| Catalan | `ca` | Nepali | `ne` |976| Chinese | `zh` | Norwegian | `no` |977| Croatian | `hr` | Odia | `or` |978| Czech | `cs` | Polish | `pl` |979| Danish | `da` | Portuguese | `pt` |980| Dutch | `nl` | Punjabi | `pa` |981| English | `en` | Romanian | `ro` |982| Estonian | `et` | Russian | `ru` |983| Filipino | `fil` | Serbian | `sr` |984| Finnish | `fi` | Slovak | `sk` |985| French | `fr` | Slovenian | `sl` |986| Galician | `gl` | Spanish | `es` |987| Georgian | `ka` | Swahili | `sw` |988| German | `de` | Swedish | `sv` |989| Greek | `el` | Tamil | `ta` |990| Gujarati | `gu` | Telugu | `te` |991| Hebrew | `iw` | Thai | `th` |992| Hindi | `hi` | Turkish | `tr` |993| Hungarian | `hu` | Ukrainian | `uk` |994| Icelandic | `is` | Urdu | `ur` |995| Indonesian | `id` | Uzbek | `uz` |996| Italian | `it` | Vietnamese | `vi` |997| Japanese | `ja` | Zulu | `zu` |998999## What's next10001001- Read the [Tool Use](https://ai.google.dev/gemini-api/docs/live-tools) and [Session Management](https://ai.google.dev/gemini-api/docs/live-session) guides for essential information on using the Live API effectively.1002- Try the Live API in [Google AI Studio](https://aistudio.google.com/app/live).1003- For more info about the Live API models, see [Gemini 2.5 Flash Native Audio](https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-live) on the Models page.1004- Try more examples in the [Live API cookbook](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/Get_started_LiveAPI.ipynb), the [Live API Tools cookbook](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/Get_started_LiveAPI_tools.ipynb), and the [Live API Get Started script](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Get_started_LiveAPI.py).