# Speech

`POST /v1/audio/speech` follows the OpenAI speech API and returns audio bytes directly.

## Request

| Field | Notes |
| --- | --- |
| `model` | Required. Checked against the key's model allowlist. |
| `input` | Required. The text to read. |
| `voice` | An OpenAI preset name (alloy, ash, ballad, coral, echo, fable, nova, onyx, sage, shimmer, verse) is mapped to a multilingual voice. An engine voice name is passed through. |
| `response_format` | `mp3` (default) or `opus` (WebM container, returned as audio/webm). Other values return 400. |
| `speed` | 0.25 to 4.0. Outside that range returns 400. |
| `instructions` | Accepted and ignored. |

```bash
curl https://api.novapi.ai/v1/audio/speech \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "MODEL_ID",
  "input": "Hello, welcome to the platform.",
  "voice": "alloy"
}' \
  --output speech.mp3
```

Python (OpenAI SDK):

```python
from openai import OpenAI

client = OpenAI(base_url="https://api.novapi.ai/v1", api_key="sk-...")

speech = client.audio.speech.create(model="MODEL_ID", voice="alloy", input="Hello, welcome to the platform.")
speech.write_to_file("speech.mp3")
```

## Response

The body is the audio. Extra headers: `X-Audio-Url` (a reusable URL of the audio), `X-Audio-Duration` (seconds) and `X-Cost` (credits charged).

If synthesis succeeded and was billed but the audio could not be streamed back, you get 502 `audio_fetch_failed` plus the `X-Audio-Url` header, so you can still download it.

## Voices

`GET /v1/tts/voices` lists the engine voice names.

## Speech to text

`POST /v1/audio/transcriptions` follows the OpenAI transcription API. Only four recognition models are served: `fun-asr`, `fun-asr-mtl`, `qwen3-asr-flash` and `qwen3-asr-flash-filetrans`. Any other `model` (for example `whisper-1`) returns 400 `model_not_found`. The model allowlist of the key applies.

Send the audio as a multipart `file`, or as an http(s) `url` (`file_url` also works) in JSON or in the form. Send one of the two, not both. An uploaded file is identified by its content, not its name or content type: wav, mp3, m4a/mp4, flac, ogg, webm, aac, amr, aiff and wma are accepted. It is stored on our storage and the stored link is passed to the model. The upload limit is 25 MB, and the gateway's overall request limit (20 MB by default) also applies; for larger files host the audio yourself and pass `url`.

| Field | Notes |
| --- | --- |
| `model` | Required. One of the four models above. |
| `file` or `url` | Required, exactly one. |
| `response_format` | `json` (default, `{"text": "..."}`) or `text`. `verbose_json`, `srt` and `vtt` need sentence timestamps, which `fun-asr`, `fun-asr-mtl` and `qwen3-asr-flash-filetrans` return; `qwen3-asr-flash` returns plain text only, so those three formats return 400 for it. |
| `duration` | Optional, seconds. See billing below; pass it whenever you can. |
| `async` | `true` (or the header `Prefer: respond-async`) returns 202 and a task object at once. |
| `language`, `prompt`, `temperature`, `timestamp_granularities` | Accepted and ignored. The model detects the language itself. |

```bash
curl https://api.novapi.ai/v1/audio/transcriptions \
  -H "Authorization: Bearer $API_KEY" \
  -F model=qwen3-asr-flash-filetrans \
  -F file=@meeting.mp3 \
  -F duration=185

# or point at a file you host:
# curl https://api.novapi.ai/v1/audio/transcriptions -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" \
#   -d '{ "model": "fun-asr", "url": "https://example.com/meeting.mp3", "duration": 185 }'
```

Python (OpenAI SDK):

```python
from openai import OpenAI

client = OpenAI(base_url="https://api.novapi.ai/v1", api_key="sk-...")

with open("meeting.mp3", "rb") as f:
    out = client.audio.transcriptions.create(
        model="qwen3-asr-flash-filetrans",
        file=f,
        extra_body={"duration": 185},
    )
print(out.text)
```

## Waiting, polling and results

By default the call waits for the result for up to about 110 seconds and answers 200 with the transcript. If the task is still running, you get 202 with a task object and a `Location` header; the task keeps running and is billed once. `GET /v1/audio/transcriptions/{id}` returns that object: `status` is `queued`, `in_progress`, `completed` or `failed`, `text` is set when completed and `error` when failed. Add `?response_format=srt` (or `text`, `vtt`, `verbose_json`) to a finished task to get that format directly.

A task that fails during a waiting call answers 502 `transcription_failed`. Ids start with `asr_` and can only be read by the account that created them.

```bash
# 200: {"text": "..."}
# 202 (still running after about 110 seconds, or "async": true):
{
  "id": "asr_<task-id>",
  "object": "audio.transcription",
  "model": "qwen3-asr-flash-filetrans",
  "status": "in_progress",
  "created_at": <unix-seconds>,
  "completed_at": null,
  "error": null
}

# GET https://api.novapi.ai/v1/audio/transcriptions/asr_<task-id> -> same object;
# when completed it also carries "text". Add ?response_format=srt to download subtitles.
```

## Billing and limits for speech to text

- Recognition is billed per second of audio and charged when the task is accepted; a failed task is refunded. The charge uses the `duration` the request carries, it is not corrected afterwards.
- For an uploaded file we read the duration ourselves: exact for WAV, from the header for MP3 (a variable-bitrate MP3 without a Xing/Info header can be off), and for other formats estimated from the file size at about 128 kbps, which can be higher or lower than the real length. If you only pass `url` and no `duration`, 60 seconds is charged because we do not download your file to measure it. Pass `duration` for an exact charge.
- For `fun-asr`, `fun-asr-mtl` and `qwen3-asr-flash-filetrans` the transcript is read from a temporary vendor link that expires after about a day; after that `GET` answers 502 `transcript_unavailable`, so store the text you need. `qwen3-asr-flash` is a short-clip model; the vendor's length and size limits apply and an over-limit file fails the task.
- Only `text` and the sentence timestamps are returned. There is no `usage` object, word-level timestamps or speaker labels.
