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

# Generate Audio

> Transcribe audio to text (ASR) or synthesize speech from text (TTS).

`POST /api/v1/generate`

**Content-Type:** `multipart/form-data`

<Warning>
  Parameter support can differ depending on the model used. Check the Model Library for model-specific compatibility. [Open Model Library](https://app.eigenai.com/model-library).
</Warning>

## Authentication

Send your API key in the `Authorization` header as a Bearer token.

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

***

## Audio Transcription (ASR)

Supported model: **Whisper V3 Turbo** (`model=whisper_v3_turbo`)

### Parameters

| Name              | Type     | Required | Description                                                 |
| ----------------- | -------- | -------- | ----------------------------------------------------------- |
| `model`           | `string` | Required | Must be `whisper_v3_turbo`.                                 |
| `file`            | `file`   | Required | Audio file to transcribe (MP3, WAV, M4A, OGG, WebM).        |
| `language`        | `string` | Optional | Spoken language code (default `en`). Supports 99 languages. |
| `response_format` | `string` | Optional | Output format: `json` or `text`.                            |

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api-web.eigenai.com/api/v1/generate \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -F "model=whisper_v3_turbo" \
    -F "file=@/path/to/audio.mp3" \
    -F "language=en" \
    -F "response_format=json"
  ```

  ```python Python theme={null}
  import requests

  url = "https://api-web.eigenai.com/api/v1/generate"
  headers = {"Authorization": "Bearer YOUR_API_KEY"}

  with open("audio.mp3", "rb") as audio:
      response = requests.post(
          url,
          headers=headers,
          data={"model": "whisper_v3_turbo", "language": "en", "response_format": "json"},
          files={"file": ("audio.mp3", audio, "audio/mpeg")},
          timeout=120,
      )
  response.raise_for_status()
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  import fs from "node:fs";

  const form = new FormData();
  form.append("model", "asr");
  form.append("file", fs.createReadStream("audio.mp3"));
  form.append("language", "en");
  form.append("response_format", "json");

  const response = await fetch("https://api-web.eigenai.com/api/v1/generate", {
    method: "POST",
    headers: { Authorization: "Bearer YOUR_API_KEY" },
    body: form,
  });
  if (!response.ok) throw new Error(`Request failed: ${response.status}`);
  console.log(await response.json());
  ```
</CodeGroup>

***

## Text-to-Speech (TTS)

Three models are available. All accept `multipart/form-data` and return a WAV audio file by default. For real-time streaming over WebSocket, see [Stream Audio](/products/model-api/api-reference/stream-audio). To upload a voice reference for cloning, see [Upload Voice Reference](/products/model-api/api-reference/upload-voice).

### Higgs Audio V2.5 (`model=higgs2p5`)

| Name                   | Type      | Required | Description                                                                                                          |
| ---------------------- | --------- | -------- | -------------------------------------------------------------------------------------------------------------------- |
| `model`                | `string`  | Required | Must be `higgs2p5`.                                                                                                  |
| `text`                 | `string`  | Required | Text to convert to speech.                                                                                           |
| `voice`                | `string`  | Optional | Voice preset (e.g. `Linda`, `Jack`).                                                                                 |
| `voice_reference_file` | `file`    | Optional | Audio file for voice cloning (WAV, MP3).                                                                             |
| `voice_id`             | `string`  | Optional | Stored voice ID returned by [Upload Voice Reference](/products/model-api/api-reference/upload-voice).                |
| `voice_url`            | `string`  | Optional | External URL to a voice reference audio sample.                                                                      |
| `voice_name`           | `string`  | Optional | Name of a saved voice from the voice library.                                                                        |
| `voice_settings`       | `string`  | Optional | JSON string with voice settings. Supports `speed` (default `1.0`).                                                   |
| `sampling`             | `string`  | Optional | JSON string with sampling controls: `temperature` (default `1.0`), `top_p` (default `0.95`), `top_k` (default `50`). |
| `stream`               | `boolean` | Optional | `false` = return WAV file (default); `true` = HTTP SSE streaming.                                                    |

### ChatterBox Voice Twin (`model=chatterbox`)

| Name                 | Type      | Required | Description                                                                                           |
| -------------------- | --------- | -------- | ----------------------------------------------------------------------------------------------------- |
| `model`              | `string`  | Required | Must be `chatterbox`.                                                                                 |
| `text`               | `string`  | Required | Text to convert to speech (≤ 1,000 characters recommended).                                           |
| `language_id`        | `string`  | Optional | Language code (e.g. `en`, `zh`, `es`, `ja`). Supports 23 languages. Default `en`.                     |
| `audio_prompt_file`  | `file`    | Optional | Voice reference clip for voice cloning (WAV/MP3/M4A/OGG, max 30s).                                    |
| `voice_id`           | `string`  | Optional | Stored voice ID returned by [Upload Voice Reference](/products/model-api/api-reference/upload-voice). |
| `preset_url`         | `string`  | Optional | URL to a voice preset audio sample.                                                                   |
| `exaggeration`       | `number`  | Optional | Expressiveness: `0.0` = subtle, `0.5` = balanced, `1.0+` = highly animated (default `0.5`).           |
| `temperature`        | `number`  | Optional | Sampling temperature (default `0.8`).                                                                 |
| `diffusion_steps`    | `number`  | Optional | Quality vs. latency. Higher = better quality, slower (default `5`).                                   |
| `max_tokens`         | `integer` | Optional | Upper bound on generated tokens (default `3000`).                                                     |
| `top_p`              | `number`  | Optional | Nucleus sampling ceiling (default `1.0`).                                                             |
| `min_p`              | `number`  | Optional | Nucleus sampling floor (default `0.05`).                                                              |
| `repetition_penalty` | `number`  | Optional | Penalizes repeated tokens (default `1.2`).                                                            |
| `seed`               | `integer` | Optional | Seed for reproducible generation (`null` = random).                                                   |
| `stream`             | `boolean` | Optional | `false` = return WAV file (default); `true` = HTTP SSE streaming.                                     |

### Qwen3 TTS (`model=qwen3-tts`)

Supports named speakers (CustomVoice mode) or voice cloning (Base mode). `voice` and `voice_id`/`voice_url` cannot be used together.

| Name              | Type      | Required | Description                                                                                                                                                               |
| ----------------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `model`           | `string`  | Required | Must be `qwen3-tts`.                                                                                                                                                      |
| `text`            | `string`  | Required | Text to synthesize.                                                                                                                                                       |
| `voice`           | `string`  | Optional | Named speaker for CustomVoice mode: `Vivian`, `Serena`, `Uncle_Fu`, `Dylan`, `Eric`, `Ryan`, `Aiden`, `Ono_Anna`, `Sohee`. Cannot be used with `voice_id` or `voice_url`. |
| `voice_id`        | `string`  | Optional | Stored voice ID for Base model (from [Upload Voice Reference](/products/model-api/api-reference/upload-voice)).                                                           |
| `voice_url`       | `string`  | Optional | External URL to voice reference audio (Base model).                                                                                                                       |
| `voice_settings`  | `string`  | Optional | JSON string with voice settings. Supports `speed` (default `1.0`).                                                                                                        |
| `language`        | `string`  | Optional | `Auto`, `Chinese`, `English`, `French`, `German`, `Italian`, `Japanese`, `Korean`, `Portuguese`, `Russian`, `Spanish` (default `Auto`).                                   |
| `instructions`    | `string`  | Optional | Style/emotion control (e.g. `"speak cheerfully"`).                                                                                                                        |
| `response_format` | `string`  | Optional | Output format: `wav` (default), `pcm`, `mp3`, `flac`, `aac`, `opus`.                                                                                                      |
| `stream`          | `boolean` | Optional | `false` = return audio file (default); `true` = HTTP SSE streaming.                                                                                                       |

### TTS Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api-web.eigenai.com/api/v1/generate \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -F "model=higgs2p5" \
    -F "text=Hello, this is a test of the text-to-speech system." \
    -F "voice=Linda" \
    --output speech.wav
  ```

  ```python Python theme={null}
  import requests

  url = "https://api-web.eigenai.com/api/v1/generate"
  headers = {"Authorization": "Bearer YOUR_API_KEY"}
  data = {
      "model": "higgs2p5",
      "text": "Hello, this is a test of the text-to-speech system.",
      "voice": "Linda",
  }

  response = requests.post(url, headers=headers, data=data, timeout=120)
  response.raise_for_status()

  with open("speech.wav", "wb") as out:
      out.write(response.content)
  ```

  ```javascript JavaScript theme={null}
  import fs from "node:fs";

  const form = new FormData();
  form.append("model", "higgs2p5");
  form.append("text", "Hello, this is a test of the text-to-speech system.");
  form.append("voice", "Linda");

  const response = await fetch("https://api-web.eigenai.com/api/v1/generate", {
    method: "POST",
    headers: { Authorization: "Bearer YOUR_API_KEY" },
    body: form,
  });
  if (!response.ok) throw new Error(`Request failed: ${response.status}`);

  const buffer = Buffer.from(await response.arrayBuffer());
  fs.writeFileSync("speech.wav", buffer);
  ```
</CodeGroup>
