跳转到主要内容
POST
/
api
/
v1
/
wav
/
generate
转换为WAV格式
curl --request POST \
  --url https://api.sunoapi.org/api/v1/wav/generate \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "taskId": "5c79****be8e",
  "audioId": "e231****-****-****-****-****8cadc7dc",
  "callBackUrl": "https://api.example.com/callback"
}
'
import requests

url = "https://api.sunoapi.org/api/v1/wav/generate"

payload = {
    "taskId": "5c79****be8e",
    "audioId": "e231****-****-****-****-****8cadc7dc",
    "callBackUrl": "https://api.example.com/callback"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    taskId: '5c79****be8e',
    audioId: 'e231****-****-****-****-****8cadc7dc',
    callBackUrl: 'https://api.example.com/callback'
  })
};

fetch('https://api.sunoapi.org/api/v1/wav/generate', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.sunoapi.org/api/v1/wav/generate",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'taskId' => '5c79****be8e',
    'audioId' => 'e231****-****-****-****-****8cadc7dc',
    'callBackUrl' => 'https://api.example.com/callback'
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.sunoapi.org/api/v1/wav/generate"

	payload := strings.NewReader("{\n  \"taskId\": \"5c79****be8e\",\n  \"audioId\": \"e231****-****-****-****-****8cadc7dc\",\n  \"callBackUrl\": \"https://api.example.com/callback\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.sunoapi.org/api/v1/wav/generate")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"taskId\": \"5c79****be8e\",\n  \"audioId\": \"e231****-****-****-****-****8cadc7dc\",\n  \"callBackUrl\": \"https://api.example.com/callback\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.sunoapi.org/api/v1/wav/generate")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"taskId\": \"5c79****be8e\",\n  \"audioId\": \"e231****-****-****-****-****8cadc7dc\",\n  \"callBackUrl\": \"https://api.example.com/callback\"\n}"

response = http.request(request)
puts response.read_body
{
  "msg": "success",
  "data": {
    "taskId": "5c79****be8e"
  }
}

使用指南

  • 提供 taskId 或 audioId 来标识源音轨
  • WAV格式适合专业音频编辑和制作
  • 转换过程保留完整音频质量

开发者注意事项

  1. 生成的WAV文件将保留15天
  2. WAV文件比MP3文件大得多
  3. 此格式推荐用于进一步音频处理或专业用途
  4. 回调在转换完成时提供单个下载URL

授权

Authorization
string
header
必填

🔑 API 认证说明

所有接口都需要通过 Bearer Token 方式进行认证。

获取 API Key

  1. 访问 API Key 管理页面 获取您的 API Key

使用方式

在请求头中添加:

Authorization: Bearer YOUR_API_KEY

⚠️ 注意:

  • 请妥善保管您的 API Key,不要泄露给他人
  • 如果怀疑 API Key 泄露,请立即在管理页面重置

请求体

application/json
taskId
string
必填

音乐生成任务的任务ID。

示例:

"5c79****be8e"

audioId
string
必填

要转换的特定音轨的音频ID。

  • 提供特定的 audioId 确保转换确切的音轨,特别是当一个任务有多个音轨时。
示例:

"e231****-****-****-****-****8cadc7dc"

callBackUrl
string<uri>
必填

接收WAV转换完成通知的URL。

  • 必填。
  • 回调包含转换后的WAV文件的单个下载URL。
  • 详细的回调格式和实现指南,请参见 WAV格式转换回调
  • 或者,您也可以使用获取WAV转换详情接口来轮询任务状态
示例:

"https://api.example.com/callback"

回调

POST
{$request.body#/callBackUrl}wavGenerated

请求体

application/json
code
integer

状态码

示例:

200

msg
string

返回消息

示例:

"success"

data
object

响应

200

回调接收成功

响应

请求成功

code
enum<integer>

状态码

  • ✅ 200 - 请求成功
  • ⚠️ 400 - 无效参数
  • ⚠️ 401 - 未授权访问
  • ⚠️ 404 - 无效的请求方法或路径
  • ⚠️ 405 - 超出速率限制
  • ⚠️ 409 - 冲突 - WAV记录已存在
  • ⚠️ 413 - 主题或提示词过长
  • ⚠️ 429 - 积分不足
  • ⚠️ 430 - 您的调用频率过高,请稍后重试
  • ⚠️ 455 - 系统维护中
  • ❌ 500 - 服务器错误
可用选项:
200,
400,
401,
404,
405,
409,
413,
429,
430,
455,
500
msg
string

Error message when code != 200

示例:

"success"

data
object