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

# Text-to-Speech

The Text-to-Speech API converts text into natural, high-quality speech with low latency. It supports multiple voices and voice cloning for creating custom voices from reference audio.

## OpenAI Compatibility

The Text-to-Speech API is fully compatible with the OpenAI Speech API. Existing OpenAI integrations can switch to Sarj by updating the base URL and API key while using the same request format and response structure.

## Base URL

`https://sarj-omni-tts.sarj.ai/v1`

## Endpoint

`POST /audio/speech`

## Authentication

All requests require an API key.

Include your API key in the `Authorization` header of every request.

**Authorization:** `Bearer YOUR_API_KEY`

## Request Format

The endpoint accepts `application/json` requests.

### Parameters

| Parameter            | Required | Description                                                    |
| :------------------- | :------- | :------------------------------------------------------------- |
| **model**            | Yes      | The model to use for speech generation. Use `gpt-4o-mini-tts`. |
| **voice**            | Yes      | Voice to synthesize.                                           |
| **input**            | Yes      | Text to convert into speech.                                   |
| **response\_format** | No       | Output audio format. Default is `wav`.                         |
| **num\_step**        | No       | Number of inference steps. Default is `16`.                    |

## Available Voices

| Voice                   | Description               |
| :---------------------- | :------------------------ |
| `ars_male`              | Saudi Arabic Male         |
| `ars_fares`             | Saudi Arabic Male (Fares) |
| `ars_female_expressive` | Saudi Arabic Female       |

## Voice Cloning

The Text-to-Speech API supports voice cloning using a reference audio sample.

Endpoint:

`POST /audio/speech/clone`

For best results:

* Use clean audio with minimal background noise.
* Use a 6–10 second reference recording.
* Provide the matching reference text.

## Example Request

Send a `POST` request to:

`https://sarj-omni-tts.sarj.ai/v1/audio/speech`

Include:

* An `Authorization` header containing your API key.
* An `application/json` request body containing the speech generation parameters.

## Response

The API returns the generated audio as a binary audio file. By default, the output format is WAV.
