Create speech
const url = 'https://api.aderra.ai/v1/audio/speech';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"model":"aderra-voice-1","input":"Hello from Aderra.","voice":"Hazel","response_format":"mp3"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.aderra.ai/v1/audio/speech \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "model": "aderra-voice-1", "input": "Hello from Aderra.", "voice": "Hazel", "response_format": "mp3" }'Text to speech, OpenAI-compatible: the OpenAI SDKs’ audio.speech.create works with
the base URL changed. Returns the audio bytes in the requested response_format.
Streamed. The audio is sent as it is generated (chunked transfer): the first audio
arrives in about half a second, while a long text takes much longer to finish. Errors
before the audio starts keep their status codes. Once audio is flowing the status is
already 200, and an early failure shows as a truncated or aborted stream. The charge is
made when the stream completes: an early end caused by Aderra is not charged; a client
that disconnects mid-audio is charged, since the audio was generated. A streamed wav
has its RIFF and data sizes set to the maximum (“until the end of the file”).
API keys only. Speech is paid from the API wallet; a terminal key is refused with
403 api_key_required.
Long text. Up to 4,096 billable characters in mp3, wav and pcm. The text is
spoken in chunks of up to 900 billable characters, split at sentence ends, and joined
into one stream (x-aderra-chunks says how many). aac, opus and flac cannot be
joined, so text longer than one chunk is refused in those formats with
input_too_long_for_format.
Billing. Per billable character, quoted per 1,000 in GET /v1/usage/prices. Chinese,
Japanese and Korean characters count 3. If any chunk fails, the request fails and
nothing is charged.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
The text to speak, up to 4,096 billable characters (Chinese, Japanese and Korean characters count 3). Longer than 900 is spoken in chunks and joined, in mp3, wav and pcm only.
One of 200 voices, every one speaking every supported language. Case-insensitive. List them, with their gender, age, accent, use cases, style and a sample, with GET /v1/audio/voices, or listen at https://aderra.ai/docs/api/voices/. An unknown voice is refused with invalid_voice.
pcm is raw 16-bit signed little-endian mono at 24 kHz, as in OpenAI; wav is the same audio with a header. aac is served as an MP4 (M4A) file, Content-Type audio/mp4. aac, opus and flac are limited to one chunk (about 900 billable characters).
Speaking speed. Outside 0.7 to 1.3 is refused with invalid_speed.
ISO 639-1 code such as en or fr (a region suffix such as fr-CA or pt_BR is accepted and dropped). Absent: detected from the text, English when it cannot be told.
Example
{ "model": "aderra-voice-1", "input": "Hello from Aderra.", "voice": "Hazel", "response_format": "mp3"}Responses
Section titled “Responses”The audio, streamed as it is generated. The Content-Type follows response_format (aac is served as audio/mp4).
aac: AAC audio in an MP4 (M4A) file.
Raw 16-bit signed little-endian mono PCM at 24 kHz, no header.
16-bit mono at 24 kHz. Streamed, so the RIFF and data sizes are set to the maximum.
Headers
Section titled “Headers”Example
1How many chunks the text was spoken in and joined from.
Example
28000The price, in micro-credits, charged when the stream completes.
Example
18The billable characters you were charged for (CJK characters count 3).
invalid_request_error with code: invalid_json, model_not_found, invalid_input (empty), input_too_long (over 4,096 billable characters), input_too_long_for_format (aac, opus or flac text longer than one chunk), invalid_voice, unsupported_format, invalid_speed or unsupported_language. param names the field.
object
Example
{ "error": { "message": "Unknown voice \"Bob\". List the 200 voices with GET /v1/audio/voices, or see https://aderra.ai/docs/api/voices/.", "type": "invalid_request_error", "param": "voice", "code": "invalid_voice" }}authentication_error / unauthorized: the key is missing, unknown or revoked.
object
Example
{ "error": { "type": "billing_error" }}insufficient_credits (type insufficient_quota, with requiredMicro): the API wallet cannot pay for this input. api_wallet_empty when the wallet is empty, and key_spend_cap_reached when the key hit its monthly cap.
object
Example
{ "error": { "type": "billing_error" }}api_key_required (a terminal key), or account_suspended.
object
Example
{ "error": { "type": "billing_error" }}request_too_large: the body is over the size limit.
object
Example
{ "error": { "type": "billing_error" }}rate_limited or too_many_concurrent_requests (wait for Retry-After), or provider_busy when the voice service is busy. Nothing is charged.
object
Example
{ "error": { "type": "billing_error" }}Headers
Section titled “Headers”Example
12Whole seconds to wait before trying again.
api_error / provider_failed: the voice could not be generated. Nothing is charged.
object
Example
{ "error": { "type": "billing_error" }}