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

# Create Speech

> Convert text to speech audio

```
POST /v1/audio/speech
```

Generates audio from text input using text-to-speech models.

## Request Body

<ParamField body="model" type="string" required>
  The TTS model to use. Options include `tts-1` and `tts-1-hd`.
</ParamField>

<ParamField body="input" type="string" required>
  The text to generate audio for. Maximum length is 4096 characters.
</ParamField>

<ParamField body="voice" type="string" required>
  The voice to use. Supported voices: `alloy`, `echo`, `fable`, `onyx`, `nova`, `shimmer`.
</ParamField>

<ParamField body="response_format" type="string" default="mp3">
  The audio format. Supported formats: `mp3`, `opus`, `aac`, `flac`, `wav`, `pcm`.
</ParamField>

<ParamField body="speed" type="number" default="1.0">
  The speed of the generated audio. Range: 0.25 to 4.0.
</ParamField>

## Response

Returns the audio file content in the requested format. The response has the appropriate `Content-Type` header based on the format.

## Examples

### Basic Text-to-Speech

<CodeGroup>
  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="sk-voidai-your_key_here",
      base_url="https://api.voidai.app/v1"
  )

  response = client.audio.speech.create(
      model="tts-1",
      voice="alloy",
      input="Hello! This is a test of the text-to-speech API."
  )

  response.stream_to_file("output.mp3")
  ```

  ```typescript TypeScript theme={null}
  import OpenAI from 'openai';
  import fs from 'fs';

  const client = new OpenAI({
    apiKey: 'sk-voidai-your_key_here',
    baseURL: 'https://api.voidai.app/v1'
  });

  const response = await client.audio.speech.create({
    model: 'tts-1',
    voice: 'alloy',
    input: 'Hello! This is a test of the text-to-speech API.'
  });

  const buffer = Buffer.from(await response.arrayBuffer());
  fs.writeFileSync('output.mp3', buffer);
  ```

  ```bash cURL theme={null}
  curl https://api.voidai.app/v1/audio/speech \
    -H "Authorization: Bearer sk-voidai-your_key_here" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "tts-1",
      "voice": "alloy",
      "input": "Hello! This is a test of the text-to-speech API."
    }' \
    --output output.mp3
  ```
</CodeGroup>

### High-Definition Audio

<CodeGroup>
  ```python Python theme={null}
  response = client.audio.speech.create(
      model="tts-1-hd",
      voice="nova",
      input="Welcome to VoidAI! Experience the power of unified AI APIs.",
      response_format="flac"
  )

  response.stream_to_file("output.flac")
  ```

  ```typescript TypeScript theme={null}
  const response = await client.audio.speech.create({
    model: 'tts-1-hd',
    voice: 'nova',
    input: 'Welcome to VoidAI! Experience the power of unified AI APIs.',
    response_format: 'flac'
  });

  const buffer = Buffer.from(await response.arrayBuffer());
  fs.writeFileSync('output.flac', buffer);
  ```
</CodeGroup>

### Adjusting Speed

<CodeGroup>
  ```python Python theme={null}
  # Slower speech (0.5x speed)
  response = client.audio.speech.create(
      model="tts-1",
      voice="onyx",
      input="This is spoken more slowly for clarity.",
      speed=0.5
  )

  # Faster speech (1.5x speed)
  response = client.audio.speech.create(
      model="tts-1",
      voice="onyx",
      input="This is spoken more quickly.",
      speed=1.5
  )
  ```
</CodeGroup>

## Voice Descriptions

| Voice     | Description                 |
| --------- | --------------------------- |
| `alloy`   | Neutral, balanced voice     |
| `echo`    | Warm, conversational voice  |
| `fable`   | Expressive, narrative voice |
| `onyx`    | Deep, authoritative voice   |
| `nova`    | Friendly, energetic voice   |
| `shimmer` | Clear, refined voice        |

## Audio Format Comparison

| Format | Quality   | File Size | Use Case                   |
| ------ | --------- | --------- | -------------------------- |
| `mp3`  | Good      | Small     | General use, web streaming |
| `opus` | Excellent | Small     | Real-time streaming        |
| `aac`  | Good      | Small     | Mobile apps                |
| `flac` | Lossless  | Large     | Archival, high quality     |
| `wav`  | Lossless  | Large     | Professional editing       |
| `pcm`  | Raw       | Large     | Audio processing           |

<Tip>
  Use `tts-1` for lower latency and `tts-1-hd` for higher quality audio generation.
</Tip>
