API 平台

音频转写

将音频转换为文本,适合会议、访谈、语音消息和媒体内容处理。

操作流程

POST /v1/audio/transcriptions

Endpoint

moss-transcribe

模型

  1. 创建 API Key

    进入 API Key 管理平台,创建 API Key,并保存为环境变量。不要把 API Key 写进客户端代码或提交到仓库。

    示例
    export MOSS_API_KEY="<your-api-key>"
    
  2. 准备请求输入

    model 指定 moss-transcribe,给出待转写音频(filefile_idurlaudio_url)。

    file / file_id / url / audio_url:待转写音频 model:moss-transcribe response_format:json / text 等

    request.json
    {
      "model": "moss-transcribe",
      "file_id": "<file_id>",
      "response_format": "json"
    }
    
  3. 发起第一次请求

    POST /v1/audio/transcriptions 发起请求,同步请求直接返回转写结果。

    curl https://api.mosi.cn/v1/audio/transcriptions \
      -H "Authorization: Bearer $MOSS_API_KEY" \
      -H "Content-Type: application/json" \
      -d @request.json
    
  4. 获取结果

    同步请求直接返回转写结果。如果传了 async=true,接口会先返回 task_id,再用它查询转写任务。

    查询转写任务
    curl https://api.mosi.cn/v1/audio/transcriptions/$TASK_ID \
      -H "Authorization: Bearer $MOSS_API_KEY"
    
  5. 验证成功

    成功标志:拿到转写文本。

下一步