Skip to main content
Once you know which model you want, calling it is a single HTTP request. This page walks a text-to-speech call and a speech-to-text call over plain HTTP, then shows how the request body changes from one model to the next. It assumes you already have an API key. If you need one, see Create your API key. To choose a model first, see Which models are available. For the same calls as a no-agent onboarding path, with more language tabs, see Use the API directly.

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 any slng/ prefix, is part of the path.
  • Auth your key as a bearer token: Authorization: Bearer $SLNG_API_KEY.
The 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 the reference_id field and returns MP3. The response is binary audio, so write it straight to a file.
The 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 in reference_id. Gradium takes it in voice_id, and returns WAV by default:
The two models also differ by route: Fish runs on the 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:

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 under results.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.