gemini-live-api-dev: Gemini Live API Real-Time Streaming Development Guide

Introduction

Building low-latency voice conversations from microphone to speaker, streaming camera footage while audio plays, or migrating legacy Live models to Gemini 3.8 usually means wrestling with multiple documents on WebSocket protocols, audio formats, VAD, and session recovery at the same time. Below we introduce the gemini-live-api-dev Skill from Google Gemini’s official repository: it consolidates the essential patterns of the Live API—from connection setup, streaming, packet reception to session and authentication—into a single Agent Skill tailored for Python google-genai and JavaScript/TypeScript @google/genai.

What Is This

gemini-live-api-dev is a development-oriented Skill under google-gemini/gemini-skills. Its official description states that it should be used when building real-time bidirectional streaming applications with the Gemini Live API, or when migrating from legacy Live models (2.0 / 2.5 / 3.1) to Gemini 3.8 Live.

The connection method is WebSocket (the documentation notes that if WebRTC or a simpler integration is required, partner solutions can be used). The Skill covers capabilities such as WebSocket-based audio/video/text streaming, Voice Activity Detection (VAD), background reasoning (extended thinking), asynchronous function calling, session management, ephemeral tokens, real-time transcription, and real-time translation.

Core Features

The following capabilities are drawn from the official SKILL documentation, grouped by topic.

Real-time Interaction & Multimodality

  • Bidirectional audio streaming: Real-time conversations from microphone input to the model’s spoken output.
  • Video streaming: Send camera or screen frames alongside audio within a session.
  • Text input/output: Send and receive text within a Live session.
  • Real-time streaming transcription: Speech-to-text, including interim and finalized streams.
  • Audio transcription: Separate text transcriptions can be obtained for input and output audio.

Reasoning, Tools, & Sessions

  • Background reasoning (extended thinking): Multi-step background reasoning, with optional conversational fillers.
  • Asynchronous function calling: Tool execution does not block; audio can continue to stream.
  • Session-wide client content: Inject or update conversation turns during streaming (Gemini 3.8 supports send_client_content / sendClientContent, requiring an explicit user or model role; turn_complete=true unconditionally interrupts the current generation).
  • Session management: Context compaction, session resumption, GoAway signals, etc.
  • Ephemeral tokens: A client-facing secure authentication mechanism that avoids long-lived API key exposure in the browser.

Voice Activity Detection (VAD)

  • Server-side automatic VAD, client-side Hybrid VAD, and manual Push-to-Talk.
Model Summary
gemini-3.8-live Default choice for most low-latency voice agents and real-time conversations; supports interleaved reasoning, default asynchronous function calling (behavior: NON_BLOCKING), and session-wide client content updates.
gemini-3.8-live-extended-thinking For real-time audio scenarios requiring stronger background reasoning; requires behavior: NON_BLOCKING, with lifecycle managed via interaction_status (IN_PROGRESS / IDLE).
gemini-3.5-transcribe-live Real-time streaming STT, including interim and finalized transcription, smart formatting, and Hybrid VAD.
gemini-3.5-live-translate-preview Real-time speech-to-speech translation for 70+ languages.

Legacy models (e.g. gemini-3.1-flash-live-preview, gemini-2.5-flash-native-audio-*, etc.) should refer to references/migration.md inside the Skill, focusing on protocol changes such as behavior: "NON_BLOCKING", thinking_level, interaction_status, send_client_content, and more.

SDKs & Audio Formats

  • Python: google-genai >= 2.3.0, install with: pip install -U google-genai
  • JavaScript/TypeScript: @google/genai >= 2.3.0, install with: npm install @google/genai

Do not use the deprecated google-generativeai (Python) or @google/generative-ai (JS).

Audio conventions (official Quick Start):

  • Input: Raw PCM, little-endian, 16-bit, mono; native 16 kHz (other sample rates will be resampled); MIME: audio/pcm;rate=16000
  • Output: Raw PCM, little-endian, 16-bit, mono; 24 kHz

Real-time user input (audio, video, text) should all go through send_realtime_input / sendRealtimeInput; do not use the media key inside sendRealtimeInput, use audio, video, or text instead.

Partner Integrations (Optional)

The official documentation lists solutions for simplified integration via WebRTC or WebSocket, such as LiveKit, Pipecat, Fishjam, Vision Agents, Voximplant, Firebase AI SDK, and others; corresponding documentation links are provided in the Skill body.

Installation & Activation

In environments that support Agent Skills, you can install using the command documented at officialskills.sh:

npx skills add https://github.com/google-gemini/gemini-skills --skill gemini-live-api-dev

You can also pass the Skill directory link to a coding assistant for installation:

https://github.com/google-gemini/gemini-skills/tree/main/skills/gemini-live-api-dev

After installation, reference this Skill when working on tasks related to “building Live API real-time applications” or “migrating legacy Live models”. The assistant will answer following the patterns in SKILL.md and the references. Support for npx skills add in Cursor, Codex CLI, Claude Code, etc. is subject to each tool’s current documentation; differences not separately documented in official materials are not covered here.

Typical Usage

The snippets below come from the official Quick Start, showing the minimal connection and streaming path; complete error handling, VAD, and asynchronous tool configuration are documented in the Skill repository.

Authentication

Python:

from google import genai

client = genai.Client(api_key="YOUR_API_KEY")

JavaScript:

import { GoogleGenAI } from '@google/genai';

const ai = new GoogleGenAI({ apiKey: 'YOUR_API_KEY' });

Connecting to a Live Session

Python (async context manager):

from google.genai import types

config = types.LiveConnectConfig(
    response_modalities=[types.Modality.AUDIO],
    system_instruction=types.Content(
        parts=[types.Part(text="You are a helpful assistant.")]
    )
)

async with client.aio.live.connect(model="gemini-3.8-live", config=config) as session:
    pass  # Session is active

JavaScript (callbacks):

const session = await ai.live.connect({
  model: 'gemini-3.8-live',
  config: {
    responseModalities: ['audio'],
    systemInstruction: { parts: [{ text: 'You are a helpful assistant.' }] }
  },
  callbacks: {
    onopen: () => console.log('Connected'),
    onmessage: (response) => console.log('Message:', response),
    onerror: (error) => console.error('Error:', error),
    onclose: () => console.log('Closed')
  }
});

Sending Text & Audio

Text (Python):

await session.send_realtime_input(text="Hello, how are you?")

Audio chunks (Python, PCM 16 kHz):

await session.send_realtime_input(
    audio=types.Blob(data=chunk, mime_type="audio/pcm;rate=16000")
)

Video frames (Python, JPEG):

await session.send_realtime_input(
    video=types.Blob(data=frame, mime_type="image/jpeg")
)

Receiving Responses

The official guidance emphasizes: a single server event may contain multiple types of content parts (e.g. audio chunks and transcription). Handle all parts in each event to avoid missing content.

Python receive loop example:

async for response in session.receive():
    content = response.server_content
    if content:
        if content.model_turn:
            for part in content.model_turn.parts:
                if part.inline_data:
                    audio_data = part.inline_data.data
        if content.input_transcription:
            print(f"User: {content.input_transcription.text}")
        if content.output_transcription:
            print(f"Gemini: {content.output_transcription.text}")

Use Cases & Notes

Who It’s For

  • Building real-time voice assistants: microphone input, instant spoken replies from the model.
  • Multimodal Live conversations: sending audio streams together with camera or screen frames in the same session.
  • Requiring session recovery to continue context after connection resets.
  • Browser deployment: using ephemeral tokens to reduce API key exposure.
  • Configuring VAD to handle user interruptions during model speech.

Limitations & Caveats

  • Live API direct connections use WebSocket; WebRTC or managed integrations require partner solutions or Firebase, etc.
  • When migrating from 2.0 / 2.5 / 3.1 Live, always check the Skill’s migration guide to avoid mismatches between legacy fields and the new NON_BLOCKING, state machine, etc.
  • SDK versions must satisfy >= 2.3.0, and deprecated package names should not be mixed in.

Conclusion

gemini-live-api-dev organizes the entire WebSocket streaming pipeline of Gemini Live API—model selection, PCM formats, streaming APIs, response parsing, VAD, sessions, and ephemeral tokens—into a Skill that can be invoked by coding assistants, making it a fitting reference manual for real-time voice and multimodal Agent development in 2026. Official repository:

https://github.com/google-gemini/gemini-skills/tree/main/skills/gemini-live-api-dev

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye