v1
API 文檔
音子AI开放平台 API 文档,提供完整的接口说明和使用示例
文档说明
本文档描述了音子AI开放平台 API 的使用方法。开发者可以通过 API 进行订单创建、查询等操作。 所有接口均需要通过 apiKey 进行鉴权。
開放平台 API 文檔 (v1)
本文檔描述了音子AI開放平台 API 的使用方法。開發者可以通過 API 進行訂單創建、查詢等操作。
鑑權 (Authentication)
所有接口均需要通過 apiKey 進行鑑權。系統將根據 apiKey 識別用戶,而不依賴 Session 或 Token。
您可以在"個人中心" -> "API Key" 中獲取您的密鑰。
鑑權方式支持以下兩種:
-
Header 鑑權 (推薦)
Authorization: Bearer <your_api_key> -
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
請求參數
| 參數名 | 類型 | 必填 | 說明 |
|---|---|---|---|
| orderType | string | 是 | 訂單類型,見下文枚舉 |
| stuff | object | 是 | 素材信息 |
| stuff.pathKey | string | 是 | 資源地址(支持 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"
}
響應字段說明
| 字段 | 類型 | 說明 |
|---|---|---|
| orderNo | string | 訂單號,用於後續查詢 |
| orderType | string | 訂單類型 |
| orderStatus | string | 訂單狀態 |
| payStatus | string | 支付狀態 |
| messageId | string | 任務消息ID |
2. 查詢訂單 (Query Order)
查詢訂單的處理狀態和結果。訂單處理完成後,會返回處理結果的下載鏈接。
注意: 訂單完成後首次查詢會自動扣費。
- URL:
/api/open/v1/order/query - Method:
GET
請求參數
| 參數名 | 類型 | 必填 | 說明 |
|---|---|---|---|
| orderNo | string | 是 | 訂單號 |
請求示例
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"
}
響應字段說明
| 字段 | 類型 | 說明 |
|---|---|---|
| orderNo | string | 訂單號 |
| orderType | string | 訂單類型 |
| status | string | 訂單狀態 |
| cost | number | 消耗積分 |
| reason | string | 失敗原因(僅失敗時有值) |
| stuffs | array | 處理結果列表 |
| stuffs[].name | string | 文件名 |
| stuffs[].business | string | 業務類型 (vocals/accompaniment/caption等) |
| stuffs[].url | string | 下載鏈接(有效期 1 小時) |
| balance | number | 當前用戶可用積分餘額 |
3. 短視頻解析 (Short Video Analyze)
實時解析短視頻分享鏈接,獲取視頻信息和無水印下載地址。
注意: 此接口為實時接口,會立即扣費並返回結果。
- URL:
/api/open/v1/short-video/analyze - Method:
POST - Content-Type:
application/json
請求參數
| 參數名 | 類型 | 必填 | 說明 |
|---|---|---|---|
| link | string | 是 | 短視頻分享鏈接 |
請求示例
{
"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"
}
響應字段說明
| 字段 | 類型 | 說明 |
|---|---|---|
| title | string | 視頻標題 |
| author | string | 作者暱稱 |
| cover | string | 封面圖地址 |
| videoUrl | string | 無水印視頻下載地址 |
| musicUrl | string | 背景音樂下載地址(如有) |
| balance | number | 當前用戶可用積分餘額 |
錯誤碼說明
| 錯誤碼 | 說明 |
|---|---|
| 0 | 成功 |
| 400 | 請求參數錯誤 |
| 401 | 鑑權失敗 (API Key 無效或缺失) |
| 500 | 服務器內部錯誤 |
常見錯誤信息
| 錯誤信息 | 說明 |
|---|---|
| API Key is required | 缺少 API Key |
| Invalid API Key | API 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
如果您有任何问题,请参考文档或联系技术支持。