Saltar al contenido principal

Generate audio from text

POST 

/api/v2/Audio/generate

Generates speech audio from the provided text using a text-to-speech model and returns a public URL to the generated audio file. The model can be selected by model id or by model code + vendor. The voice is optional; when not provided a default voice is used. A raw vendor voice id can be sent instead, to use a voice available in the tenant's own vendor account.

With stream: true the audio is delivered progressively as Server-Sent Events instead of only once complete, which avoids timeouts on long inputs. The events are: start (instance id and the audio format the chunks carry), audio (a base64 chunk; concatenating every chunk in order yields the complete file), ping (keep-alive), error and stop (the audio URL, usage and cost). Request validation still fails with a regular HTTP error, because it runs before the stream is opened.

Request​

Query Parameters

    culture string

    Use this param to override the culture of the response. Options: - en (default) - es

Body

The audio generation request containing the text, the model selection, an optional voice, voice id and speed, and whether to stream the result.

    text stringrequired

    Possible values: non-empty and <= 4000 characters

    The text to convert into speech.

    voice stringnullable

    Optional voice to use. When not provided, the vendor's default voice is used.

    voiceId stringnullable

    Possible values: <= 128 characters

    Optional raw vendor voice id, to use a voice available in the tenant's own vendor account. Takes precedence over voice.

    speed floatnullable

    Optional speed of the generated audio. Ignored by the models that don't accept a speed; otherwise defaults to 1 when not provided and is clamped to the model's accepted range.

    userIdentifier stringnullable

    Possible values: <= 256 characters

    Optional user identifier for tracking and cost management purposes.

    channel stringnullable

    Possible values: <= 64 characters

    The channel used in the execution.

    stream boolean

    When true, the audio is delivered progressively as Server-Sent Events instead of a single JSON response.

    aiModelId uuidnullable

    The unique identifier of the AI model to use. Used instead of Vendor and ModelCode.

    modelCode stringnullable

    The model code to use. Used together with Vendor when AIModelId is not provided.

    vendor stringnullable

    The vendor of the model to use. Used together with ModelCode when AIModelId is not provided.

Responses​

Returns the audio generation result including the public audio URL, or streams it as Server-Sent Events when stream is true.

Schema

    instanceId uuid
    audioUrl stringnullable

    usage

    object

    inputUnit stringnullable
    input int32nullable
    outputUnit stringnullable
    output int32nullable

    cost

    object

    amount double
    currency stringnullable
Loading...