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
Use this param to override the culture of the response. Options: - en (default) - es
- application/json
- text/json
- application/*+json
Body
The audio generation request containing the text, the model selection, an optional voice, voice id and speed, and whether to stream the result.
Possible values: non-empty and <= 4000 characters
The text to convert into speech.
Optional voice to use. When not provided, the vendor's default voice is used.
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.
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.
Possible values: <= 256 characters
Optional user identifier for tracking and cost management purposes.
Possible values: <= 64 characters
The channel used in the execution.
When true, the audio is delivered progressively as Server-Sent Events instead of a single JSON response.
The unique identifier of the AI model to use. Used instead of Vendor and ModelCode.
The model code to use. Used together with Vendor when AIModelId is not provided.
The vendor of the model to use. Used together with ModelCode when AIModelId is not provided.
Body
The audio generation request containing the text, the model selection, an optional voice, voice id and speed, and whether to stream the result.
Possible values: non-empty and <= 4000 characters
The text to convert into speech.
Optional voice to use. When not provided, the vendor's default voice is used.
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.
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.
Possible values: <= 256 characters
Optional user identifier for tracking and cost management purposes.
Possible values: <= 64 characters
The channel used in the execution.
When true, the audio is delivered progressively as Server-Sent Events instead of a single JSON response.
The unique identifier of the AI model to use. Used instead of Vendor and ModelCode.
The model code to use. Used together with Vendor when AIModelId is not provided.
The vendor of the model to use. Used together with ModelCode when AIModelId is not provided.
Body
The audio generation request containing the text, the model selection, an optional voice, voice id and speed, and whether to stream the result.
Possible values: non-empty and <= 4000 characters
The text to convert into speech.
Optional voice to use. When not provided, the vendor's default voice is used.
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.
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.
Possible values: <= 256 characters
Optional user identifier for tracking and cost management purposes.
Possible values: <= 64 characters
The channel used in the execution.
When true, the audio is delivered progressively as Server-Sent Events instead of a single JSON response.
The unique identifier of the AI model to use. Used instead of Vendor and ModelCode.
The model code to use. Used together with Vendor when AIModelId is not provided.
The vendor of the model to use. Used together with ModelCode when AIModelId is not provided.
Responses
- 200
- 400
- 401
- 403
- 404
- 500
Returns the audio generation result including the public audio URL, or streams it as Server-Sent Events when stream is true.
- text/plain
- application/json
- text/json
- Schema
- Example (from schema)
Schema
usage
object
cost
object
{
"instanceId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"audioUrl": "string",
"usage": {
"inputUnit": "string",
"input": 0,
"outputUnit": "string",
"output": 0
},
"cost": {
"amount": 0,
"currency": "string"
}
}
- Schema
- Example (from schema)
Schema
usage
object
cost
object
{
"instanceId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"audioUrl": "string",
"usage": {
"inputUnit": "string",
"input": 0,
"outputUnit": "string",
"output": 0
},
"cost": {
"amount": 0,
"currency": "string"
}
}
- Schema
- Example (from schema)
Schema
usage
object
cost
object
{
"instanceId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"audioUrl": "string",
"usage": {
"inputUnit": "string",
"input": 0,
"outputUnit": "string",
"output": 0
},
"cost": {
"amount": 0,
"currency": "string"
}
}
If the request validation fails or there are invalid parameter combinations.
- application/json
- Schema
- Example (from schema)
Schema
- MOD1
- MOD2
Array [
]
Stable, machine-readable error code. Branch on this value, not on message.
Human-readable, localised summary of the error.
Link to the documentation section for this error code.
errors
object
nullable
Map of keys (an invalid request field or the rule that failed) to messages. Only present when the error has specific detail to report. Values are strings, except on input_validation_error, where each value is an array of messages for that field.
property name*
object
nullable
oneOf
string
string
{
"code": "string",
"message": "string",
"documentationUrl": "string",
"errors": {}
}
The user is unauthorized or the session expired
- application/json
- Schema
- Example (from schema)
Schema
Stable, machine-readable error code. Branch on this value, not on message.
Human-readable, localised summary of the error.
Link to the documentation section for this error code.
{
"code": "string",
"message": "string",
"documentationUrl": "string"
}
The user does not have permission
- application/json
- Schema
- Example (from schema)
Schema
Stable, machine-readable error code. Branch on this value, not on message.
Human-readable, localised summary of the error.
Link to the documentation section for this error code.
{
"code": "string",
"message": "string",
"documentationUrl": "string"
}
If the specified model is not found or does not support text to speech.
- application/json
- Schema
- Example (from schema)
Schema
- MOD1
- MOD2
Array [
]
Stable, machine-readable error code. Branch on this value, not on message.
Human-readable, localised summary of the error.
Link to the documentation section for this error code.
errors
object
nullable
Map of keys (an invalid request field or the rule that failed) to messages. Only present when the error has specific detail to report. Values are strings, except on input_validation_error, where each value is an array of messages for that field.
property name*
object
nullable
oneOf
string
string
{
"code": "string",
"message": "string",
"documentationUrl": "string",
"errors": {}
}
There was an unexpected error
- application/json
- Schema
- Example (from schema)
Schema
Stable, machine-readable error code. Branch on this value, not on message.
Human-readable, localised summary of the error.
Link to the documentation section for this error code.
{
"code": "string",
"message": "string",
"documentationUrl": "string"
}