# Speech to text

`POST https://api.llm.buzz/api/v1/audio/transcriptions`

OpenRouter's speech-to-text API: one audio file in, its text out, never streamed. Send the audio as base64 in `input_audio`, or as an OpenAI multipart upload with the audio in a `file` part and every other field as a text part. The file is at most 25 MiB in `wav`, `mp3`, `flac`, `ogg`, `webm`, `m4a`, `aac` or `pcm`; its duration is measured before any provider is called, and a file that cannot be read is a 400, never billed. A call bills the seconds of audio. `GET /api/v1/models?output_modalities=transcription` lists the models your key can call, each with `verbose_json`.

Authentication: an inference key, as `Authorization: Bearer KEY`.

## Body

- `model` (string, required): A speech-to-text model from `GET /api/v1/models?output_modalities=transcription`, such as `openai/whisper-large-v3-turbo`.
- `input_audio` (object, required): `data` (the audio in base64) and `format`. A `url` is a 400: send the bytes.
- `response_format` (string, one of `json`, `verbose_json`): `json` (the default: `text` and `usage`) or `verbose_json`, which adds `task`, `language`, `duration`, `segments` and `words`, on a model whose `verbose_json` is `true`.
- `language` (string): An ISO-639-1 code such as `en`; omitted, the provider detects it.
- `temperature` (number): 0 to 1.
- `timestamp_granularities` (string[]): Sent with `verbose_json` only.
- `provider` (object): The audio routes read only the data policy fields; `order`, `only`, `ignore`, `allow_fallbacks` and `sort` are accepted and ignored. With the OpenAI SDK, send it in `extra_body`.
  - `zdr` (boolean): `true` keeps the request on providers that declare 0 days of retention.
  - `data_collection` (string, one of `allow`, `deny`): `deny` keeps the request on providers that declare no training and 0 days of retention.

## Responses

- 200: The text, with `usage.seconds` (what the call billed) and `usage.cost` in US dollars. The `X-Generation-Id` header names the call's generation record.
- 400: A field is missing or malformed (`invalid_request`, with `metadata.param`), or the model cannot do what the request asks (`unsupported_capability`).
- 401: No key, or the key is unknown, expired, revoked or disabled.
- 402: Your balance is spent and the model is not free, or the request could cost more than your balance.
- 404: No model has this name, or your key may not call it.
- 413: The file is over 25 MiB (`request_too_large`). Send a shorter file.

## Example (curl)

```bash
curl -X POST https://api.llm.buzz/api/v1/audio/transcriptions \
  -H "Authorization: Bearer $LLM_BUZZ_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "openai/whisper-large-v3-turbo",
  "input_audio": {
    "data": "BASE64_AUDIO",
    "format": "mp3"
  }
}'
```

## Example response

```json
{
  "text": "Thanks for calling.",
  "usage": {
    "seconds": 12.48,
    "cost": 0.000041558
  }
}
```
