Files
ai-video-fullstack/backend/services/openai_realtime/webrtc.py
Xin Wang 86639692ba feat: implement OpenAI-compatible Realtime API with authentication and management features
- Added support for public Realtime API, including new routes for managing API keys and handling WebRTC connections.
- Introduced RealtimeApiKey model and associated CRUD operations for admin management of API keys.
- Implemented authentication mechanisms for API keys and client secrets.
- Enhanced environment configuration with new secrets for Realtime API.
- Created OpenAIRealtime session management and event processing for real-time interactions.
- Updated schemas and settings to accommodate new features and ensure compatibility with existing systems.
2026-08-11 10:05:55 +08:00

27 lines
828 B
Python

"""Project-local SmallWebRTC specialization for the OpenAI event channel."""
from __future__ import annotations
from typing import Any
from pipecat.transports.smallwebrtc.connection import SmallWebRTCConnection
class OpenAIRealtimeWebRTCConnection(SmallWebRTCConnection):
"""Prevent Pipecat's private signalling envelope from leaking to clients."""
data_channel_label = "oai-events"
def _setup_listeners(self):
super()._setup_listeners()
@self._pc.on("datachannel")
def require_openai_event_channel(channel):
if channel.label != self.data_channel_label:
channel.close()
def send_app_message(self, message: Any):
if isinstance(message, dict) and message.get("type") == "signalling":
return
super().send_app_message(message)