API Platform

Synchronous, Asynchronous, and Task Queries

The current /v1 endpoints use a synchronous/asynchronous model: a synchronous request returns the result directly; an asynchronous request creates a task via async=true and is queried using the task_id returned by the server.

Synchronous request

When async=true is not passed, the endpoint returns the result directly according to the capability. For speech generation, delivery_method=audio returns the audio content directly, while delivery_method=url returns JSON with a result URL.

Asynchronous request

When async=true is passed, the endpoint immediately returns a task object; you may optionally pass webhook_url to receive a terminal-state callback.

Create an asynchronous task
{
  "model": "moss-tts",
  "input": "This is a piece of asynchronously generated speech.",
  "voice_id": "<voice_id>",
  "async": true,
  "webhook_url": "https://example.com/webhook"
}

On success, the endpoint immediately returns a task object:

Creation response
{
  "task_id": "task_abc123",
  "status": "PENDING",
  "retry_after": 3
}

The success-path state machine is PENDING → PROCESSING → SUCCESS; on failure, the task enters a failure terminal state and returns the internal standard error structure (see the task query notes below). A task may stay in PROCESSING for an extended period, and completion time depends on actual processing; start polling at the returned retry_after interval (in seconds).

Task queries

Use the task_id returned by the server to query the latest status and results of the task.

Task typeQuery path
General audio taskGET /v1/audio/tasks/{task_id}
Transcription taskGET /v1/audio/transcriptions/{task_id}

For the endpoint parameters of general audio tasks, see Audio Tasks.

Query a general audio task
curl https://api.mosi.cn/v1/audio/tasks/$TASK_ID \
  -H "Authorization: Bearer $MOSS_API_KEY"