API Platform

Create Transcription

Audio transcription endpoint. Supports multipart file, file_id, url, and audio_url; audio_data is not supported.

POST
/v1/audio/transcriptions

Speech recognition. The request body is multipart/form-data or JSON. moss-transcribe-1.0 returns { text } synchronously; moss-transcribe-diarize-pro with diarize=true returns structured segments, and you can additionally pass stream=true to return transcription events over SSE.

Authentication

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

Example
curl -X POST https://api.mosi.cn/v1/audio/transcriptions \
  -H "Authorization: Bearer $MOSS_API_KEY"

Supported models

FieldAllowed values
model

moss-transcribe-1.0 / moss-transcribe-diarize-pro

Choose transcription mode

ScenariomodelResponse format
Standard audio transcriptionmoss-transcribe-1.0JSON / text
Multi-speaker transcriptionmoss-transcribe-diarize-proJSON with segments; pass stream=true to return SSE

Request fields

FieldTypeRequiredDescription
modelstringYes

See "Choose transcription mode" for values.

diarizebooleanNo

Whether to return speaker-separation results; recommended to pass true when using moss-transcribe-diarize-pro.

streambooleanNo

moss-transcribe-diarize-pro supports true, which returns transcription events over SSE; it cannot be combined with async=true.

response_formatstringNo

json returns JSON; diarized_json returns structured JSON with speakers and time ranges; text returns plain text. Pass json or diarized_json for streaming scenarios.

keytermsstring[]No

List of keyterms used to improve recognition accuracy for proper nouns, personal names, brand names, terminology, and similar content. Supported by the current moss-transcribe-diarize-pro; up to 20 keyterms, with a maximum of 30 characters each; omit it or pass [] to disable this feature.

asyncbooleanNo

Creates an asynchronous task when set to true.

webhook_urlstringNo

The HTTPS URL to call back once the asynchronous task completes.

filemultipart fileConditionally required

Local file; maximum 512 MB per file.

file_idstringConditionally required

File ID returned by /v1/files.

urlstringConditionally required

Public audio URL; it must not point to localhost, a loopback address, or a private network address.

audio_urlstringConditionally required

Compatibility field for url; the same access restrictions apply.

Supported formats and upload limits

ItemDescription
File sizeMaximum 512 MB; direct uploads use the same limit as /v1/files.
Supported formatsAAC, AMR, FLAC, M4A, ALAC, MOV, MP3, MP4, MPG, OGG, OPUS, WAV, WebM, WMA
Audio/video containersMOV, MP4, MPG, and WebM can be transcribed.

Request example

{
  "model": "moss-transcribe-1.0",
  "file_id": "<file_id>",
  "response_format": "json"
}

Response fields

Standard transcription (response_format=json)

FieldTypeAlways returnedDescription
textstringYes

The full recognized text.

Multi-speaker transcription

FieldTypeAlways returnedDescription
taskstringYes

Task type, currently returns transcribe.

durationnumberYes

Audio duration, in seconds.

textstringYes

The full transcription text.

segmentsarrayYes

Segment list; may be an empty array for short audio or when there are no valid segments.

segments[].typestringWhen segmented

Segment event type.

segments[].idstringWhen segmented

Segment ID.

segments[].startnumberWhen segmented

Segment start time, in seconds.

segments[].endnumberWhen segmented

Segment end time, in seconds.

segments[].textstringWhen segmented

Text of the segment.

segments[].speakerstringWhen segmented

Speaker label, for example S01.

Text response (response_format=text)

Multi-speaker streaming output (SSE)

When stream=true, text/event-stream is returned; SSE frames consist only of data: lines (no event: line), and the event type is carried in the type field of each frame's JSON.

FieldTypeAlways returnedDescription
task.createdSSE eventYes

Streaming task creation event, carrying task_id / object / status / model.

transcript.text.deltaSSE eventAs applicable

Incremental text event, carrying a delta text fragment.

transcript.segment.doneSSE eventAs applicable

Segment completion event, carrying content_index / speaker / text and other fields.

transcript.text.doneSSE eventYes

Transcription completion event, may carry the full text or usage.

usageobjectOptional in events

Usage information, returned according to the actual server events.

SSE example
data: {"type":"task.created","task_id":"<task_id>","object":"audio.transcription","status":"PROCESSING","model":"moss-transcribe-diarize-pro"}

data: {"type":"transcript.text.delta","delta":"大家"}

data: {"type":"transcript.segment.done","content_index":0,"speaker":"S01","text":"大家好,"}

data: {"type":"transcript.segment.done","content_index":1,"speaker":"S02","text":"你好。"}

data: {"type":"transcript.text.done","text":"大家好,你好。","usage":{"prompt_tokens":142,"completion_tokens":12,"total_tokens":154}}

Asynchronous creation response (async=true)

FieldTypeAlways returnedDescription
idstringYes

Task ID.

task_idstringYes

Task query ID, usually the same as id.

objectstringYes

Always audio.transcription.

statusstringYes

Initial status, for example PENDING.

retry_afterintegerNo

Suggested polling interval, in seconds.

created_atintegerYes

Creation time, a Unix timestamp in seconds.

updated_atintegerNo

Update time, a Unix timestamp in seconds.

For the result fields after an asynchronous task completes, see GET /v1/audio/tasks/{task_id}.

Next steps

Errors

The following cases return a parameter error:

  • keyterms is not an array of strings.
  • keyterms contains a non-string element.
  • A non-empty keyterms value is provided for the standard moss-transcribe-1.0 model.