> ## Documentation Index
> Fetch the complete documentation index at: https://apixo.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Suno API：生成带人声和歌词的 AI 音乐

> AI 音乐生成 API，用于使用 Suno V6 模式根据文本提示或自定义歌词创作声乐和器乐歌曲。

## 概览

Suno 可以根据文字描述或按段落编排的歌词，生成完整的音乐作品。在 APIXO Playground 试用后，可以按本页示例调用 API。

| 功能 | 值 |
| - | - |
| 模型 ID | `suno` |
| 输出 | 带有封面图片的音轨 |
| 交付 | 异步轮询或 webhook 回调 |
| 支持的模式 | `V6`, `V6_MINI`, `V6_WILD` |
| 非自定义提示长度 | 1 至 500 个字符 |
| 自定义提示长度 | 1 至 5000 个字符 |
| 定制款式长度 | 最多 1000 个字符 |

## V6 迁移和传统模式兼容性

目前只有 V6 模式系列可用于新集成。在新请求中使用 `V6`、`V6_MINI` 或 `V6_WILD`。

所有 V3、V4 和 V5 模式均已停用。为了保持现有集成的兼容性，在处理任务之前接受并映射已停用的模式，如下所示：

| 退休模式已提交 | 用于任务的模式 |
| - | - |
| `V3.5`, `V3_5`, `V4.5 All`, `V4_5ALL` | `V6_MINI` |
| 任何其他 V3、V4 或 V5 模式或别名 | `V6` |

将客户端更新为 V6 模式之一。兼容性行为适用于现有请求，不会使已停用模式支持新集成的值。

## 接口与身份验证

API 基础地址：

```text theme={null}
https://api.apixo.ai/api/v1
```

| 方法 | 端点 | 用途 |
| - | - | - |
| `POST` | `/generateTask/suno` | 提交音乐生成任务 |
| `GET` | `/statusTask/suno?taskId={taskId}` | 查询任务状态并获取结果 |

每个请求都必须携带 APIXO API 密钥：

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

提交任务时，还需要设置以下请求头：

```http theme={null}
Content-Type: application/json
```

## 异步请求示例

此最小请求提交一个简单的文本到音乐任务并返回 `taskId`。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/suno" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "V6",
      "prompt": "upbeat pop song about a summer road trip",
      "customMode": false,
      "instrumental": false
    }
  }'
```

成功响应：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
```

保存 `taskId`，后续轮询结果时需要用到它。

## 轮询结果

```bash theme={null}
curl -X GET "https://api.apixo.ai/api/v1/statusTask/suno?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

任务处理中的响应示例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "processing",
    "createTime": 1767965610929
  }
}
```

成功响应：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[{\"audio_url\":\"https://file.apixo.ai/track1.mp3\",\"image_url\":\"https://file.apixo.ai/cover1.jpg\"},{\"audio_url\":\"https://file.apixo.ai/track2.mp3\",\"image_url\":\"https://file.apixo.ai/cover2.jpg\"}]}",
    "lyrics": "[Verse 1]\nRolling down the highway...",
    "createTime": 1767965610929,
    "completeTime": 1767965700929,
    "costTime": 90000
  }
}
```

任务失败时的响应示例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "PromptInvalid",
    "failMsg": "Prompt is invalid or rejected",
    "createTime": 1767965610929,
    "completeTime": 1767965620132,
    "costTime": 9203
  }
}
```

等 `state` 变为 `success` 后，再解析 `resultJson`：

```javascript theme={null}
const payload = JSON.parse(data.resultJson);
const tracks = payload.resultUrls;

for (const track of tracks) {
  console.log(track.audio_url, track.image_url);
}
```

> [!WARNING]
>
> Suno `resultJson` 包含 `resultUrls` 作为对象数组。每个项目可以包含 `audio_url` 用于生成的 MP3 和 `image_url` 用于封面图片。不要将其解析为纯字符串 URL 数组。

## 请求体

### 简单模式

使用 `customMode: false` 时，Suno 将根据简短描述生成歌曲。

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "V6",
    "prompt": "upbeat pop song about a summer road trip",
    "customMode": false,
    "instrumental": false
  }
}
```

### 自定义歌词模式

当您希望提供歌词、风格和标题时，请使用 `customMode: true`。

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "V6_WILD",
    "prompt": "[Verse 1]\nWalking down an empty street\nEchoes of your laughter sweet\n\n[Chorus]\nI miss you more than words can say",
    "customMode": true,
    "instrumental": false,
    "style": "orchestral, emotional, film score",
    "title": "Dawn of Hope",
    "vocalGender": "f",
    "styleWeight": 0.6,
    "weirdnessConstraint": 0.2,
    "audioWeight": 0.5,
    "negativeTags": "noise, distortion"
  }
}
```

### 器乐模式

当您希望生成无人声的音乐时，请设置 `instrumental: true`。

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "V6_WILD",
    "prompt": "cinematic orchestral track with gentle piano and strings",
    "customMode": true,
    "instrumental": true,
    "style": "orchestral, cinematic, ambient",
    "title": "Peaceful Morning",
    "styleWeight": 0.7
  }
}
```

## 参数

**request\_type** `string` (default: async)

结果获取方式。选择 `async` 时，通过 `statusTask` 轮询结果；选择 `callback` 时，通过 Webhook 接收结果。

**callback\_url** `string`

当`request_type`为`callback`时必需。必须是可接收任务负载的公开 HTTPS URL。请参阅 [Webhooks](https://apixo.ai/docs/zh/api-reference/webhooks.md)。

**input** `object` *required*

Suno 的输入参数。

**属性**

**mode** `string` *required*

Suno 生成模式，可设为 `V6`、`V6_MINI` 或 `V6_WILD`。已停用的 V3、V4 和 V5 模式仍可按[迁移到 V6 与旧模式兼容说明](#v6-migration-and-legacy-mode-compatibility)中的规则调用。

**prompt** `string` *required*

歌曲描述或歌词。必须是非空字符串。非自定义模式下，支持1-500个字符；自定义模式下，支持1-5000个字符。

**customMode** `boolean` *required*

支持的值：`true` 表示自定义歌词模式，`false` 表示歌曲描述。自定义歌词模式需提供风格和标题。

**instrumental** `boolean` *required*

是否生成不含人声的纯器乐曲。

**style** `string`

自定义歌词模式下必需。音乐风格描述，最多1000个字符。

**title** `string`

自定义歌词模式下必需。歌曲标题，最多80个字符。

**vocalGender** `string`

可选的声音性别提示。支持的值：`m` 为男声，`f` 为女声。

**styleWeight** `number`

可选的样式强度，范围为 `0` 到 `1`。

**weirdnessConstraint** `number`

可选的创造力约束，范围为 `0` 到 `1`。

**audioWeight** `number`

可选的音频权重，范围为 `0` 到 `1`。

**negativeTags** `string`

可选的负标签，最多 200 个字符。

## 响应格式

### 提交任务时的响应

任务受理后，`POST /generateTask/suno` 会返回任务 ID：

**code** `integer`

API 状态码。`200` 表示任务已受理。

**message** `string`

状态说明。

**data.taskId** `string`

任务的唯一 ID，用于查询任务状态。

### 状态响应字段

**taskId** `string`

任务的唯一标识符。

**state** `string`

当前任务状态，可能的值为 `pending`、`processing`、`success`、`failed`。

**resultJson** `string`

包含生成的音频对象的 JSON 字符串。当 `state` 为 `success` 时存在。

**lyrics** `string`

结果中包含歌词或提示文本。仅在可用时提供。

**failCode** `string`

供程序处理的错误码，仅在 `state` 为 `failed` 时返回。

**failMsg** `string`

失败原因说明，仅在 `state` 为 `failed` 时返回。

**createTime** `integer`

任务创建时的 Unix 时间戳，单位为毫秒。

**completeTime** `integer`

任务完成时的 Unix 时间戳，单位为毫秒。任务完成后返回。

**costTime** `integer`

处理耗时，单位为毫秒。任务完成且有该数据时返回。

解析的`resultJson`结构：

```json theme={null}
{
  "resultUrls": [
    {
      "audio_url": "https://file.apixo.ai/track1.mp3",
      "image_url": "https://file.apixo.ai/cover1.jpg"
    },
    {
      "audio_url": "https://file.apixo.ai/track2.mp3",
      "image_url": "https://file.apixo.ai/cover2.jpg"
    }
  ]
}
```

| 每个项目中的字段 | 类型 | 说明 |
| - | - | - |
| `audio_url` | string | 生成 MP3 音频文件 URL |
| `image_url` | string | 生成的封面图像 URL |

## Webhook 回调模式

当您的后端应自动接收任务负载而不是轮询时，请使用回调模式。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/suno" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "callback",
    "callback_url": "https://your-server.com/webhooks/apixo",
    "input": {
      "mode": "V6",
      "prompt": "warm acoustic song about coming home",
      "customMode": false,
      "instrumental": false
    }
  }'
```

只解析 `resultJson` 当回调有效负载有 `state: "success"`。看 [Webhook](https://apixo.ai/docs/zh/api-reference/webhooks.md) 用于交付要求和重试行为。

## 计费

新提交的非 LLM 请求按 **1 积分 = `$0.001`** 计费。先按用量和附加项目计算总额，再应用账号折扣，最后将请求总额向上取整到整数积分。如果约定了固定单价，则按该单价的原始精度计算，不再使用标准价或另行打折；最终积分仍向上取整。详见[积分换算与取整](https://apixo.ai/docs/zh/pricing.md#credit-conversion-and-rounding)。

Suno 按生成请求计费。当前公开的 APIXO 目录将 Suno 列为 `$0.18 / use`。

| 模型 | 路线 | APIXO 价格 | 单位 |
| - | - | - | - |
| Suno V6 | 独家的 | `$0.18` | 每次使用 |
| SunoV6迷你 | 独家的 | `$0.18` | 每次使用 |
| Suno V6 百搭 | 独家的 | `$0.18` | 每次使用 |

有关当前定价，请参阅 [API 定价](https://apixo.ai/pricing/api)。

## 延迟与轮询

实际延迟可能因提示复杂性、所选模式、提供程序队列和当前负载而异。

| 工作流程 | 通常生成耗时 | 建议首次查询时间 | 轮询间隔 |
| - | - | - | - |
| Suno 音乐一代 | 60s-90s | 任务创建 60 秒后 | 60s |

> [!TIP]
>
> 对于生产工作负载，使用回调模式来减少轮询流量。结果 URL 默认存储 15 天；帐户级存储设置可能会更改保留期限。

如果收到 `429`，请放慢请求速度并通过退避重试。有关帐户级别的详细信息，请参阅 [系统 API](https://apixo.ai/docs/zh/api-reference/system.md)。

## 错误与排查

### HTTP 错误

| 代码 | 含义 | 处理方式 |
| - | - | - |
| `400` | 缺少必需参数、参数类型无效、值无效或超出长度 | 在重试前修复请求 |
| `401` | 缺少 API 密钥，或密钥无效 | 检查 `Authorization` 请求头 |
| `402` | 余额不足 | 重试前需添加余额 |
| `422` | 计费计算失败 | 如果该模型应在您的帐户上可用，请联系支持人员 |
| `429` | 已达到速率或并发限制 | 按指数退避策略重试 |
| `500` | 服务器错误或未知任务失败 | 逐步延长间隔后重试 |
| `502` | 服务或网络错误 | 逐步延长间隔后重试 |
| `504` | 服务超时 | 重试；耗时较长的任务可改用回调模式 |

### 任务失败字段

当任务到达 `state: "failed"` 时，检查状态响应中的 `failCode` 和 `failMsg`。

| 失败代码示例 | 含义 | 处理方式 |
| - | - | - |
| `PromptInvalid` | 提示被拒绝或格式错误 | 重写提示或歌词 |
| `SensitiveContent` / `SensitiveContentDetected` | 提示或输出被安全检查标记 | 更改提示、歌词或风格 |
| `MissingParameter` | 该服务报告缺少所需数据 | 检查`mode`、`prompt`、`customMode`、`instrumental`和自定义模式字段 |
| `RateLimited` / `RateLimitExceeded` | 请求频率达到上限 | 逐步延长间隔后重试 |
| `Timeout` | 任务超时 | 稍后重试或使用回调模式 |
| `Unknown error` | 任务因未知原因失败 | 重试并退避；如果重复出现，请联系支持人员 |

完整列表见[错误码](https://apixo.ai/docs/zh/api-reference/errors.md)。

## MCP 集成

[完整模型 Schema](https://apixo.ai/docs/models/schemas/audio/suno.json) 中的 `mcp.result` 指定了结果的解析方式，`mcp.attachments` 列出支持绑定文件的字段。这些元数据供客户端集成使用，无需作为生成参数提交。API 负责校验模型参数。

## 相关链接

* [生成 API 概览](https://apixo.ai/docs/zh/models.md)
* [音频模型](https://apixo.ai/docs/zh/models/audio)
* [提交生成任务](https://apixo.ai/docs/zh/api-reference/generate-task.md)
* [查询任务状态](https://apixo.ai/docs/zh/api-reference/status-task.md)
* [Webhook](https://apixo.ai/docs/zh/api-reference/webhooks.md)
* [错误码](https://apixo.ai/docs/zh/api-reference/errors.md)
* [参数规范](https://apixo.ai/docs/zh/api-reference/parameters.md)
* [路由策略](https://apixo.ai/docs/zh/concepts/routing-strategies.md)
* [尝试 Suno 在 APIXO Playground](https://apixo.ai/models/suno)
* [API定价](https://apixo.ai/pricing/api)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.