> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sabi-tts-app.dev.neuralace.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate speech

> Synthesize a complete audio clip from text. OpenAI-compatible.

Generates speech for the given text and returns raw audio bytes. The endpoint is
drop-in compatible with the OpenAI Audio API — point the OpenAI SDK at
`https://sabi-tts.dev.neuralace.co/v1` with your `sk_` key.

## Authorization

<ParamField header="Authorization" type="string" required>
  `Bearer sk_…` — your secret API key.
</ParamField>

## Body

<ParamField body="voice" type="string" required>
  The voice id. Use `capella`.
</ParamField>

<ParamField body="input" type="string" required>
  The text to speak. Supports inline [audio tags](/capella/audio-tags).
</ParamField>

<ParamField body="response_format" type="string" default="wav">
  One of `wav`, `mp3`, `pcm`, `opus`, `flac`. With `pcm`, audio is streamed to the
  response as it is synthesized (lowest time-to-first-byte).
</ParamField>

<ParamField body="model" type="string">
  Accepted for OpenAI SDK compatibility but ignored — the voice selects the model.
</ParamField>

## Response

Raw audio bytes with the matching `Content-Type` (`audio/wav`, `audio/mpeg`, `audio/pcm`,
`audio/opus`, or `audio/flac`) and `Cache-Control: no-store`.

<ResponseField name="x-upstream-ms" type="header">
  Model inference time for this request, in milliseconds.
</ResponseField>

<ResponseField name="x-gateway-ms" type="header">
  Total gateway time in milliseconds. Subtract `x-upstream-ms` to get exact gateway
  overhead for the same request.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://sabi-tts.dev.neuralace.co/v1/audio/speech" \
    -H "Authorization: Bearer $SABI_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"model":"sabi","voice":"capella","input":"Hello from Capella.","response_format":"wav"}' \
    --output out.wav
  ```

  ```python Python theme={null}
  from openai import OpenAI
  import os

  client = OpenAI(
      base_url="https://sabi-tts.dev.neuralace.co/v1",
      api_key=os.environ["SABI_API_KEY"],
  )

  with client.audio.speech.with_streaming_response.create(
      model="sabi",
      voice="capella",
      input="Hello from Capella.",
      response_format="wav",
  ) as resp:
      resp.stream_to_file("out.wav")
  ```

  ```typescript Node theme={null}
  import OpenAI from "openai";
  import fs from "node:fs";

  const client = new OpenAI({
    baseURL: "https://sabi-tts.dev.neuralace.co/v1",
    apiKey: process.env.SABI_API_KEY,
  });

  const res = await client.audio.speech.create({
    model: "sabi",
    voice: "capella",
    input: "Hello from Capella.",
    response_format: "wav",
  });
  fs.writeFileSync("out.wav", Buffer.from(await res.arrayBuffer()));
  ```
</RequestExample>

<ResponseExample>
  ```json Error (4xx/5xx) theme={null}
  {
    "error": {
      "message": "Unknown voice",
      "type": "proxy_error"
    }
  }
  ```
</ResponseExample>
