# Deployments: Speech

A speech deployment answers `/v1/audio/speech`. It turns text into audio and is priced for each character of the text.

[Deployments](https://liquidinference.ai/docs/provider-models.md) has the fields that every kind shares, the listing statuses and the lifecycle. This page has what is special to this kind.

## Register a deployment

Copy the request, set your provider key and change the names. Every endpoint here takes the [provider key](https://liquidinference.ai/docs/provider.md) as a bearer token.

```bash
curl https://router.inference.ai.exchange/v1/provider/models \
  -H "Authorization: Bearer $LIQUID_PROVIDER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
      "kind": "audio_speech",
      "deployment_name": "tts-1",
      "creator": "openai",
      "precision": "bf16",
      "region": "us-east",
      "max_input_tokens": 4096,
      "output_modalities": [
        {
          "type": "text"
        },
        {
          "type": "audio",
          "formats": [
            "audio/mpeg"
          ],
          "voices": [
            "alloy",
            "nova"
          ],
          "speeds": {
            "min_percent": 70,
            "max_percent": 120
          }
        }
      ]
    }'
```

```python
import os
import requests

response = requests.post(
    "https://router.inference.ai.exchange/v1/provider/models",
    headers={"Authorization": f"Bearer {os.environ['LIQUID_PROVIDER_KEY']}"},
    json={
        "kind": "audio_speech",
        "deployment_name": "tts-1",
        "creator": "openai",
        "precision": "bf16",
        "region": "us-east",
        "max_input_tokens": 4096,
        "output_modalities": [
            {
                "type": "text"
            },
            {
                "type": "audio",
                "formats": [
                    "audio/mpeg"
                ],
                "voices": [
                    "alloy",
                    "nova"
                ],
                "speeds": {
                    "min_percent": 70,
                    "max_percent": 120
                }
            }
        ]
    },
)
response.raise_for_status()
print(response.json()["status"])
```

```typescript
const response = await fetch('https://router.inference.ai.exchange/v1/provider/models', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.LIQUID_PROVIDER_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    kind: 'audio_speech',
    deployment_name: 'tts-1',
    creator: 'openai',
    precision: 'bf16',
    region: 'us-east',
    max_input_tokens: 4096,
    output_modalities: [
      {
        type: 'text',
      },
      {
        type: 'audio',
        formats: ['audio/mpeg'],
        voices: ['alloy', 'nova'],
        speeds: {
          min_percent: 70,
          max_percent: 120,
        },
      },
    ],
  }),
})
if (!response.ok) throw new Error(await response.text())
console.log((await response.json()).status)
```

The answer is `201` with the registration. A new registration is `UNLISTED`. `kind` cannot change: a new kind returns `409 kind_changed`.

## What you declare

| Field                  | Meaning                                                                                                                                                              |
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `voices`               | Voices it can speak in. A request for a voice that you did not list goes to another offer. A request that names no voice needs a deployment that lists at least one. |
| `formats`              | Formats it makes. Write `mp3` or `audio/mpeg`.                                                                                                                       |
| `speeds`               | The rates that it takes, in percent of the normal rate: `{ "min_percent": 70, "max_percent": 120 }`. Absent takes any rate from 0.25 to 4.                           |
| `max_duration_seconds` | The longest clip. The exchange only records it, because it cannot measure a clip first.                                                                              |

A request with a `speed` outside your range does not reach you, and the error names `speed`.

## Style and speakers

Declare the controls that your upstream honours as features in the quote:

- `speech.instructions`: the buyer's style line, such as `cheerful`.
- `speech.turns`: a clip with more than one speaker, each turn with its own voice.

## Quote and serve

Quote one `output.speech` line. To price a quality apart, add a `variant`. See [Quote a media model](https://liquidinference.ai/docs/provider-media-quote.md#a-speech-model). The route that your upstream needs is in [Sell speech](https://liquidinference.ai/docs/provider-speech.md).

```json
{ "billable": "output.speech", "unit": "character", "usd": 0.000015 }
```

## Charge

The charge is the rate times the characters in the text of all turns. The exchange counts characters before dispatch, so the cap is exactly the charge.

## Next

- Quote the deployment: [Quote over the session](https://liquidinference.ai/docs/provider-quoting.md).
- Get it on the public book: [Deployments](https://liquidinference.ai/docs/provider-models.md#from-registration-to-the-public-book).
