> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slng.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Your first request

> Call a model over HTTP: pick the model ID, send the request, read the response.

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](/guides/get-started/quickstart#create-your-api-key). To choose
a model first, see [Which models are available](/guides/models/which-models-are-available).
For the same calls as a no-agent onboarding path, with more language tabs, see
[Use the API directly](/guides/get-started/create-a-project/api-only).

## 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](/guides/regions/using-regions-in-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](/guides/models/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.

<Tabs>
  <Tab title="curl" icon="terminal">
    ```bash theme={null}
    curl https://eu-west.slng.ai/v1/tts/slng/fish/tts:s2.1-pro \
      -H "Authorization: Bearer $SLNG_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "text": "Hello from sunny Barcelona!",
        "reference_id": "16cabdb7f8d240569aff36c9e480d783"
      }' \
      --output hello.mp3
    ```
  </Tab>

  <Tab title="Python" icon="python">
    ```python theme={null}
    import os
    import requests

    url = "https://eu-west.slng.ai/v1/tts/slng/fish/tts:s2.1-pro"
    headers = {
        "Authorization": f"Bearer {os.environ['SLNG_API_KEY']}",
        "Content-Type": "application/json",
    }
    data = {
        "text": "Hello from sunny Barcelona!",
        "reference_id": "16cabdb7f8d240569aff36c9e480d783",
    }

    response = requests.post(url, headers=headers, json=data)
    with open("hello.mp3", "wb") as f:
        f.write(response.content)
    ```
  </Tab>

  <Tab title="CLI" icon="square-terminal">
    The [`voiceai`](https://www.npmjs.com/package/voiceai-cli) CLI wraps the same API.
    Run `voiceai login` once to store your key, then pass the model with `-m`:

    ```bash theme={null}
    npm install -g voiceai-cli
    voiceai login
    voiceai tts "Hello from sunny Barcelona!" -m slng/fish/tts:s2.1-pro --out hello.mp3
    ```
  </Tab>
</Tabs>

The [`voiceai-sdk`](https://www.npmjs.com/package/voiceai-sdk) client wraps the same
endpoint from JavaScript. See
[Use the API directly](/guides/get-started/create-a-project/api-only).

## 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:

```bash highlight={2,7} theme={null}
# Gradium instead of Fish
curl https://eu-west.slng.ai/v1/tts/gradium/tts:default \
  -H "Authorization: Bearer $SLNG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello from sunny Barcelona!",
    "voice_id": "YTpq7expH9539ERJ"
  }' \
  --output hello.wav
```

The two models also differ by route: Fish runs on the `slng/` hosted path, while
Gradium is proxied to the provider.

| Model            | Route                             | Voice field    | Default format |
| ---------------- | --------------------------------- | -------------- | -------------- |
| Fish TTS 2.1 Pro | `slng/fish/tts:s2.1-pro` (hosted) | `reference_id` | MP3            |
| Gradium TTS      | `gradium/tts:default` (proxied)   | `voice_id`     | WAV            |

Always check the model's API reference page for its own parameters before you call it.
See the [text to speech API](/api-reference/text-to-speech/overview). 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:

<Tabs>
  <Tab title="curl" icon="terminal">
    ```bash theme={null}
    curl https://eu-west.slng.ai/v1/stt/slng/deepgram/nova:3-en \
      -H "Authorization: Bearer $SLNG_API_KEY" \
      -F "audio=@sample.wav"
    ```
  </Tab>

  <Tab title="CLI" icon="square-terminal">
    ```bash theme={null}
    voiceai stt sample.wav -m slng/deepgram/nova:3-en
    ```
  </Tab>
</Tabs>

## 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`:

```json Response theme={null}
{
  "results": {
    "channels": [
      {
        "alternatives": [
          { "transcript": "Hello from sunny Barcelona!" }
        ]
      }
    ]
  }
}
```

## Next steps

<CardGroup cols={2}>
  <Card title="WebSockets vs HTTP" icon="bolt" href="/guides/models/websockets-vs-http">
    Stream audio in real time instead of posting a whole file.
  </Card>

  <Card title="Unified API" icon="layer-group" href="/guides/models/unified-api">
    Call any model with one request format.
  </Card>

  <Card title="Bring your own key" icon="key" href="/guides/models/bring-your-own-key">
    Run a model on your own provider account.
  </Card>

  <Card title="Which models are available" icon="list" href="/guides/models/which-models-are-available">
    Find the models you can call and how each one routes.
  </Card>
</CardGroup>
