API Platform

Upload File

Upload a file into the platform asset system and receive a file_id, which can be reused by id in asynchronous / large-file scenarios such as ASR. This endpoint aligns with the Files upload operation; the request body is multipart/form-data.

POST
/v1/files

Upload a file. The request body is multipart/form-data; the file field is streamed into assets, and a file object is returned, where id is the file_id.

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/files \
  -H "Authorization: Bearer $MOSS_API_KEY"

Request fields

FieldTypeRequiredDescription
filefileYes

The multipart file field, streamed into assets; the whole file is not read into memory.

purposestringYes

File purpose, for example audio; the platform records this marker.

Request example

curl https://api.mosi.cn/v1/files \
  -H "Authorization: Bearer $MOSS_API_KEY" \
  -F file=@speech.wav \
  -F purpose=audio

Response fields

FieldTypeAlways returnedDescription
idstringYes

The file id, i.e. the file_id used by subsequent endpoints.

objectstringYes

Always file.

bytesintegerYes

File size in bytes.

created_atintegerYes

Creation time, a Unix timestamp in seconds.

filenamestringYes

The original file name.

purposestringYes

The purpose marker passed in on upload.

statusstringYes

File status, for example processed / active; failed may be returned on failure, subject to the actual server response.

Response example

Response example
{
  "id": "<file_id>",
  "object": "file",
  "bytes": 1048576,
  "created_at": 1710000000,
  "filename": "speech.wav",
  "purpose": "audio",
  "status": "processed"
}

Next steps