AI Gateway でリアルタイム音声エージェントを構築可能に
Vercel は AI Gateway にリアルタイム音声機能を追加し、OpenAI と xAI のモデルを用いて、従来のテキスト処理と同じインターフェースで低遅延の双方向音声エージェント構築を可能にした。
キーポイント
マルチモーダル統合による開発効率化
音声機能を AI Gateway に統合し、テキストや画像と同様の API キャンセルでリアルタイム音声処理が可能になったため、複雑なパイプライン構築が不要となる。
サーバーサイドでのターン検出と中断機能
クライアント側のサイレンスタイマーに依存せず、サーバー側による VAD(音声活動検知)で自然な会話の切り替えや、ユーザーによる会話の割り込み(バーギン)を可能にする。
ツール呼び出しの中間実行
応答生成中にツール呼び出しが発生した場合でも会話を終了させずに結果を即座に反映し、より人間らしい対話フローを実現する。
音声と文字の補完的関係
音声生成モデルと文字起こしモデルは互いに補完し合うため、一方で生成した音声を他方で読み返すことで、オーディオパイプラインの両端を迅速に検証できます。
コード不要での試行可能
Playground を利用すれば、ブラウザ上で直接リアルタイムモデルと会話したり、テキストや音声を入力して結果を確認したりするテストが可能です。
影響分析・編集コメントを表示
影響分析
この発表は、音声 AI アプリケーション開発における技術的障壁(複雑なパイプライン構築や遅延問題)を大幅に低下させ、開発者が従来のテキスト処理と同じ感覚で高品質なリアルタイム音声エージェントを構築できる環境を提供します。特に、サーバーサイドでの制御とセキュリティ強化により、実運用レベルの製品開発が加速することが期待されます。
編集コメント
Vercel が提供する AI Gateway の機能拡張により、音声処理のインフラ構築コストが劇的に下がるため、今後はより多くの企業がリアルタイム音声インターフェースを標準搭載するようになるでしょう。
AI Gateway は now、オーディオ/音声に対応しました。テキスト、画像、動画に対して既に使用している呼び出しと同じ呼び出しを通じて、リアルタイム音声、テキストから音声への変換(Text to Speech)、音声からテキストへの変換(Speech to Text)を追加できます。これらは AI Gateway を経由して他のすべてのモダリティと共にルーティングされます。
オーディオ機能は、OpenAI と xAI のモデルでローンチされました。各呼び出しには、他のモデルに対して既に使用しているプロバイダーのルーティング、観測性(Observability)、支出管理、および BYOK(Bring Your Own Key)サポートが同じように適用されます。
これらの機能はベータ版であり、AI SDK 7 で利用可能です。
Capability
How it works
Use it for
Realtime voice
Live audio in and out, for streaming, low-latency session
Two-way voice agents and live conversation
Text to speech
Text in, audio file out, single request
Voiceovers, spoken responses, audio versions of written content
Speech to text
Recorded audio in, text out, single request
Transcribing voice notes, call recordings
Getting started
リアルタイム、音声、および通訳モデルは AI SDK 7 でサポートされています。
Realtime voice agents
リアルタイム機能により、アプリをユーザーが会話できるものに変換します。ユーザーが発話すると、モデルは即座に反応します。完全なターンを待つのではなくその場で応答するため、ユーザーは人間と話すように割り込んで話したり、重ねて話したりすることができます。これは音声アシスタント、カスタマーサポートエージェント、ハンズフリーツール、およびユーザーがタイピングするよりも通話したいあらゆる場所に適しています。
モデルを連鎖させることとの決定的な違いは、単一のリアルタイムモデルが音声を直接聴き取り、音声として直接出力する点にあります。これは、音声認識→言語モデル→音声合成というパイプラインを実行する従来のアプローチとは異なります。
ブラウザ内では、useRealtimeフックが WebSocket 接続、マイクキャプチャ、および音声再生を管理します。
この接続は AI Gateway の認証情報によって認証されるため、サーバー側で短寿命のトークンを発行し、ブラウザにはそのトークンだけを渡す必要があります。API キーがクライアントに到達することはありません。トークンを発行するルートを追加してください:
次に、クライアントコンポーネントから接続します:
このフックはマイクをキャプチャし、AI Gateway を介して音声をモデルにストリーミングし、発話された応答を再生します。ブラウザ外では、getWebSocketConfig、serializeClientEvent、parseServerEvent を使用して WebSocket 経由でセッションを直接制御できます。そのためのパスについてはリアルタイムリファレンスをご覧ください。
リアルタイムセッション内での動作
リアルタイムセッションは、通常のモデル呼び出しとは異なる仕組みで動作します:
ターン交代と割り込み。turnDetection: { type: 'server-vad' } を設定すると、サーバーがユーザーの発話終了を判断し、ユーザーがモデルの応答中に発言して応答を途中で打ち切る(バージイン)ことが可能になります。クライアント側のサイレンスタイマーは不要です。
会話中のツール呼び出し。モデルが応答の途中にツール呼び出しを発行した場合、それを実行して結果をクライアントイベントとして返すと、ターンを終了させることなく、次の発言内容にその回答を組み込んで継続します。
テキストから音声へ
generateSpeech を使用してテキストから音声オーディオを生成します。ボイスと出力形式を指定し、結果をファイルに書き出してください。
音声からテキストへ(文字起こし)
transcribe を使用して録音をテキストに変換します。オーディオはバッファ、base64 文字列、または URL のいずれかになります。
音声生成と文字起こしは補完関係にあるため、組み合わせて利用できます。あるモデルでオーディオを生成し、別のモデルで再生することで、オーディオパイプラインの両端を素早く確認することが可能です。
プレイグラウンド
コードを書かずにオーディオモデルを試すこともできます。models ページを開き、特定のモデルをクリックしてブラウザ内で直接操作してください。リアルタイムモデルと対話して音声会話を行ったり、テキストまたはオーディオを音声生成モデルや文字起こしモデルに送信したりして、結果を読み取ったり再生したりできます。
AI Gateway を通じたオーディオのルーティング
オーディオ呼び出しは、AI Gateway 上の他のすべてのモデル呼び出しと同様に動作します。プロバイダー間で 1 つの API キーを使用し、観測機能でリクエストと使用状況を確認し、同じ予算や支出制限を適用し、必要に応じて独自のプロバイダーキーを持ち込むことができます。テキスト・画像・ビデオのためにすでに AI Gateway を利用しているアプリに音声機能を追加する場合も、すべて同じ場所で完結できるようになりました。
詳細情報
リアルタイムクイックスタート
音声クイックスタート(テキストから音声へ、および音声からテキストへ)
リアルタイムリファレンス
すべてのオーディオモデルを見る
続きを読む
原文を表示
AI Gateway now supports audio/voice. You can add realtime voice, text to speech, and speech to text with the same calls you already use for text, image, and video, routed through AI Gateway alongside every other modality.
Audio launches with models from OpenAI and xAI. Each call gets the same provider routing, observability, spend controls, and bring-your-own-key support you already use for your other models.
These capabilities are in beta and available in AI SDK 7.
Capability
How it works
Use it for
Realtime voice
Live audio in and out, for streaming, low-latency session
Two-way voice agents and live conversation
Text to speech
Text in, audio file out, single request
Voiceovers, spoken responses, audio versions of written content
Speech to text
Recorded audio in, text out, single request
Transcribing voice notes, call recordings
Getting started
Realtime, speech, and transcription model are supported on AI SDK 7.
Realtime voice agents
Realtime turns your app into something a user can hold a conversation with. When they speak, the model responds right away. Because it replies in the moment instead of waiting for a full turn, users can interrupt and talk over it the way they would with a person. It fits voice assistants, customer support agents, hands-free tools, and anywhere a user would rather talk than type.
What sets it apart from chaining models together is that a single realtime model hears audio and produces audio directly, instead of running a speech-to-text, then language model, then text-to-speech pipeline.
In the browser, the useRealtime hook manages the WebSocket connection, microphone capture, and audio playback.
The connection is authenticated with your AI Gateway credential, so you mint a short-lived token on the server and hand the browser only that token. Your API key never reaches the client. Add a route that mints the token:
Then connect from a client component:
The hook captures the microphone, streams the audio to the model through AI Gateway, and plays back the spoken reply. Outside the browser, you can drive the session over a WebSocket yourself with getWebSocketConfig, serializeClientEvent, and parseServerEvent. See the realtime reference for that path.
Inside a realtime session
A realtime session works differently from a normal model call:
Turn-taking and interruptions. turnDetection: { type: 'server-vad' } lets the server decide when the user has stopped speaking, and lets the user talk over the model to cut a reply short (barge-in), with no client-side silence timers.
Tools mid-conversation. The model emits a tool call mid-reply, you run it and return the result as a client event, and it folds the answer into what it says next without ending the turn.
Text to speech
Generate spoken audio from text with generateSpeech. Pass a voice and an output format, then write the result to a file:
Speech to text (transcription)
Transcribe recordings into text with transcribe. The audio can be a buffer, a base64 string, or a URL:
Speech and transcription are complementary, so they compose. You can generate audio with one model and read it back with the other, which is a quick way to check both ends of an audio pipeline.
Playground
You can also try audio models without writing any code. Open the models page, click into a model, and interact with it right in the browser. Talk to a realtime model to hold a voice conversation, or send text or audio to a speech or transcription model and read or play back the result.
Routing audio through AI Gateway
Audio calls behave like every other model call on AI Gateway. You use one API key across providers, see requests and usage in observability, apply the same budgets and spend limits, and bring your own provider keys when you need to. Adding speech to an app that already uses AI Gateway for text/images/videos can now all be done in the same place.
More information
Realtime quickstart
Speech quickstart (text to speech and speech to text)
Realtime reference
See all audio models
Read more
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み