Real-time speech-to-speech (STS) communication WebSocket API for Phonic’s AI voice conversation platform.
All connections require authentication using one of the following methods:
Use your Phonic API key in the Authorization header:
Authorization: Bearer PHONIC_API_KEY
For client-side applications where you don’t want to expose your API key, first create a short-lived session token via the REST API: POST /v1/auth/session_token
Then connect to the WebSocket with the session token as a query parameter:
wss://api.phonic.ai/v1/sts/ws?session_token=ph_session_abc123...
API key for authentication. Format: “Bearer PHONIC_API_KEY”
Send audio chunk for real-time voice input
Update system prompt mid-conversation. This message is deprecated. Using add_system_message is recommended instead.
Add system message mid-conversation
Update the subset of tools available to the assistant mid-conversation
Soft-reset the conversation mid-stream, clearing the agent’s conversation memory and allowing for a new system prompt, tools, etc.
User input was cancelled (no speech detected)
AI-generated audio chunk with text
Assistant finished speaking (Not sent if interrupted by user_started_speaking)
WebSocket tool call requiring client-side execution
Non-fatal warning about conversation configuration or state
Bearer authentication header of the form Bearer <PHONIC_API_KEY>. Manage your API keys here.