GPT-Live 1.1 现已在 AI Gateway 上线
来自 OpenAI 的 GPT-Live 1.1 现已在 AI Gateway 上线。
GPT-Live 1.1 是一款全双工语音模型,因此它边听边说,通话者可以在回复过程中暂停、打断或补充细节。与上一代 GPT-Live 模型相比,它转写语音更准确,并在不同语言之间保持更一致的口音和音色。它使用相同的 Live 端点和客户端委派,因此现有的 GPT-Live 集成只需更换新的模型 ID。
复制链接到标题简单示例(不使用委派)
单独运行 openai/gpt-live-1.1:
import { createOpenAI } from '@ai-sdk/openai';
const live = createOpenAI({ apiKey: process.env.AI_GATEWAY_API_KEY, baseURL: 'https://ai-gateway.vercel.sh/v1',}).experimental_realtime('openai/gpt-live-1.1', { api: 'live' });
const { url, headers } = await live.getServerWebSocketConfig();
send(live.serializeClientEvent({ type: 'session-start', config: { instructions: 'You are a helpful voice assistant.' },}));
复制链接到标题委派任务并保持对话
开启客户端委派,并使用会话指令告诉 GPT-Live 1.1 何时请求帮助。它通过发送 delegation-created 来请求帮助。用 AI Gateway 上的任意文本模型作答,并将结果返回到 commentary 通道,供 GPT-Live 朗读。此示例使用 openai/gpt-6.2-sol,并基于上面的会话构建:
send(live.serializeClientEvent({ type: 'session-start', config: { instructions: 'Ask the application for help with order questions.', providerOptions: { openai: { delegation: { type: 'client' } } }, },}));
async function handleDelegation({ delegationId }) { const { text } = await generateText({ model: 'openai/gpt-6.2-sol', // Any text model prompt: conversationContext, });
send(live.serializeClientEvent({ type: 'context-append', delegationId, content: text, providerOptions: { openai: { channel: 'commentary' } }, }));}
你的应用控制委派的工作及其权限、确认和取消。委派的模型请求通过 AI Gateway 单独计费,语音会话用量在这些请求运行期间会继续计费。这些代码片段省略了 WebSocket 连接、事件解析、转写内容组装、音频流传输和关闭流程。有关连接设置、音频流传输和完整示例,请参阅 GPT-Live 指南。
在模型 playground 中试用 GPT-Live 1.1。
AI Gateway 提供统一 API,用于调用模型、跟踪用量和成本,并配置重试、故障转移和性能优化,以实现高于模型提供商的正常运行时间。它包括内置的自定义报告、Zero Data Retention 支持、API 密钥预算、路由规则等。
AI Gateway 按提供商定价计费,不加价,且不对推理收取平台费,包括 Bring Your Own Key (BYOK) 请求。
你可以查看 AI Gateway 上所有可用的模型。