---
title: Suno Text-to-Speech | RunAPI
description: 根据描述或准确脚本生成语音，可选声音风格和背景音乐。
url: https://runapi.ai/zh-CN/docs/api/suno/text-to-speech.md
canonical: https://runapi.ai/zh-CN/docs/api/suno/text-to-speech
locale: zh-CN
---

> HTML 版本: https://runapi.ai/zh-CN/docs/api/suno/text-to-speech
> 智能体网站索引: https://runapi.ai/llms.txt

# Suno Text-to-Speech

## 概览

使用支持的模型提交Text to Speech请求。使用返回的 Task ID 查询状态，或提供 callback_url 接收下方列出的投递。

### 快速开始

1. 创建 API Key，并将其设置为 RUNAPI_API_KEY。
2. 选择一个支持的模型，并发送与该模型 Schema 匹配的 POST 请求。
3. 保存返回的任务 ID，随后轮询到终态，或处理下方列出的回调。

## 端点

POST /api/v1/suno/text_to_speech

基础 URL: https://runapi.ai

API 版本: v1

身份验证: Authorization: Bearer YOUR_API_TOKEN

## 支持的模型

打开模型页可查看当前价格、限流和商业使用详情。

- [suno-speech](https://runapi.ai/zh-CN/models/suno/speech)

## 请求 Schema

字段和允许的取值取决于所选模型。提供 callback_url 后，它会收到下方列出的 Task 投递。

### suno-speech

```json
{
  "background_music": {
    "description": "Whether to add background music. Only allowed when custom_mode is true.",
    "enum": [
      true,
      false
    ],
    "type": "boolean"
  },
  "callback_url": {
    "description": "Webhook URL for async notifications.",
    "type": "string"
  },
  "custom_mode": {
    "description": "Required mode switch. False creates a script from prompt; true speaks the supplied script.",
    "enum": [
      true,
      false
    ],
    "required": true,
    "type": "boolean"
  },
  "model": {
    "description": "Model slug.",
    "required": true,
    "type": "string"
  },
  "prompt": {
    "description": "Scene description, trimmed before validation. Required when custom_mode is false; forbidden when true.",
    "length": true,
    "max": 3000,
    "min": 1,
    "type": "string"
  },
  "script": {
    "description": "Text to speak, trimmed before validation. Required when custom_mode is true; forbidden when false.",
    "length": true,
    "max": 5000,
    "min": 1,
    "type": "string"
  },
  "tone": {
    "description": "Tone, rhythm, emotion, and setting, trimmed before validation. Only allowed when custom_mode is true.",
    "length": true,
    "max": 1000,
    "min": 0,
    "type": "string"
  },
  "variety": {
    "description": "Style variety from exact to highly varied. Only allowed when custom_mode is true.",
    "enum": [
      0,
      1,
      2,
      3,
      4
    ],
    "max": 4,
    "min": 0,
    "type": "integer"
  },
  "vocal_gender": {
    "description": "Vocal gender. Only allowed when custom_mode is true.",
    "enum": [
      "male",
      "female"
    ],
    "type": "string"
  }
}
```

#### 条件规则

当列出的全部条件同时匹配时，应用这些要求。

- **当**: `custom_mode` = `false`; **必填**: `prompt`; **不可提供**: `script`, `tone`, `variety`, `vocal_gender`, `background_music`
- **当**: `custom_mode` = `true`; **必填**: `script`; **不可提供**: `prompt`

## 创建已接受

HTTP 202 - POST /api/v1/suno/text_to_speech

### 响应 Schema

```json
{
  "properties": {
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "processing"
      ],
      "type": "string"
    },
    "task_replayed": {
      "type": "boolean"
    }
  },
  "required": [
    "id",
    "status"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 响应示例

```json
{
  "id": "tsk_reference_demo",
  "status": "processing"
}
```

## 轮询处理中

HTTP 200 - GET /api/v1/suno/text_to_speech/:id

### 响应 Schema

```json
{
  "properties": {
    "audios": {
      "items": {
        "properties": {
          "audio_url": {
            "type": "string",
            "x-runapi-generated-media": true
          },
          "duration": {
            "type": "number"
          },
          "id": {
            "type": "string"
          },
          "image_url": {
            "type": "string",
            "x-runapi-generated-media": true
          },
          "lyrics": {
            "type": "string"
          },
          "model_name": {
            "type": "string"
          },
          "stream_audio_url": {
            "type": "string",
            "x-runapi-generated-media": true
          },
          "tags": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "id"
        ],
        "type": "object",
        "unevaluatedProperties": false
      },
      "type": "array"
    },
    "generation_stage": {
      "enum": [
        "text_generated",
        "first_audio_ready"
      ],
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "processing"
      ],
      "type": "string"
    }
  },
  "required": [
    "id",
    "status"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 响应示例

```json
{
  "id": "tsk_reference_demo",
  "status": "processing"
}
```

## 轮询已完成

HTTP 200 - GET /api/v1/suno/text_to_speech/:id

### 响应 Schema

```json
{
  "properties": {
    "audios": {
      "items": {
        "properties": {
          "audio_url": {
            "type": "string",
            "x-runapi-generated-media": true
          },
          "duration": {
            "type": "number"
          },
          "id": {
            "type": "string"
          },
          "image_url": {
            "type": "string",
            "x-runapi-generated-media": true
          },
          "lyrics": {
            "type": "string"
          },
          "model_name": {
            "type": "string"
          },
          "stream_audio_url": {
            "type": "string",
            "x-runapi-generated-media": true
          },
          "tags": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "id"
        ],
        "type": "object",
        "unevaluatedProperties": false
      },
      "type": "array"
    },
    "generation_stage": {
      "enum": [
        "text_generated",
        "first_audio_ready",
        "all_audios_ready",
        "failed"
      ],
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "completed"
      ],
      "type": "string"
    },
    "usage": {
      "properties": {
        "cost": {
          "type": "number"
        }
      },
      "required": [
        "cost"
      ],
      "type": "object",
      "unevaluatedProperties": false
    }
  },
  "required": [
    "id",
    "status",
    "audios",
    "usage"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 响应示例

```json
{
  "audios": [
    {
      "audio_url": "https://file.runapi.ai/reference-speech.mp3",
      "duration": 2.5,
      "id": "speech_reference"
    }
  ],
  "id": "tsk_reference_demo",
  "status": "completed",
  "usage": {
    "cost": 0.05
  }
}
```

## 轮询失败

HTTP 200 - GET /api/v1/suno/text_to_speech/:id

### 响应 Schema

```json
{
  "properties": {
    "error": {
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "failed"
      ],
      "type": "string"
    }
  },
  "required": [
    "id",
    "status",
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 响应示例

```json
{
  "error": "Task processing failed.",
  "id": "tsk_reference_demo",
  "status": "failed"
}
```

## 客户回调：处理中

HTTP 200 - POST callback_url

### 响应 Schema

```json
{
  "properties": {
    "audios": {
      "items": {
        "properties": {
          "audio_url": {
            "type": "string",
            "x-runapi-generated-media": true
          },
          "duration": {
            "type": "number"
          },
          "id": {
            "type": "string"
          },
          "image_url": {
            "type": "string",
            "x-runapi-generated-media": true
          },
          "lyrics": {
            "type": "string"
          },
          "model_name": {
            "type": "string"
          },
          "stream_audio_url": {
            "type": "string",
            "x-runapi-generated-media": true
          },
          "tags": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "id"
        ],
        "type": "object",
        "unevaluatedProperties": false
      },
      "type": "array"
    },
    "generation_stage": {
      "enum": [
        "text_generated",
        "first_audio_ready"
      ],
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "processing"
      ],
      "type": "string"
    }
  },
  "required": [
    "id",
    "status"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 响应示例

```json
{
  "id": "tsk_reference_demo",
  "status": "processing"
}
```

## 客户回调：已完成

HTTP 200 - POST callback_url

### 响应 Schema

```json
{
  "properties": {
    "audios": {
      "items": {
        "properties": {
          "audio_url": {
            "type": "string",
            "x-runapi-generated-media": true
          },
          "duration": {
            "type": "number"
          },
          "id": {
            "type": "string"
          },
          "image_url": {
            "type": "string",
            "x-runapi-generated-media": true
          },
          "lyrics": {
            "type": "string"
          },
          "model_name": {
            "type": "string"
          },
          "stream_audio_url": {
            "type": "string",
            "x-runapi-generated-media": true
          },
          "tags": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "id"
        ],
        "type": "object",
        "unevaluatedProperties": false
      },
      "type": "array"
    },
    "generation_stage": {
      "enum": [
        "text_generated",
        "first_audio_ready",
        "all_audios_ready",
        "failed"
      ],
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "completed"
      ],
      "type": "string"
    },
    "usage": {
      "properties": {
        "cost": {
          "type": "number"
        }
      },
      "required": [
        "cost"
      ],
      "type": "object",
      "unevaluatedProperties": false
    }
  },
  "required": [
    "id",
    "status",
    "audios",
    "usage"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 响应示例

```json
{
  "audios": [
    {
      "audio_url": "https://file.runapi.ai/reference-speech.mp3",
      "duration": 2.5,
      "id": "speech_reference"
    }
  ],
  "id": "tsk_reference_demo",
  "status": "completed",
  "usage": {
    "cost": 0.05
  }
}
```

## 客户回调：失败

HTTP 200 - POST callback_url

### 响应 Schema

```json
{
  "properties": {
    "error": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "properties": {
            "code": {
              "type": "string"
            },
            "limit_cents": {
              "type": "integer"
            },
            "message": {
              "type": "string"
            },
            "reset_at": {
              "format": "date-time",
              "type": [
                "string",
                "null"
              ]
            },
            "used_cents": {
              "type": "integer"
            },
            "window": {
              "enum": [
                "1h",
                "1d",
                "7d",
                "daily",
                "weekly",
                "monthly",
                "lifetime"
              ],
              "type": "string"
            }
          },
          "required": [
            "code",
            "message"
          ],
          "type": "object",
          "unevaluatedProperties": false
        }
      ]
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "failed"
      ],
      "type": "string"
    }
  },
  "required": [
    "id",
    "status",
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 响应示例

```json
{
  "error": {
    "code": "generation_failed",
    "message": "Task processing failed."
  },
  "id": "tsk_reference_demo",
  "status": "failed"
}
```

## 错误

HTTP 401 - POST /api/v1/suno/text_to_speech

### 响应 Schema

```json
{
  "properties": {
    "error": {
      "description": "Human-readable error message.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 响应示例

```json
{
  "error": "Authentication required"
}
```

## 错误

HTTP 401 - GET /api/v1/suno/text_to_speech/:id

### 响应 Schema

```json
{
  "properties": {
    "error": {
      "description": "Human-readable error message.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 响应示例

```json
{
  "error": "Authentication required"
}
```

## 错误

HTTP 400 - POST /api/v1/suno/text_to_speech

### 响应 Schema

```json
{
  "oneOf": [
    {
      "properties": {
        "error": {
          "description": "Human-readable error message.",
          "type": "string"
        }
      },
      "required": [
        "error"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    {
      "properties": {
        "error": {
          "description": "Human-readable validation summary.",
          "type": "string"
        },
        "errors": {
          "additionalProperties": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "description": "Validation messages keyed by public request field, with an array of human-readable strings for each field.",
          "type": "object"
        }
      },
      "required": [
        "error",
        "errors"
      ],
      "type": "object",
      "unevaluatedProperties": false
    }
  ]
}
```

### 响应示例

```json
{
  "error": "Validation failed",
  "errors": {
    "custom_mode": [
      "is required"
    ]
  }
}
```

## 错误

HTTP 402 - POST /api/v1/suno/text_to_speech

### 响应 Schema

```json
{
  "properties": {
    "error": {
      "description": "Human-readable error message.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 响应示例

```json
{
  "error": "Insufficient balance"
}
```

## 错误

HTTP 429 - POST /api/v1/suno/text_to_speech

### 响应 Schema

```json
{
  "properties": {
    "error": {
      "description": "Human-readable error message.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 响应示例

```json
{
  "error": "API key credit limit exceeded"
}
```

## 错误

HTTP 409 - POST /api/v1/suno/text_to_speech

### 响应 Schema

```json
{
  "properties": {
    "error": {
      "description": "Human-readable error message.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 响应示例

```json
{
  "error": "The request uses features that are not supported for the selected model"
}
```

## 错误

HTTP 429 - POST /api/v1/suno/text_to_speech

### 响应 Schema

```json
{
  "properties": {
    "error": {
      "description": "Human-readable error message.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 响应示例

```json
{
  "error": "Rate limit reached. Please retry later."
}
```

## 错误

HTTP 503 - POST /api/v1/suno/text_to_speech

### 响应 Schema

```json
{
  "properties": {
    "error": {
      "description": "Human-readable error message.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 响应示例

```json
{
  "error": "Service under maintenance, please try again later"
}
```

## 错误

HTTP 503 - POST /api/v1/suno/text_to_speech

### 响应 Schema

```json
{
  "properties": {
    "error": {
      "description": "Human-readable error message.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 响应示例

```json
{
  "error": "The request timed out"
}
```

## 错误

HTTP 404 - GET /api/v1/suno/text_to_speech/:id

### 响应 Schema

```json
{
  "properties": {
    "error": {
      "description": "Human-readable error message.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 响应示例

```json
{
  "error": "Task with id 'tsk_reference_demo' not found"
}
```

## 生成的代码示例

直接使用 cURL，或安装所用语言的 SDK。每个示例都会提交本参考中经过验证的请求。

### curl

```curl
curl -X POST https://runapi.ai/api/v1/suno/text_to_speech \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"model":"suno-speech","custom_mode":true,"script":"Welcome to our morning briefing.","tone":"Warm and calm","variety":1,"vocal_gender":"female","background_music":false}'
```

### javascript

#### 安装

```bash
npm install @runapi.ai/suno
```

```javascript
import { SunoClient } from "@runapi.ai/suno";

const client = new SunoClient({ apiKey: process.env.RUNAPI_API_KEY });
const task = await client.textToSpeech.create({
  "model": "suno-speech",
  "custom_mode": true,
  "script": "Welcome to our morning briefing.",
  "tone": "Warm and calm",
  "variety": 1,
  "vocal_gender": "female",
  "background_music": false
});
```

### python

#### 安装

```bash
pip install runapi-suno
```

```python
import os
from runapi.suno import SunoClient

client = SunoClient(api_key=os.environ["RUNAPI_API_KEY"])
task = client.text_to_speech.create(
  model="suno-speech",
  custom_mode=True,
  script="Welcome to our morning briefing.",
  tone="Warm and calm",
  variety=1,
  vocal_gender="female",
  background_music=False
)
```

### go

#### 安装

```bash
go get github.com/runapi-ai/suno-sdk/go@latest
```

```go
package main

import (
  "context"
  "log"
  "os"

  "github.com/runapi-ai/core-sdk/go/option"
  suno "github.com/runapi-ai/suno-sdk/go/suno"
)

func main() {
  client, err := suno.NewClient(option.WithAPIKey(os.Getenv("RUNAPI_API_KEY")))
  if err != nil {
    log.Fatal(err)
  }

  task, err := client.TextToSpeech.Create(context.Background(), suno.TextToSpeechParams{
    Model: "suno-speech",
    CustomMode: func(value bool) *bool { return &value }(true),
    Script: "Welcome to our morning briefing.",
    Tone: "Warm and calm",
    Variety: func(value int) *int { return &value }(1),
    VocalGender: "female",
    BackgroundMusic: func(value bool) *bool { return &value }(false),
  })
  if err != nil {
    log.Fatal(err)
  }
  _ = task
}
```

### ruby

#### 安装

```bash
gem install runapi-suno
```

```ruby
require "runapi/suno"

client = RunApi::Suno::Client.new(api_key: ENV.fetch("RUNAPI_API_KEY"))
task = client.text_to_speech.create(
  model: "suno-speech",
  custom_mode: true,
  script: "Welcome to our morning briefing.",
  tone: "Warm and calm",
  variety: 1,
  vocal_gender: "female",
  background_music: false
)
```

### java

#### 安装

```kotlin
implementation("ai.runapi:runapi-suno")
```

```java
import ai.runapi.suno.SunoClient;
import ai.runapi.suno.types.TextToSpeechParams;
import ai.runapi.core.polling.TaskCreateResponse;

public final class Example {
  public static void main(String[] args) {
    SunoClient client = SunoClient.builder()
        .apiKey(System.getenv("RUNAPI_API_KEY"))
        .build();
    TaskCreateResponse task = client.textToSpeech().create(
        TextToSpeechParams.builder()
        .model("suno-speech")
        .customMode(true)
        .script("Welcome to our morning briefing.")
        .tone("Warm and calm")
        .variety(1)
        .vocalGender("female")
        .backgroundMusic(false)
            .build()
    );
  }
}
```

### php

#### 安装

```bash
composer require runapi-ai/suno
```

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use RunApi\Core\ClientOptions;
use RunApi\Suno\SunoClient;

$client = new SunoClient(new ClientOptions(apiKey: getenv('RUNAPI_API_KEY')));
$task = $client->textToSpeech->create([
  "model" => "suno-speech",
  "custom_mode" => true,
  "script" => "Welcome to our morning briefing.",
  "tone" => "Warm and calm",
  "variety" => 1,
  "vocal_gender" => "female",
  "background_music" => false
]);
```

## 相关指南

- [API 身份验证](https://runapi.ai/zh-CN/docs/guides/authentication.md)
- [快速开始](https://runapi.ai/zh-CN/docs/guides/task-api/quickstart.md)

---

## RunAPI 的更多内容

- [首页](https://runapi.ai/zh-CN/.md)
- [模型目录](https://runapi.ai/zh-CN/models.md)
- [定价](https://runapi.ai/zh-CN/pricing.md)
- [提供方](https://runapi.ai/zh-CN/models)
- [提示词库](https://runapi.ai/zh-CN/prompts.md)
- [文档](https://runapi.ai/zh-CN/docs/guides)
- [SDK](https://runapi.ai/zh-CN/sdk.md)
- [CLI](https://runapi.ai/zh-CN/cli.md)
- [MCP Server](https://runapi.ai/zh-CN/mcp.md)
- [x402](https://runapi.ai/zh-CN/x402.md)
- [Claude Code 与 Cursor](https://runapi.ai/zh-CN/claude-code-vs-cursor.md)
- [Cursor API 设置](https://runapi.ai/zh-CN/cursor-api-setup.md)
- [RunAPI 与 OpenRouter](https://runapi.ai/zh-CN/openrouter-alternative.md)
- [企业版](https://runapi.ai/zh-CN/contact.md)
- [邀请返利](https://runapi.ai/zh-CN/referral-program.md)
- [联系](https://runapi.ai/zh-CN/contact.md)
- [服务条款](https://runapi.ai/zh-CN/terms.md)
- [隐私政策](https://runapi.ai/zh-CN/privacy.md)
- [智能体网站索引](https://runapi.ai/llms.txt)

联系我们: contact@runapi.ai

## 结构化数据

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-CN",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-CN",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/zh-CN/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-CN",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-CN",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/icon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-CN",
    "@type": "TechArticle",
    "headline": "Suno Text-to-Speech",
    "description": "根据描述或准确脚本生成语音，可选声音风格和背景音乐。",
    "url": "https://runapi.ai/zh-CN/docs/api/suno/text-to-speech",
    "mainEntityOfPage": "https://runapi.ai/zh-CN/docs/api/suno/text-to-speech"
  }
]
```
