Single-speaker Speech
Synthesize text into speech. This endpoint aligns with POST /v1/audio/speech; voice_id accepts only a voice id, not a voice url, a multipart voice file, or base64.
Authentication
Add Authorization: Bearer <API_KEY> to the request headers to authenticate. You can generate a key on the console "API Keys" page.
curl https://api.mosi.cn/v1/audio/speech \
-H "Authorization: Bearer $MOSS_API_KEY"
Supported models
| Field | Allowed values |
|---|---|
| model |
|
Request fields
| Field | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model name; see "Supported models" for allowed values, for example |
| version | string | No | Specify a model version that is live and publicly available; omit it to use the server's current default. |
| input | string | Yes | The text to synthesize. |
| voice_id | string | Yes | Voice ID; get one via List Voices, or go to the Mossland voice library and copy it from a voice card's copy icon. TTS accepts only a voice ID and does not support |
| response_format | string | No | Audio format for synchronous requests, e.g. |
| delivery_method | string | No |
|
| async | boolean | No | When set to |
| webhook_url | string | No | The HTTPS URL to call back once the asynchronous task completes. |
Request example
curl https://api.mosi.cn/v1/audio/speech \
-H "Authorization: Bearer $MOSS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "moss-tts",
"input": "hello",
"voice_id": "<voice_id>",
"response_format": "mp3",
"delivery_method": "url"
}'
Response fields
When delivery_method=url, JSON (with a result URL) is returned:
| Field | Type | Always returned | Description |
|---|---|---|---|
| id | string | Yes | Task/result ID. Synchronous URL JSON responses uniformly use |
| object | string | Yes | Fixed as |
| status | string | Yes | Task status, for example |
| url | string | Yes | Audio result URL. |
| response_format | string | Yes | Actual output audio format, for example |
| content_type | string | Yes | Audio MIME type, for example |
| created_at | integer | Yes | Creation time, a Unix timestamp in seconds. |
Asynchronous creation response fields
Returned immediately when async=true:
| Field | Type | Always returned | Description |
|---|---|---|---|
| id | string | Yes | Task ID. |
| task_id | string | Yes | Task query ID, usually the same as |
| object | string | Yes | Always |
| status | string | Yes | Initial status, for example |
| retry_after | integer | No | Suggested polling interval, in seconds. |
| created_at | integer | Yes | Creation time, a Unix timestamp in seconds. |
| updated_at | integer | No | Update time, a Unix timestamp in seconds. |
Response example
{
"id": "task_abc123",
"object": "audio.speech",
"status": "SUCCESS",
"url": "https://cdn.example.com/out.mp3",
"response_format": "mp3",
"content_type": "audio/mpeg",
"created_at": 1710000000
}