Skip to main content
Audio workloads split into two shapes. Use the audio endpoints for file-like requests such as text-to-speech, transcription, and audio translation. Use the realtime WebSocket endpoint when the user experience needs low-latency, interactive audio or multimodal events.

Choose The Workflow

Discover Models

Query the model catalog before hard-coding a model. Use recommended shortlists for speech and transcription, and use model details to confirm realtime support before opening a socket.

Synchronous Audio Requests

Speech, transcription, and translation requests return directly from the HTTP request. Large inputs can take longer than common client defaults, so set a generous timeout and store request IDs for support.

Realtime Sessions

Open a WebSocket with the model in the query string and the API key in the Authorization header. Keep the event format documented for the selected realtime model, and close the socket when the session is complete. This guide covers the WebSocket proxy only. AI Sonar does not currently provide OpenAI Realtime REST client secret, translation client secret, Calls, or legacy beta session management endpoints.

State Handling

  • Save generated audio files instead of replaying the same request on refresh.
  • For transcription and translation, show upload and processing states even when the API call is synchronous.
  • For realtime, handle close events and reconnect only after the user starts a new session.
  • Do not put API keys, private URLs, or account secrets in audio text input.

API Reference