# Sell speech

This page is for a provider that turns text into audio. It tells you which path to use, what your upstream must answer, and how to register and quote the deployment. [Quote a media model](https://inference.ai.exchange/docs/provider-media-quote.md) has the features and the prices.

## Choose a path

| Path                                                 | Use it when                                                                           |
| ---------------------------------------------------- | ------------------------------------------------------------------------------------- |
| [OpenAI-compatible API](https://inference.ai.exchange/docs/provider-openai.md#speech) | Your API has `POST /audio/speech` and answers in the OpenAI format. You run no agent. |
| [Your own agent](https://inference.ai.exchange/docs/provider-dispatch.md#speech)      | Your upstream has other routes. Send one `audio` event with the clip.                 |

The rest of this page is for the reference agent. It reads these routes from your upstream.

## Give the agent this route

The agent calls `POST {base}/audio/speech` with `Authorization: Bearer <key>`. Set `{base}` in `LIQUID_UPSTREAM_BASE_URL`.

```json
{
  "model": "acme-tts-1",
  "input": "The auction is open.",
  "voice": "alloy",
  "response_format": "mp3",
  "speed": 1.0
}
```

`input` is the last user turn. `response_format` and `speed` are present only when the buyer set them. The agent sends `instructions` only if you declared `speech.instructions`.

Answer with the audio file as the body, not JSON. Set `Content-Type` to the type of the file, for example `audio/mpeg`. The buyer gets that type. If you send none, the agent uses the type of the format that was asked for, or `audio/mpeg`. An empty body fails the job.

## Declare the controls

- `speech.instructions`: the buyer's style line. The first-party OpenAI adapter declares it for a model whose name contains `gpt-4o`.
- `speech.turns`: a clip with more than one voice. No first-party adapter declares it, because they speak one voice for each clip. To sell it, write your own agent. The dispatch holds a list of `turns`. See [Speech](https://inference.ai.exchange/docs/provider-dispatch.md#speech).

## Register and quote

Register the deployment with `kind` set to `audio_speech`. List the `voices` and `formats` that it makes. [Register deployments](https://inference.ai.exchange/docs/provider-models.md) has the fields.

Quote one `output_speech` line in `pricing`. The charge is that rate multiplied by the characters of the text of all turns. The exchange counts them before dispatch, so the price cap is exactly the charge. Your upstream reports no count, and the agent meters the characters that it received.

To price a quality apart, add a line with `variant` `{"quality": "hd"}`. A request that states `quality` pays the line whose variant it matches. A request that states none, or a name that you do not price, pays the line with no variant. See [Quote a media model](https://inference.ai.exchange/docs/provider-media-quote.md#a-speech-model).

## Limits

- Speech does not stream. The agent reads the whole file, then sends it as one clip.
- A request for a voice or a format that you did not list goes to another offer before the award.
- A failed call ends the attempt. The exchange charges nothing and tries the next offer.
