Skip to main content

Turn text into speech

TTS turns a complete text into a complete WAV file. It supports the stella and tide voices and returns 24 kHz, 16-bit, mono audio.

Prepare your project​

Follow Set up your project and set ANTAPI_KEY in a trusted terminal or backend. Before calling, check availability, accepted fields, and the published character price in the TTS API reference. A guide can be read before its API Reference is published.

Synthesize speech​

curl "https://api.antapi.dev/tts/v1/synthesize" \
--header "Authorization: Bearer $ANTAPI_KEY" \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: tts-speech-example-001' \
--dump-header speech.headers \
--data '{"text":"Hello, welcome to AntAPI.","voice_id":"stella","filter_markdown":true}' \
--output speech.wav

text is required. voice_id defaults to stella; choose tide for the other voice. filter_markdown defaults to true and affects what is spoken, not the platform's input-character count. The JSON body may be up to 64 KiB, with at most 10000 weighted input characters. Blank input and invalid control characters are rejected.

Check the HTTP status and Content-Type in speech.headers before playing the saved file. Success returns audio/wav; errors use the platform JSON code, data, and error envelope, so an error body saved as speech.wav is not audio.

Understand the character count​

Each Unicode Han character counts as two units. Every other Unicode code point counts as one, including spaces, newlines, emoji code points, and Markdown syntax. For example, 你好 A is six units. Filtering Markdown does not remove those input characters from billing. The output may be up to 30 minutes; audio length and synthesis time are different limits.

Completion and billing​

The platform authorizes the actual input-character count and bills it only after synthesis explicitly succeeds and the complete audio passes validation. Synthesis failures are not charged. Download interruption after successful synthesis does not cancel the charge. See Balance and billing for shared funding and budget rules.

The endpoint delivers the complete WAV after synthesis. It does not expose partial audio, WebSocket synthesis, download resumption, or an output-format switch. Same-key retries must preserve the original JSON bytes. Replays preserve the execution and financial facts but do not guarantee another download of the original audio. Do not automatically switch to a new key after a timeout; it can create another paid synthesis.

Save X-Request-ID and inspect usage and receipts when delivery is interrupted.

Use through MCP​

Follow MCP setup, authorize tts:synthesize, and discover tts_synthesize. Put the text, voice_id, and filter_markdown fields above inside input, with a saved idempotency_key beside it. Standard MCP AudioContent delivers audio/wav; structuredContent contains delivery metadata only, without another audio copy or download link.

The complete WAV limit is 86,400,044 bytes. Clients can impose smaller audio or timeout limits, so this does not guarantee long-audio compatibility. There is no persistent download resource or resumption. If completed audio cannot be replayed, only the original execution and receipt are recovered, without another synthesis or a new paid key. The weighted-character billing and input limits are unchanged. Availability follows the current release and authorization; existing connections need new consent for the added permission. The existing CLI does not include this operation.