API Platform

Generate Voice

Generate a voice or speech preview from text and a voice description. This endpoint is driven by input (the text to synthesize) + instruction (a description of the voice style).

POST
/v1/audio/voice/generations

Generate a voice / speech preview from text. The request body is JSON; delivery_method=url returns JSON (containing a result URL), while delivery_method=audio (the default) returns the audio binary.

Authentication

Add Authorization: Bearer <API_KEY> to the request header to authenticate. You can generate a key on the "API Keys" page of the console.

Example
curl https://api.mosi.cn/v1/audio/voice/generations \
  -H "Authorization: Bearer $MOSS_API_KEY"

Supported models

FieldAllowed values
model

moss-voice-generator

Request fields

FieldTypeRequiredDescription
modelstringYes

Model name; the value is moss-voice-generator.

versionstringNo

Optionally specify moss-voice-generator-v1; omit it to use the server's default.

inputstringYes

The text to generate speech from.

instructionstringYes

A description of the voice style, age, emotion, speaking rate, and so on.

response_formatstringNo

Audio format for synchronous requests, e.g. mp3 / wav; asynchronous tasks are not guaranteed to output in this format.

delivery_methodstringNo

audio returns the audio binary directly; url returns JSON and a result URL.

asyncbooleanNo

When set to true, creates an asynchronous task and immediately returns a task object.

webhook_urlstringNo

The HTTPS URL called back after the asynchronous task completes.

Request example

curl https://api.mosi.cn/v1/audio/voice/generations \
  -H "Authorization: Bearer $MOSS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "moss-voice-generator",
    "input": "Welcome to tonight's show.",
    "instruction": "A gentle, natural young female voice with a hint of a smile",
    "delivery_method": "url",
    "response_format": "mp3"
  }'

Synchronous URL response fields

When delivery_method=url, JSON (containing a result URL) is returned:

FieldTypeAlways returnedDescription
idstringYes

Task / result ID.

objectstringYes

Always audio.voice_generation.

statusstringYes

Task status, for example SUCCESS.

urlstringYes

The audio result URL.

response_formatstringYes

The actual output audio format, for example mp3 / wav.

content_typestringYes

The audio MIME type, for example audio/mpeg / audio/wav.

created_atintegerYes

Creation time, a Unix timestamp in seconds.

Response example

Response example
{
  "id": "task_abc123",
  "object": "audio.voice_generation",
  "status": "SUCCESS",
  "url": "https://cdn.example.com/out.mp3",
  "response_format": "mp3",
  "content_type": "audio/mpeg",
  "created_at": 1710000000
}

Synchronous audio response fields

When delivery_method is omitted or delivery_method=audio:

FieldTypeAlways returnedDescription
Content-TypeHTTP headerYes

The audio MIME type, for example audio/mpeg / audio/wav.

bodybinaryYes

The audio binary content.

Asynchronous creation response fields

Returned immediately when async=true:

FieldTypeAlways returnedDescription
idstringYes

Task ID.

task_idstringYes

Task ID; use this value when querying the task.

objectstringYes

Always audio.voice_generation.

statusstringYes

Task status after creation, for example PENDING.

model_idstringYes

The model name actually used.

model_versionstringYes

The model version actually used.

retry_afterintegerNo

Suggested number of seconds to wait before querying the task again.

created_atintegerYes

Creation time, a Unix timestamp in seconds.

updated_atintegerNo

Update time, a Unix timestamp in seconds.

Next steps