Create speech (OpenAI compatible)
The request shape of the OpenAI speech API (POST /v1/audio/speech), so an OpenAI SDK, or a framework built on one, works with the base URL https://tts.us.assemblyai.com/v1/openai (or the EU host) and your AssemblyAI API key as its API key. It shares its behaviour with Create speech: the status waits for the first audio, the audio streams as it is synthesized, a failure after that point cuts the connection, and the same limits and billing apply.
Fields. model and input are required. model takes a language’s model name such as assemblyai-tts-en, or a model’s name such as assemblyai-tts-1 (the assemblyai/ prefix is accepted); a name that is not an AssemblyAI model name, OpenAI’s model names such as tts-1 included, is refused with 400, code model_not_found, and so is a model name the region does not serve. voice takes the library slug of an AssemblyAI voice, such as aai-jane, a voice’s UUID, or an OpenAI voice name, each mapped to an AssemblyAI voice: alloy to aai-jane, ash to aai-michael, ballad to aai-charles, cedar to aai-george, coral to aai-anna, echo to aai-paul, fable to aai-charles, marin to aai-mary, nova to aai-eve, onyx to aai-george, sage to aai-vera, shimmer to aai-alba and verse to aai-michael; in a language other than English, an OpenAI voice name speaks with the language’s default voice, aai-jane. A bare AssemblyAI voice name such as jane is refused with 422 on voice, and the message names its slug. A cloned voice goes in voice as {"id": "<voice ID or slug>"} or as a string holding its UUID. response_format is mp3 (default, 24 kHz at 64 kbps), pcm, wav, mulaw or alaw; opus, aac and flac are refused. stream_format: "sse" streams the audio as OpenAI speech events instead of raw bytes. Fields this route does not use, such as instructions and user, are ignored and listed in X-TTS-Unknown-Params.
Extensions. language (a language name such as english, or an ISO 639-1 code such as en), sample_rate, voice_id (a cloned voice’s ID or slug, with voice left out) and extend_biometric_consent (renews a cloned voice’s consent; see Renew consent) may be added to the body; most OpenAI clients pass them through an extra-body option. A language that contradicts model is refused. The language is the one you set, else the one the model name implies (assemblyai-tts-es asks for Spanish), else a cloned voice’s own language, else English. A request in a language no model of the region speaks is refused with 400, code invalid_request; see Languages.
SSE. With stream_format: "sse" the body is text/event-stream of data: lines only: {"type":"speech.audio.delta","audio":"<base64>"} for each piece of audio, the next bytes of the requested format, then one {"type":"speech.audio.done","usage":{...}}. There is no [DONE] line. While nothing is sent for 15 seconds, a comment line : keepalive arrives; ignore lines that start with :. A failure after the first audio sends {"type":"error","error":{...}} and then cuts the connection.
Errors use the OpenAI body (OpenAIErrorResponse), with the same code the native routes use and an OpenAI type. Text with nothing to speak is refused with 400, code invalid_request (input produced no speech), and is not billed.
Authorizations
Your AssemblyAI API key, or a temporary token, in the Authorization header. The raw key works directly; a Bearer prefix is also accepted, which is what OpenAI SDKs send. Send exactly one Authorization header. The HTTP routes read the credential from this header only.
Headers
Your own id for the request, 1 to 512 printable ASCII characters, echoed in the response. An invalid value is refused with 400, code invalid_parameter.
1 - 512Body
The OpenAI speech request. Fields this route does not use are ignored and listed in X-TTS-Unknown-Params.
A language's model name, such as assemblyai-tts-en (the language follows the code), or a model's name such as assemblyai-tts-1, optionally prefixed assemblyai/. Case-insensitive. A name that is not an AssemblyAI model name, OpenAI's model names such as tts-1 included, is refused with model_not_found, and so is a model name the region does not serve.
The text to speak, 1 to 5,000 Unicode code points, not blank. An array is refused.
1 - 5000The library slug of an AssemblyAI voice, such as aai-jane, a voice's UUID, or an OpenAI voice name mapped to an AssemblyAI voice: alloy (aai-jane), ash (aai-michael), ballad (aai-charles), cedar (aai-george), coral (aai-anna), echo (aai-paul), fable (aai-charles), marin (aai-mary), nova (aai-eve), onyx (aai-george), sage (aai-vera), shimmer (aai-alba) or verse (aai-michael), in English; in a language other than English, an OpenAI voice name speaks with the language's default voice, aai-jane. OpenAI voice names are case-insensitive; a slug is lowercase. A bare AssemblyAI voice name such as jane is refused with 422 (invalid_parameter) and param voice, and the message names its slug. Other values are not supported: a misspelt name, a file name, a path or a URL is refused with 422 like a bare name, and a slug or UUID that names no voice with 400 (invalid_request) or, where cloned voices are not available, 403. Left out, the default voice of the model and language, aai-jane. A cloned voice goes in as {"id": "<voice ID or slug>"}, or as a string holding its UUID; the slug of one of your voices in a plain string is refused.
mp3 (24 kHz, 64 kbps), pcm (raw 16-bit little-endian), wav (16-bit PCM in a WAV file), mulaw or alaw (raw G.711), case-insensitive. The sample rate is 24 kHz unless sample_rate says otherwise. opus, aac and flac are refused.
mp3, pcm, wav, mulaw, alaw audio streams the audio bytes; sse streams speech events. Case-insensitive.
audio, sse Accepted when it equals 1; any other value is refused.
Extension: the language to speak, as a name (english) or an ISO 639-1 code (en). Refused when it differs from the language model implies.
Extension: the sample rate of the audio in Hz.
8000, 16000, 22050, 24000, 44100, 48000 Extension: the ID or slug of a cloned voice, for clients that cannot send voice as an object. Leave voice out; next to any other voice, such as alloy or aai-jane, it is refused with invalid_parameter.
1 - 64Extension: true renews the biometric consent of a cloned voice, and attests renewed consent on behalf of the account that owns the voice; see Renew consent. Only the voice's owner may set it. The voice must be named as {"id": ...} in voice, as its UUID in the voice string, or in voice_id: with no voice, or a slug such as aai-jane in the voice string, it is refused with invalid_parameter (extend_biometric_consent: needs the voice by its id: {"id": ...} or a voice id in voice), and on another account's voice, or with an OpenAI voice name such as alloy in an English request, with not_owner. In another language, an OpenAI voice name is refused with invalid_parameter. The renewal is not guaranteed: one that cannot be made leaves the expiry as it was.
Must be false or left out; word timings come from POST /v1/speech/events.
Response
The audio, or speech events with stream_format sse.
Raw audio in the requested format. Streamed responses are chunked and end cleanly only when the audio is complete.