APIMaster.ai

Gemini 3.8 Live — 即時語音

即時語音對話、官方價格與接入狀態

Gemini 3.8 Live

截至 2026-11-12,APIMaster 尚未開放此模型的即時會話服務。目前上游 WebSocket 握手回傳 403,原生 Live 轉發與計費也尚未完成驗收。價格已登記不代表服務可用。

用途

支援文字、音訊、圖片與影片輸入,以及文字和音訊輸出。適用於語音客服、口語練習及具有視覺情境的即時助理。持續對話使用 Live;配音和逐字朗讀使用 TTS。

官方價格

下表為 2026-11-12 核查的 Google Standard 官方基準價,不代表 APIMaster 在售價格。

模態 美元 / 百萬 tokens
文字輸入 $0.75
文字輸出(含思考) $4.50
音訊輸入 $3.00
音訊輸出 $12.00
圖片 / 影片輸入 $1.00

Google 直接連線參考範例

此範例直接連線 Google,需要具備 Live 權限的 Google API Key,而非 APIMaster Key;不代表 APIMaster 已開放 Live 端點。

安裝 SDK,於伺服器環境變數設定 GEMINI_API_KEY 後執行;簡短語音回覆會儲存為 reply.wav。

python -m pip install google-genai
python gemini_live_reference.py
import asyncio
import os
import wave
from google import genai

async def main():
    client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
    async with client.aio.live.connect(
        model="gemini-3.8-live",
        config={"response_modalities": ["AUDIO"]},
    ) as session:
        await session.send_client_content(
            turns={"role": "user", "parts": [{"text": "Say hello briefly."}]},
            turn_complete=True,
        )
        audio = bytearray()
        async for message in session.receive():
            content = message.server_content
            if content and content.model_turn:
                for part in content.model_turn.parts or []:
                    if part.inline_data and part.inline_data.data:
                        audio.extend(part.inline_data.data)
        if not audio:
            raise RuntimeError("The Live session returned no audio")
        with wave.open("reply.wav", "wb") as output:
            output.setnchannels(1)
            output.setsampwidth(2)
            output.setframerate(24000)
            output.writeframes(audio)

asyncio.run(main())

音訊輸入與輸出

麥克風輸入使用 16 kHz、單聲道、16 位元有符號小端 PCM;輸出為 24 kHz PCM。將音訊轉成 Base64 後分塊傳送以下訊息,保留協定欄位名稱。

{"realtimeInput":{"audio":{"mimeType":"audio/pcm;rate=16000","data":"BASE64_PCM16_AUDIO"}}}

會話與疑難排解

使用 Live API WebSocket,等待 setupComplete 後再傳送輸入;turnComplete 表示本輪結束。握手 403 代表連線未建立,不是指紋不符。generateContent 與 Chat Completions 無法取代 Live 雙向會話。正式接入需驗證鑑權、音訊、打斷、工具、重連與按模態計費。金鑰僅存於伺服器,不要放入網頁或公開儲存庫。

來源與核查日期

2026-11-12 · Google: Gemini 3.8 Live · Google: Live API · Google: pricing