Quickstart with WebSocket API
Get started with Soket AI Realtime Speech API in minutes
Introduction
The Soket’s Realtime Speech API, built on OpenAI’s protocol, enables implementation of conversational AI capabilities through WebSockets, a widely supported protocol optimized for real-time server-to-server data transfer. This guide demonstrates how to establish WebSocket connections and interact with Realtime models. WebRTC support for browser and mobile clients will be available in an upcoming release.
Access Your API Key
- Log in to your TensorStudio account.
- Navigate to the API Keys section under manage.
- Generate a new API key for your project.
Note: Keep your API key secure. Avoid sharing it publicly.
Explore the Realtime Speech API
The Realtime Speech API lets you create responsive conversational applications powered by expressive voice-enabled models. It handles both text and audio in real-time, detects when users are speaking, and can execute custom functions - all with minimal latency.
Connection details
Connecting via WebSocket requires the following connection information:
URL | wss://api.soket.ai/v1/realtime |
Query Parameters | model Realtime model ID to connect to, like pragna-realtime |
Headers | Authorization: Bearer YOUR_API_KEY Substitute YOUR_API_KEY with a standard API key on the server, or an ephemeral token on insecure clients (note that WebRTC coming soon is recommended for this use case). |
Below are several examples of using these connection details to initialize a WebSocket connection to the Realtime API.
Sending and receiving events
Communication with Realtime models occurs through bidirectional message exchange over the WebSocket interface. The comprehensive documentation of available client and server messages can be found in the OpenAI Realtime API reference. Upon establishing a connection, the interface supports various event types including text messages, audio streams, tool calling, speech interruptions using Voice Activity Detection (VAD), and configuration modifications - enabling robust real-time interactions with the model.
Below, you’ll find examples of how to send and receive events over the WebSocket interface in several programming environments.
Need Help?
- Community Support: Join the TensorStudio’s Discord Community for tips and discussions.
- Customer Support: Reach us at support@tensorstudio.ai.