Gemini 3.8 Live 模型現已可於 AI Gateway 使用
Gemini 3.8 Live models now available on AI Gateway
Gemini 3.8 Live 及 Gemini 3.8 Live Extended Thinking 現已可於 AI Gateway 使用,支援即時語音互動與多模態功能。
Gemini 3.8 Live 及其擴展思考功能可即時語音互動,開發者可透過 AI Gateway 直接使用 WebSocket 進行實時對話,提升語音助手與多模態應用的互動體驗。
Gemini 3.8 Live 與 Gemini 3.8 Live Extended Thinking(Google)現在可於 AI Gateway 使用。
兩款模型皆支援即時語音互動,適用於語音助手、對話式體驗,以及透過音訊回應的應用程式。
google/gemini-3.8-live支援即時音訊、視覺定位、97 種語言的自動切換,以及在對話進行時的背景工具呼叫。google/gemini-3.8-live-extended-thinking加入多步驟推理,可與語音同步執行,允許在不打斷對話的情況下確認請求並說明進度。
可透過 AI SDK 的 realtime API 使用任一模型。安裝 Gateway 提供者與 WebSocket 客戶端:
pnpm add @ai-sdk/gateway@latest ws
產生短期存取權杖,開啟 WebSocket,並使用模型適配器序列化與解析 realtime 事件:
import { gateway } from '@ai-sdk/gateway';
import WebSocket from 'ws';
const modelId = 'google/gemini-3.8-live';
const { token, url } = await gateway.experimental_realtime.getToken({
model: modelId,
});
const model = gateway.experimental_realtime(modelId);
const config = model.getWebSocketConfig({ token, url });
const ws = new WebSocket(config.url, config.protocols);
const send = async (
event: Parameters<typeof model.serializeClientEvent>[0],
) => ws.send(JSON.stringify(await model.serializeClientEvent(event)));
ws.on('open', async () => {
await send({
type: 'session-update',
config: {
outputModalities: ['audio'],
outputAudioTranscription: {},
// Extended Thinking only. Set exactly one of thinkingLevel or thinkingBudget:
// providerOptions: {
// google: { thinkingConfig: { thinkingLevel: 'LOW' } },
// },
},
});
await send({
type: 'conversation-item-create',
item: {
type: 'text-message',
role: 'user',
text: 'Say hello in one sentence.',
},
});
});
ws.on('message', (data) => {
const parsed = model.parseServerEvent(JSON.parse(data.toString()));
for (const event of Array.isArray(parsed) ? parsed : [parsed]) {
if (event.type === 'audio-transcript-delta') {
process.stdout.write(event.delta);
}
if (event.type === 'response-done') {
console.log();
ws.close();
}
if (event.type === 'error') {
console.error(event.message);
ws.close();
}
}
});
ws.on('close', (code, reason) => {
if (code !== 1000) {
console.error(`WebSocket closed (${code}): ${reason.toString()}`);
}
});
請參閱 realtime quickstart 以了解更多關於 realtime 事件與 WebSocket 連線的細節。
在模型測試平台試用 Gemini 3.8 Live 或 Gemini 3.8 Live Extended Thinking。
AI Gateway 提供統一 API,用於呼叫模型、追蹤使用量與成本,以及設定重試、故障轉移與效能優化,以達到高於供應商的正常運作時間。
Source: Vercel Blog · vercel.com