v1

API 文檔

音子AI开放平台 API 文档,提供完整的接口说明和使用示例

文档说明

本文档描述了音子AI开放平台 API 的使用方法。开发者可以通过 API 进行订单创建、查询等操作。 所有接口均需要通过 apiKey 进行鉴权。

開放平台 API 文檔 (v1)

本文檔描述了音子AI開放平台 API 的使用方法。開發者可以通過 API 進行訂單創建、查詢等操作。

鑑權 (Authentication)

所有接口均需要通過 apiKey 進行鑑權。系統將根據 apiKey 識別用戶,而不依賴 Session 或 Token。 您可以在"個人中心" -> "API Key" 中獲取您的密鑰。

鑑權方式支持以下兩種:

  1. Header 鑑權 (推薦)

    Authorization: Bearer <your_api_key>
    
  2. Query 參數鑑權

    ?apiKey=<your_api_key>
    

基礎 URL

https://api.yinziai.com

接口列表

1. 創建訂單 (Create Order)

創建異步處理訂單。系統會自動生成訂單號並返回。

  • URL: /api/open/v1/order/create
  • Method: POST
  • Content-Type: application/json

請求參數

參數名類型必填說明
orderTypestring訂單類型,見下文枚舉
stuffobject素材信息
stuff.pathKeystring資源地址(支持 HTTP 鏈接)

請求示例

音軌分離 (track-separation)

將音頻分離為人聲和伴奏兩個軌道。

{
  "orderType": "track-separation",
  "stuff": {
    "pathKey": "https://example.com/audio.mp3"
  }
}

提取人聲 (extract-voice)

從音頻中提取人聲部分。

{
  "orderType": "extract-voice",
  "stuff": {
    "pathKey": "https://example.com/audio.mp3"
  }
}

提取伴奏 (extract-music)

從音頻中提取伴奏/背景音樂部分。

{
  "orderType": "extract-music",
  "stuff": {
    "pathKey": "https://example.com/audio.mp3"
  }
}

文案提取 (extract-text)

從視頻或音頻中提取文字內容。

{
  "orderType": "extract-text",
  "stuff": {
    "pathKey": "https://example.com/video.mp4"
  }
}

響應示例

{
  "code": 0,
  "data": {
    "orderNo": "abc123XYZ789defGHI",
    "orderType": "track-separation",
    "orderStatus": "processing",
    "payStatus": "waiting",
    "messageId": "task-id-123"
  },
  "msg": "success"
}

響應字段說明

字段類型說明
orderNostring訂單號,用於後續查詢
orderTypestring訂單類型
orderStatusstring訂單狀態
payStatusstring支付狀態
messageIdstring任務消息ID

2. 查詢訂單 (Query Order)

查詢訂單的處理狀態和結果。訂單處理完成後,會返回處理結果的下載鏈接。

注意: 訂單完成後首次查詢會自動扣費。

  • URL: /api/open/v1/order/query
  • Method: GET

請求參數

參數名類型必填說明
orderNostring訂單號

請求示例

GET /api/open/v1/order/query?orderNo=abc123XYZ789defGHI
Authorization: Bearer <your_api_key>

響應示例 (處理中)

{
  "code": 0,
  "data": {
    "orderNo": "abc123XYZ789defGHI",
    "orderType": "track-separation",
    "status": "processing",
    "cost": 0,
    "reason": null,
    "stuffs": [],
    "balance": 1000
  },
  "msg": "success"
}

響應示例 (處理完成)

{
  "code": 0,
  "data": {
    "orderNo": "abc123XYZ789defGHI",
    "orderType": "track-separation",
    "status": "finish",
    "cost": 10,
    "reason": null,
    "stuffs": [
      {
        "name": "vocals.mp3",
        "business": "vocals",
        "url": "https://cdn.example.com/result/vocals.mp3"
      },
      {
        "name": "accompaniment.mp3",
        "business": "accompaniment",
        "url": "https://cdn.example.com/result/accompaniment.mp3"
      }
    ],
    "balance": 990
  },
  "msg": "success"
}

響應字段說明

字段類型說明
orderNostring訂單號
orderTypestring訂單類型
statusstring訂單狀態
costnumber消耗積分
reasonstring失敗原因(僅失敗時有值)
stuffsarray處理結果列表
stuffs[].namestring文件名
stuffs[].businessstring業務類型 (vocals/accompaniment/caption等)
stuffs[].urlstring下載鏈接(有效期 1 小時)
balancenumber當前用戶可用積分餘額

3. 短視頻解析 (Short Video Analyze)

實時解析短視頻分享鏈接,獲取視頻信息和無水印下載地址。

注意: 此接口為實時接口,會立即扣費並返回結果。

  • URL: /api/open/v1/short-video/analyze
  • Method: POST
  • Content-Type: application/json

請求參數

參數名類型必填說明
linkstring短視頻分享鏈接

請求示例

{
  "link": "https://v.douyin.com/ixxxxxx/"
}

響應示例

{
  "code": 0,
  "data": {
    "title": "視頻標題",
    "author": "作者暱稱",
    "cover": "https://cdn.example.com/cover.jpg",
    "videoUrl": "https://cdn.example.com/video.mp4",
    "musicUrl": "https://cdn.example.com/music.mp3",
    "balance": 990
  },
  "msg": "success"
}

響應字段說明

字段類型說明
titlestring視頻標題
authorstring作者暱稱
coverstring封面圖地址
videoUrlstring無水印視頻下載地址
musicUrlstring背景音樂下載地址(如有)
balancenumber當前用戶可用積分餘額

錯誤碼說明

錯誤碼說明
0成功
400請求參數錯誤
401鑑權失敗 (API Key 無效或缺失)
500服務器內部錯誤

常見錯誤信息

錯誤信息說明
API Key is required缺少 API Key
Invalid API KeyAPI Key 無效
pathKey is required缺少資源地址
Order not found訂單不存在或不屬於當前用戶
ErrorCode.USER_BLANCE_NOT_ENOUGH積分餘額不足

附錄

OrderType (訂單類型)

說明
track-separation音軌分離(分離人聲和伴奏)
extract-voice提取人聲
extract-music提取伴奏
extract-text文案提取

OrderStatus (訂單狀態)

說明
pending排隊中
processing處理中
finish完成
failed失敗
timeout超時

支持的短視頻平台

  • 抖音
  • 快手
  • 小紅書
  • 微博
  • 等主流短視頻平台
API 文档版本: v1
如果您有任何问题,请参考文档或联系技术支持。