---
title: "Text to speech"
method: POST
path: "/audio/speech"
tags: ["Audio"]
---

# Text to speech

`POST /audio/speech`

## Request

- Base URL: `https://www.aimagicx.com/api/v1`
- URL: `https://www.aimagicx.com/api/v1/audio/speech`
- Auth: HTTP bearer

Generates audio from input text using AI voice synthesis. Supports voice cloning.

## Request body

- TextToSpeechRequest
  - `input` string, required: Text to synthesize
  - `model` string
  - `voice` 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer'
  - `speed` number
  - `response_format` 'mp3' | 'wav' | 'opus' | 'aac'
  - `reference_audio` string, uri, nullable: URL for voice cloning
  - `reference_text` string, nullable: Transcript of reference audio

## Response `200`

Successful response

- TextToSpeechResponse
  - `created` integer
  - `audio_url` string, uri
  - `duration_seconds` number
  - `character_count` integer
  - `model` string
  - `model_tier` string
  - `usage` Usage
    - `credits_used` integer
    - `credits_breakdown` object
    - `prompt_tokens` integer
    - `completion_tokens` integer
    - `total_tokens` integer

## Other responses

- `400`: Bad request - invalid parameters
- `401`: Unauthorized - invalid or missing API key

---

[API](https://skmtc.dev/aimagicx/apis/ai-magicx-api.md) - [All operations](https://skmtc.dev/aimagicx/apis/ai-magicx-api/llms.txt) - [OpenAPI document](https://skmtc.dev/aimagicx/apis/ai-magicx-api/revisions/08210272abb4?raw)
