Skip to content

Speech and voices

Turn text into speech in the format you need, list a model's voices, and clone a voice for your project with the speaker's consent.

Markdown
On this page

POST /audio/speech turns text into audio. The request is OpenAI compatible, so the OpenAI SDKs' audio.speech.create works against it. Voices come from GET /audio/voices, and a project can add its own cloned voices with POST /audio/voices. Field by field reference: POST /audio/speech.

Generate speech

curl https://api.getlykia.com/v1/audio/speech \
  -H "Authorization: Bearer $LYKIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini-tts",
    "input": "Your order has shipped and will arrive on Thursday.",
    "voice": "alloy",
    "response_format": "mp3"
  }' \
  --output speech.mp3

The response body is the audio itself, streamed as it is produced, with a Content-Type that matches response_format: mp3 (default), opus, aac, flac, wav or pcm. Which formats a model supports is in media.capabilities.speech.formats in GET /models?kind=speech.

Speech is priced per character of input (or per token for models whose provider bills tokens), so the cost is known before the audio starts: it comes in the X-Lykia-Cost header, next to the request id in X-Generation-Id. If the connection drops halfway, the characters the provider has billed are still charged.

Other fields: speed (within the model's speech.speed range), language, and instructions for models that take a speaking style (speech.instructions). The longest input a model accepts is speech.maxInputChars.

List voices

voice is a voice id. GET /audio/voices?model=… lists the model's ready-made voices and the voices your project has cloned for it:

curl "https://api.getlykia.com/v1/audio/voices?model=openai/gpt-4o-mini-tts" \
  -H "Authorization: Bearer $LYKIA_API_KEY"
200 OK
{
    "object": "list",
    "model": "openai/gpt-4o-mini-tts",
    "provider": "openai",
    "data": [
        {
            "id": "alloy",
            "object": "voice",
            "name": "Alloy",
            "category": "premade",
            "provider": "openai"
        },
        {
            "id": "ash",
            "object": "voice",
            "name": "Ash",
            "category": "premade",
            "provider": "openai"
        },
        {
            "id": "coral",
            "object": "voice",
            "name": "Coral",
            "category": "premade",
            "provider": "openai"
        }
    ]
}

Without model, the list is for the model of your @tts preset.

Clone a voice

Some models can speak in a voice cloned from a short recording. Send one or more recordings of the speaker as multipart/form-data, with a name for the voice and consent=true:

# consent=true confirms that you have the speaker's permission to clone this voice
curl https://api.getlykia.com/v1/audio/voices \
  -H "Authorization: Bearer $LYKIA_API_KEY" \
  -F model=elevenlabs/eleven_multilingual_v2 \
  -F name="Store narrator" \
  -F description="Calm narration voice" \
  -F consent=true \
  -F file=@sample.mp3

The answer is a voice object with an id starting with lvc_:

201 Created
{
    "id": "lvc_xg3eZdWjqZ19YY04ozRw",
    "object": "voice",
    "name": "Narrator",
    "category": "cloned",
    "description": "Calm narration voice",
    "provider": "elevenlabs",
    "model": "elevenlabs/eleven_multilingual_v2",
    "created_at": 1795463459,
    "requires_verification": false
}

Use that id as voice in speech requests. A cloned voice belongs to the project that created it: it works only with that project's keys, with the same provider and the same key (Lykia's or your own) it was created with, and requests from other projects get 404 (voice_not_found). Cloning itself is not charged; speech with the voice is priced like any other speech request. Some providers ask the speaker to verify a clone before it can be used; requires_verification says so.

Delete a cloned voice

DELETE /audio/voices/{id} deletes the clone at the provider and in Lykia:

curl -X DELETE https://api.getlykia.com/v1/audio/voices/lvc_xg3eZdWjqZ19YY04ozRw \
  -H "Authorization: Bearer $LYKIA_API_KEY"

Errors

CodeStatusWhen
unsupported_input400An unsupported response_format, speed, or a longer input than the model takes. metadata.param names the field.
consent_required400POST /audio/voices without consent=true.
platform_sales_disabled403The model's provider is not offered on Lykia credits yet. Add your own key for that provider to the project.
voice_not_found404The voice id is unknown or belongs to another project.
provider_busy429Lykia's connection to the provider is at its limit of requests at once. Retry after Retry-After.

See Errors for the error body and the other status codes.