API Reference
Authentication
All Shunya TTS endpoints require a valid API key. Authentication differs slightly between HTTP and WebSocket transports.
HTTP (Bearer Token)
For batch synthesis, pass your API key in the Authorization header:
terminal
curl -X POST https://tts.shunyalabs.ai/v1/audio/speech \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"zero-indic","voice":"Nisha","input":"Hello world"}'WebSocket (Query Param)
For streaming synthesis, pass the API key as a query parameter when opening the WebSocket connection:
python
import websockets
ws_url = "wss://tts.shunyalabs.ai/ws?api_key=YOUR_API_KEY"
async with websockets.connect(ws_url) as ws:
# Send config and text frames...
passAuthentication Errors
401 Unauthorized-- Missing or invalid API key.- WebSocket connections with an invalid key are closed immediately with code
4001.