PipecatとAmazon Bedrock AgentCore Runtimeで音声エージェントをデプロイする - 第1部
AWSとPipecatは、Pipecat音声エージェントをAmazon Bedrock AgentCore Runtime上にWebSocket、WebRTC、電話連携などのネットワークトランスポートアプローチでデプロイする方法を実践的なガイダンスとコードサンプルで解説する連載記事の第1部を公開した。
キーポイント
リアルタイム音声エージェントの課題と解決策
自然な会話フローを維持するには低遅延ストリーミング、セキュリティのための厳格な分離、予測不可能な会話量への動的スケーリングが必要であり、不適切なアーキテクチャではオーディオジッター、スケーラビリティ制約、コスト増大などの問題が発生する。
AgentCore Runtimeの利点
Amazon Bedrock AgentCore Runtimeは、安全なサーバーレス環境を提供し、各会話セッションを分離されたmicroVMで実行、トラフィックスパイクへの自動スケーリング、最大8時間の継続セッション処理を可能にし、使用中のリソースのみ課金される。
PipecatとAgentCore Runtimeの統合
Pipecatはリアルタイム音声AIパイプライン構築のためのエージェントフレームワークであり、コンテナとしてパッケージ化してAgentCore Runtimeに直接デプロイでき、双方向ストリーミングと組み込みの可観測性をサポートする。
実践的なデプロイメントガイダンス
本記事ではWebSocket、WebRTC、電話連携などの異なるネットワークトランスポートアプローチを使用してPipecat音声エージェントをAgentCore Runtimeにデプロイする方法を、実践的な展開ガイダンスとコードサンプルで提供している。
影響分析・編集コメントを表示
影響分析
この記事は、リアルタイム音声AIエージェントの実用的なデプロイメントソリューションを提供し、AWSのインフラとPipecatフレームワークの統合による実装ガイドを提示している。これにより、企業が顧客サポートや仮想アシスタントなどの音声エージェントをより効率的に構築・展開できる可能性が高まるが、技術的には既存技術の組み合わせに重点を置いた実装ガイドという性格が強い。
編集コメント
技術的な実装ガイドに特化した記事で、既存技術の組み合わせによる実用的なソリューションを提供しているが、画期的な技術革新というよりは実装ベストプラクティスの共有という性格が強い。連載の第1部という位置付けも考慮する必要がある。
この投稿は、AWS と Pipecat の共同制作です。
自然で人間らしい会話を維持するインテリジェントな音声エージェントをデプロイするには、ユーザーが利用している場所(Web、モバイル、電話チャネルなど)へストリーミング配信を行う必要があります。これは、過大なトラフィックや不安定なネットワーク環境下においても同様です。わずかな遅延でも会話の流れが途切れ、ユーザーにエージェントが反応していない、あるいは信頼できないという印象を与えてしまいます。カスタマーサポート、バーチャルアシスタント、アウトバウンドキャンペーンなどのユースケースでは、自然な流れがユーザーエクスペリエンスにとって極めて重要です。本シリーズの投稿では、Amazon Bedrock AgentCore Runtime 上で Pipecat の音声エージェントを活用し、ストリーミングアーキテクチャがこれらの課題をどのように解決するかについて学びます。
パート1では、WebSocket、WebRTC、および電話回線統合(telephony integration)を含むさまざまなネットワーク転送アプローチを用いて、AgentCore Runtime 上で Pipecat 音声エージェントをデプロイする方法と、実用的なデプロイガイダンス、コードサンプルについて学習します。
Voice エージェントにおける AgentCore Runtime の利点
リアルタイム音声エージェントの展開は困難を伴います。低遅延ストリーミング、セキュリティのための厳格な分離、予測不能な会話量への動的スケーリング能力が必要です。適切に設計されたアーキテクチャがない場合、オーディオジッター(音質の揺らぎ)、スケーラビリティの制約、過剰プロビジョニングによるコスト増大、複雑性の増加といった問題が発生する可能性があります。カスケード型 (STT → LLM → TTS) や音声対音声アプローチを含む音声エージェントアーキテクチャの詳細については、以前の投稿 Amazon Nova Sonic を用いたリアルタイム音声アシスタントの構築とカスケード型アーキテクチャとの比較 をご参照ください。
Amazon Bedrock AgentCore Runtime は、動的な AI エージェントのスケーリングを可能にする安全でサーバーレスな環境を提供することで、これらの課題に対処します。各会話セッションはセキュリティのために分離されたマイクロ VM (microVMs) で実行されます。トラフィックの急増に対して自動スケーリングし、最大 8 時間にわたる継続的なセッションも処理できるため、長時間にわたる多段階の音声対話に最適です。実際に使用されたリソースのみに対して課金されるため、アイドル状態のインフラに関連するコストを最小限に抑えることができます。
Pipecat は、リアルタイム音声 AI パイプラインを構築するためのエージェントフレームワークであり、最小限の設定で AgentCore Runtime 上で動作します。Pipecat の音声パイプラインをコンテナとしてパッケージ化し、AgentCore Runtime に直接デプロイできます。このランタイムは、リアルタイムオーディオのための双方向ストリーミングと、エージェントの推論やツール呼び出しを追跡するための組み込み観測機能(observability)をサポートしています。
AgentCore Runtime では ARM64 (Graviton) 対応のコンテナが必要となるため、Docker イメージが linux/arm64 システム向けにビルドされていることを確認してください。
AgentCore Runtime における音声エージェントのストリーミングアーキテクチャ
本記事では、一般的な音声エージェントのアーキテクチャについてある程度ご存知であることを前提としています。具体的には、音声認識 (STT) と音声合成 (TTS) モデルをパイプラインで接続する カスケード モデルのアプローチや、Amazon Nova Sonic のような 音声から音声へ のモデルアプローチです。これらの概念に初めて触れる場合は、先に当社の基礎的な 2 つのアプローチである カスケード と 音声から音声へ に関する以前のブログ記事をお読みください。
音声エージェントを構築する際、レイテンシは極めて重要な考慮事項であり、これが会話の自然さや信頼性を決定づけます。滑らかで人間らしいリズムを維持するためには、エンドツーエンドで通常 1 秒未満のほぼ即時応答が必要です。

低遅延を実現するには、複数の経路における双方向ストリーミングを考慮する必要があります。具体的には以下の通りです。
- クライアントからエージェントへ:音声エージェントは、Web ブラウザやモバイルアプリ、エッジハードウェアなど、それぞれ固有のネットワーク環境を持つデバイスやアプリケーション上で動作します。
- エージェントからモデルへ:音声エージェントは、音声モデルとの双方向ストリーミングを介して対話を行います。ほとんどの音声モデルはリアルタイム WebSocket API を公開しており、エージェントランタイムやオーケストレーションフレームワークがこれを利用してオーディオ入力やテキスト・音声出力を取得できます。モデルの選択は、自然な応答性を達成する上で重要な役割を果たします。遅延に最適化され、高速な Time-to-First-Token (TTFT) を提供する Amazon Nova Sonic(またはカスケードパイプラインアプローチでは Amazon Nova Lite)などのモデルを選択してください。
- 電話回線:従来のコンタクトセンターや電話システムを介して処理される着信・発信通話の場合、音声エージェントは電話プロバイダーとも連携する必要があります。これは通常、ハンドオフおよび/またはセッション相互接続プロトコル (SIP) 転送を通じて実現され、生オーディオストリームが電話システムからエージェントランタイムへ転送されて処理されます。
本シリーズの第 1 部では、「クライアントからエージェント」への接続に焦点を当て、エッジデバイスから音声エージェントまでの最初のネットワーク経路における遅延を最小化する手法と、音声エージェントアーキテクチャの他のコンポーネントに関連する追加的な考慮事項について探求します。
これらの概念を説明するために、以下の考慮事項を踏まえて 4 つのネットワーク転送アプローチを探求します:
- ユーザーが音声エージェントとどのようにインタフェースするか(Web/モバイルアプリケーションまたは電話通話)
- 変動するネットワーク条件下でのパフォーマンスの一貫性と回復力
- 実装の容易さ
アプローチ
説明
パフォーマンスの一貫性
実装の容易さ
適した用途
WebSockets
Web およびモバイルアプリケーションは、WebSockets を介して音声エージェントに直接接続されます。
良い
シンプル
プロトタイピングおよび軽量なユースケース。
WebRTC (TURN-assisted)
Web およびモバイルアプリケーションは、WebRTC を介して音声エージェントに直接接続されます。
非常に良好
中程度
クライアントが Traversal Using Relays around NAT (TURN) サーバーを介してリレーされるランタイム環境に直接接続することによる遅延を持つ本番環境向けユースケース。
WebRTC (managed)
Web およびモバイルアプリケーションは、WebRTC を通じて、高度でグローバルに分散されたインフラストラクチャを介して音声エージェントに接続されます。
非常に良好(グローバル分散)
シンプル
グローバルに分散したネットワークとメディアリレーを持つ専門プロバイダに遅延最適化をオフロードし、観測可能性や複数参加者通話などの追加機能を提供する本番環境向けユースケース。
電話回線
音声エージェントは、従来の電話通話を通じてアクセスされます。
優秀
中程度
コールセンターおよび電話回線ユースケース。レイテンシは電話プロバイダに依存する可能性があります。
例:WebSockets を用いた双方向ストリーミングアプローチ
最もシンプルなアプローチとして、WebSockets(WebSocket)から始めることができます。これはネイティブでほとんどのクライアントと AgentCore Runtime をサポートしています。永続的で双方向の WebSocket 接続を使用して、クライアントデバイスとエージェントロジック間のオーディオストリーミングを行うことで、Pipecat 音声エージェントを AgentCore Runtime 上でデプロイできます。

接続は、以下の単純な 3 ステップのフローに従います。
- クライアントは WebSocket エンドポイントを要求します:クライアントはまず、安全な WebSocket 接続エンドポイントを取得するために、仲介サーバー(/server)に対して POST リクエストを送信します。
- 仲介サーバーが AWS 認証を処理します:Pipecat の事前構築フロントエンド上の仲介サーバーは、AWS SDK を使用して、埋め込まれた資格情報をクエリパラメータとして含む AWS SigV4 署名付き URL(pre-signed URL)を生成します。例:X?-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=
- クライアントが直接接続を確立します:認証された署名付き URL を使用して、クライアントは AgentCore Runtime 上のエージェントに直接接続し、仲介サーバーを経由せずに双方向オーディオをストリーミングし、以降の通信では仲介サーバーをバイパスします。
AgentCore Runtime の要件に従い、Pipecat の WebSocket トランスポート を使用して /ws パスにエンドポイントを公開します。このアーキテクチャは、クライアントアクセスのセキュリティを確保しつつ AWS 資格情報をブラウザアプリケーションに直接露出させることなく、資格情報の管理とエージェントロジックを分離しています。
詳しくは、WebSocket トランスポートを使用した AgentCore 上の Pipecat の コードサンプル をお試しください。
例のアプローチ:TURN 支援を備えた WebRTC の双方向ストリーミングの使用
WebSocket はシンプルなデプロイメントには適していますが、WebRTC はより優れたパフォーマンスを提供できます。これは遅延を最小限に抑える高速で軽量なネットワーク経路を使用してオーディオを送信するように設計されており、通常は低遅延と滑らかなリアルタイム体験のために UDP を使用します。また、変動するネットワーク条件に対する耐性も向上しています。UDP が利用できない場合、WebRTC は自動的に TCP にフォールバックしますが、これはより信頼性は高いもののわずかな遅延をもたらす可能性があります。音声には理想的ではありませんが、接続が制限されている状況では役立ちます。この信頼性は、NAT やファイアウォールを介して直接のピアツーピア経路を交渉し、直接接続ができない場合に Traversal Using Relays around NAT (TURN) サーバーを介したメディアストリーミングリレーにフォールバックする ICE(Interactive Connectivity Establishment)サーバーによって実現されています。
Pipecat は、AgentCore Runtime 上のクライアントとエージェント間の直接ピアツーピア WebRTC 接続のために SmallWebRTCTransport をサポートしています。専用メディアサーバー(Selective Forwarding Units または SFU など)を必要とする包括的な WebRTC アーキテクチャと比較して、この軽量なトランスポートは AgentCore Runtime 内で直接実行可能であり、複雑なメディアサーバー管理の必要性を排除します。

このシナリオでは、接続フローは以下の通り動作します。
- シグナリング:クライアントはセッション記述プロトコル(SDP)オファーを仲介サーバーに送信し、これは AgentCore Runtime の /invoke/ エンドポイントへ転送されます。@app.entrypoint ハンドラーがオファーを処理し、メディア機能とネットワーク候補を含む SDP アンスワーを返します。
- 接続確立:直接接続を確立するために、クライアントとエージェントの両方がインタラクティブ・コネクティビティ・エスタブリッシュメント(ICE)プロトコルを使用して最適なネットワーク経路を発見します。AgentCore Runtime は NAT の周囲のリレーを使用したトランザバーサル(TURN)リレー接続をサポートしています。このプロトコルは以下の順序で接続を試みます:
直接接続:ローカルネットワークアドレスを使用してピアツーピアで接続します。このパスは、ランタイム環境にパブリック IP アドレスを割り当てることができないため、AgentCore Runtime ではサポートされていません。
- NAT 用セッショントランザバルユーティリティ(STUN)支援接続:NAT を介してパブリック IP/ポートを発見し、直接接続を試みるために STUN サーバーを使用します。このパスには双方向の UDP トラフィックが必要ですが、AWS NAT ゲートウェイが対称型 NAT を使用しているため、現在はこのパスはサポートされておらず、STUN ベースの直接接続は成功しません。
- NAT の周囲のリレーを使用したトランザバーサル(TURN)リレー接続:メディアを TURN リレーサーバー経由でルーティングします。TURN は管理サービス(Cloudflare や Twilio など)、Amazon Kinesis Video Streams (KVS)、または自己ホスト型ソリューション(VPC 内の coturn など)を使用して構成します。このパスは、VPC で構成された AgentCore Runtime 上で推奨されます(詳細は後述)。
- VPC を介した接続:接続が確立されると、トラフィックはクライアントから VPC を経由してランタイム環境へルーティングされます(詳細は次のセクションで説明)。
さらに詳しく知りたい場合は、Pipecat on AgentCore のコードサンプル [WebRTC トランスポートを使用] (https://github.com/pipecat-ai/pipecat-examples/tree/main/deployment/aws-agentcore-webrtc) をお試しください。
VPC 上の AgentCore Runtime の WebRTC 接続用設定
コードサンプル は、WebRTC を使用したシンプルな音声エージェントを示しています。まず、Pipecat の事前構築フロントエンドの仲介サーバー(/server)とランタイム環境(/agent)の両方で、ICE_SERVER_URLS 環境変数を設定します。これにより、両者間の双方向通信が可能になります。
次に、UDP トランスポートを TURN サーバーへ転送できるようにするために、VPC ネットワーク構成が設定された AgentCore Runtime にエージェントを展開します。セキュリティのため、ランタイムはプライベート VPC サブネットに公開し、インターネットアクセスをルーティングするための NAT Gateway をパブリックサブネットに配置します。これは以下の図の通りです。

このアプローチにより、STUN と UDP を使用し、TCP フォールバックも備えた完全な WebRTC 接続用の ICE サーバーを設定できます。例えば、Cloudflare が管理する TURN は以下のように設定します。
agent/.env および server/.env の設定
ICE_SERVER_URLS=stun:stun.cloudflare.com,turn:turn.cloudflare.com:53,turn:turn.cloudflare.com:3478,turn:turn.cloudflare.com:5349
Amazon Kinesis Video Streams (KVS) を使用した AWS ネイティブ TURN の活用
管理型 TURN サービスに対する完全な AWS ネイティブの代替手段として、Amazon Kinesis Video Streams (KVS) は、サードパーティ製の依存関係なしに TURN インフラストラクチャを処理します。これは GetIceServerConfig API を介して一時的で自動ローテーションされる TURN 認証情報を提供し、NAT トリバーサル(ネットワークアドレス変換の通過)のためのサードパーティ依存を回避します。フローは以下の通りです。
- 一度きりのセットアップ: KVS シグナリングチャネルを作成します。このチャネルは TURN 認証情報のプロビジョニング専用であり、エージェントはシグナリングとメディアのために引き続き Pipecat の WebRTC トランスポートを使用し続けます。
- 接続時: エージェントは GetSignalingChannelEndpoint を呼び出して HTTPS エンドポイントを取得し、その後 GetIceServerConfig を呼び出して一時的な TURN 認証情報(URI、ユーザー名、パスワード)を取得します。
- ピア接続の設定: 返された認証情報を RTCPeerConnection の ICE サーバーとして渡します。TURN トラフィックは KVS が管理するインフラストラクチャを通じて流れます。
KVS 管理型 TURN を使用する際の考慮事項
| 要素 | KVS 管理型 TURN | サードパーティ製 TURN |
|---|---|---|
| AWS ネイティブ | はい — 外部依存なし | いいえ — 外部アカウントが必要 |
| 認証情報の管理 | 自動ローテーション | 手動またはプロバイダー管理 |
Set up
<td style="padding: 10px;border: 1px solid
原文を表示
*This post is a collaboration between AWS and Pipecat.*
Deploying intelligent voice agents that maintain natural, human-like conversations requires streaming to users where they are, across web, mobile, and phone channels, even under heavy traffic and unreliable network conditions. Even small delays can break the conversational flow, causing users to perceive the agent as unresponsive or unreliable. For use cases such as customer support, virtual assistants and outbound campaigns, a natural flow is critical for user experience. In this series of posts, you will learn how streaming architectures help address these challenges using Pipecat voice agents on Amazon Bedrock AgentCore Runtime.
In Part 1, you will learn how to deploy Pipecat voice agents on AgentCore Runtime using different network transport approaches including WebSockets, WebRTC and telephony integration, with practical deployment guidance and code samples.
Benefits of AgentCore Runtime for voice agents
Deploying real-time voice agents is challenging: you need low-latency streaming, strict isolation for security, and the ability to scale dynamically to unpredictable conversation volume. Without an appropriately designed architecture, you can experience audio jitter, scalability constraints, inflated costs due to over-provisioning, and increased complexity. For a deeper dive into voice agent architectures, including cascaded (STT → LLM → TTS) and speech-to-speech approaches refer to our previous post, Building real-time voice assistants with Amazon Nova Sonic compared to cascading architectures.
Amazon Bedrock AgentCore Runtime addresses these challenges by providing a secure, serverless environment for scaling dynamic AI agents. Each conversation session runs in isolated microVMs for security. It auto-scales for traffic spikes, and handles continuous sessions for up to 8 hours, making it ideal for long, multi-turn voice interactions. It charges only for resources actively used, helping to minimize costs associated with idle infrastructure.
Pipecat, an agentic framework for building real-time voice AI pipelines, runs on AgentCore Runtime with minimal setup. Package your Pipecat voice pipeline as a container and deploy it directly to AgentCore Runtime. The runtime supports bidirectional streaming for real-time audio, and built-in observability to trace agent reasoning and tool calls.
AgentCore Runtime requires ARM64 (Graviton) containers, so make sure your Docker images are built for the linux/arm64 system.
Streaming architectures for voice agents on AgentCore Runtime
This post assumes your familiarity of common voice agent architectures: specifically the cascaded models approach, where you connect speech-to-text (STT) and text-to-speech (TTS) models in a pipeline, and the speech-to-speech model approach, like Amazon Nova Sonic. If you are new to these concepts, start with our earlier blog posts on the two foundational approaches: cascaded and speech-to-speech before continuing.
When building voice agents, latency is a critical consideration, determining how natural and reliable a voice conversation feels. Conversations require near-instant responses, typically under one second end-to-end, to maintain a fluid, human-like rhythm.

To achieve low latency, you need to consider bi-directional streaming on multiple paths, including:
- Client to Agent: Your voice agents will run on devices and applications, from web browsers and mobile apps to edge hardware, each with unique network conditions.
- Agent to Model: Your voice agents rely on bidirectional streaming to interact with speech models. Most speech models expose real-time WebSocket APIs, which your agent runtime or orchestration framework can consume for audio input and text or speech output. Model selection plays a key role in achieving natural responsiveness. Select models like Amazon Nova Sonic (or Amazon Nova Lite in a cascaded pipeline approach) that are optimized for latency and provides a fast Time-to-First-Token (TTFT).
- Telephony: For traditional inbound or outbound calls handled through contact centers or telephony systems, your voice agent must also integrate with a telephony provider. This is typically achieved through a handoff and/or Session Interconnect Protocol (SIP) transfer, where the live audio stream is transferred from the telephony system to your agent runtime for processing.
In Part 1 of this series, we will focus on the *Client to Agent* connection and how to minimize the first-hop network latency from your edge device to your voice agent and explore additional considerations in relation to other components of voice agent architecture.
To illustrate these concepts, we will explore four network transport approaches with considerations for:
- How users interface with your voice agents (web/mobile applications or phone calls)
- Performance consistency and resilience across variable network conditions
- Ease of implementation
Approach
Description
Performance consistency
Ease of implementation
Suitable for
WebSockets
Web and mobile applications connects directly to your voice agents via WebSockets.
Good
Simple
Prototyping and lightweight use cases.
WebRTC (TURN-assisted)
Web and mobile applications connects directly to your voice agents via WebRTC.
Excellent
Medium
Production use cases with latency derived from direct connection of the client to the runtime environment relayed via Traversal Using Relays around NAT (TURN) servers.
WebRTC (managed)
Web and mobile applications connect to your voice agents through an advanced, globally distributed infrastructure via WebRTC.
Excellent (Global distribution)
Simple
Production use cases with latency optimization offloaded to specialized providers with globally distributed network and media relays. Offers additional capabilities such as observability and multi-participant calls.
Telephony
Voice agents are accessed through traditional phone calls.
Excellent
Medium
Contact center and telephony use cases. Latency may be dependent on telephony provider.
Example approach: Using WebSockets bi-directional streaming
You can start with WebSockets as the simplest approach: it natively supports most clients and AgentCore Runtime. Deploy Pipecat voice agents on AgentCore Runtime using persistent, bidirectional WebSocket connections for audio streaming between client devices and your agent logic.

The connection follows a straightforward three-step flow:
- Client requests a WebSocket endpoint: The client first sends a POST request to an intermediary server (/server) to obtain a secure WebSocket connection endpoint.
- Intermediary server handles AWS authentication: The intermediary server on the Pipecat pre-built frontend uses the AWS SDK to generate an AWS SigV4 pre-signed URL with embedded credentials as query parameter. For example: X?-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=
- Client establishes direct connection: Using the authenticated pre-signed URL, the client connects directly to the agent on AgentCore Runtime and streams bi-directional audio, bypassing the intermediary server for subsequent communications.
You use Pipecat’s WebSocket transport to expose an endpoint at the /ws path as required by AgentCore Runtime. The architecture separates credential management from agent logic for secure client access without exposing AWS credentials directly to browser applications.
To learn more, try the Pipecat on AgentCore code sample using WebSockets transport.
Example approach: Using WebRTC bi-directional streaming with TURN assistance
While WebSockets works for simple deployments, WebRTC can offer improved performance. It is designed to send audio using a fast, lightweight network path that minimizes delay. It typically uses UDP for its low latency and smoother real-time experience, and provides improved resilience across variable network conditions. If UDP is not available, WebRTC automatically falls back to TCP, which is more reliable but can introduce slight delays: less ideal for voice, but helpful when connectivity is restricted. This reliability comes from Interactive Connectivity Establishment (ICE) servers, which negotiate direct peer-to-peer paths through NATs and firewalls, falling back to streaming media relay via Traversal Using Relays around NAT (TURN) servers when direct connections cannot be made.
Pipecat supports SmallWebRTCTransport for direct peer-to-peer WebRTC connections between clients and agents on AgentCore Runtime. Compared to comprehensive WebRTC architectures requiring dedicated media servers (such as Selective Forwarding Units or SFUs), this lightweight transport can run directly within AgentCore Runtime, removing the need for complex media server management.

In this scenario, connection flow operates as follows:
- Signaling: Client sends a Session Description Protocol (SDP) offer to the intermediary server, which forwards it to the /invoke/ endpoint in AgentCore Runtime. The agent @app.entrypoint handler processes the offer and returns an SDP answer containing media capabilities and network candidates.
- Connectivity Establishment: To establish a direct connection, both the client and the agent use Interactive Connectivity Establishment (ICE) protocol in order to discover the optimal network path. AgentCore Runtime supporting Traversal Using Relays around NAT (TURN) relayed connections. The protocol attempts connectivity in this order:
Direct Connection: Connect peer-to-peer using local network addresses. This path is not supported on AgentCore Runtime as the runtime environment cannot be assigned to a public IP address.
- Session Traversal Utilities for NAT (STUN) assisted connection: Use a STUN server to discover public IP/port through Network Address Translation (NAT) and attempt direct connectivity. This path requires both inbound and outbound UDP traffic which is not currently supported as AWS NAT Gateways uses symmetric NAT, which prevents STUN-based direct connectivity from succeeding.
- Traversal Using Relays around NAT (TURN) relayed connection: Route media through a TURN relay server. Configure TURN using managed services (such as Cloudflare or Twilio), Amazon Kinesis Video Streams (KVS) or self-hosted solutions (such as coturn in your VPC). This path is recommended on AgentCore Runtime configured with a VPC (see details below).
- Connection through VPC: Once connectivity is established, traffic will route from the client to the runtime environment via the VPC (more details in the following section).
To learn more, try the Pipecat on AgentCore code sample using WebRTC transport.
Configuring AgentCore Runtime on VPC for WebRTC connectivity
The code sample demonstrates a simple voice agent using WebRTC. First, you configure ICE_SERVER_URLS environment variables in both: 1) the intermediary server on the Pipecat pre-built frontend (/server) and 2) the runtime environment (/agent). This allows bidirectional traffic between them.
Next, you deploy your agents to AgentCore Runtime with VPC networking configured to allow for UDP transport to TURN servers. For security, you expose the runtime to a private VPC subnet, with a NAT Gateway in the public subnet to route internet access, as illustrated below.

With this approach, you can configure ICE servers for full WebRTC connectivity, with both STUN and UDP with TCP fallback. For example, you can configure Cloudflare managed TURN as follows:
# Configure agent/.env and server/.env
ICE_SERVER_URLS=stun:stun.cloudflare.com,turn:turn.cloudflare.com:53,turn:turn.cloudflare.com:3478,turn:turn.cloudflare.com:5349Using AWS-native TURN with Amazon Kinesis Video Streams (KVS)
For a fully AWS-native alternative to managed TURN services, Amazon Kinesis Video Streams (KVS) handles TURN infrastructure without third-party dependencies. It provides temporary, auto-rotating TURN credentials via the GetIceServerConfig API, avoiding third-party dependencies for NAT traversal. The flow works as follows:
- One-time setup: Create a KVS signaling channel. The channel is used only for TURN credential provisioning — your agent continues to use Pipecat’s WebRTC transport for signaling and media.
- At connection time: Your agent calls GetSignalingChannelEndpoint to get the HTTPS endpoint, then calls GetIceServerConfig to retrieve temporary TURN credentials (URIs, username, password).
- Configure the peer connection: Pass the returned credentials to your RTCPeerConnection as ICE servers. TURN traffic flows through KVS-managed infrastructure.
Considerations when using KVS managed TURN
Factor
KVS Managed TURN
Third-party TURN
AWS native
Yes — no external dependency
No — requires external account
Credential management
Automatic rotation
Manual or provider-managed
Set up
<td style="padding: 10px;border: 1px solid
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み