Anatomy of a request
Every model call has the same shape:- Host
https://eu-west.api.slng.ai. Regional hosts follow{region}.api.slng.ai; see Using regions in the services. - Path
/v1/tts/{model-id}for text to speech,/v1/stt/{model-id}for speech to text. The full model ID, including anyslng/prefix, is part of the path. - Auth your key as a bearer token:
Authorization: Bearer $SLNG_API_KEY.
slng/ prefix marks a model hosted by SLNG in your region, which is the
lowest-latency route. A model ID with no prefix is proxied to the provider. For the
routing rules, see
Which models are available.
Synthesize speech
Text to speech takes text and a voice and returns audio. This example calls the SLNG-hosted Fish model, which picks the voice with thereference_id field and returns
MP3. The response is binary audio, so write it straight to a file.
- curl
- Python
- CLI
voiceai-sdk client wraps the same
endpoint from JavaScript. See
Use the API directly.
Parameters differ by model
The endpoint shape is the same for every model, but the body is not. The field that selects the voice belongs to the model, so it changes when you change the model. Fish takes the voice inreference_id. Gradium takes it in voice_id, and returns WAV by
default:
slng/ hosted path, while
Gradium is proxied to the provider.
Always check the model’s API reference page for its own parameters before you call it.
See the text to speech API. On the CLI,
the voice is a friendly
-v/--voice name rather than these raw fields, so it reads the
same across models.
Transcribe audio
Speech to text takes an audio file and returns a transcript. Send the file as multipart form data:- curl
- CLI
Read the response
Text to speech returns binary audio. Write it to a file, and match the extension to the model’s output format: MP3 for Fish, WAV for Gradium in the examples above. Speech to text returns JSON. The transcript is underresults.channels[0].alternatives[0].transcript:
Response
Next steps
WebSockets vs HTTP
Stream audio in real time instead of posting a whole file.
Unified API
Call any model with one request format.
Bring your own key
Run a model on your own provider account.
Which models are available
Find the models you can call and how each one routes.