> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.beatapi.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.beatapi.io/_mcp/server.

# Lyria 3.5 与 Lyria 3 Pro

> BeatAPI 上的谷歌 Lyria 3.5 和 Lyria 3 Pro——用描述或自己的歌词生成带人声的完整歌曲，可指定时长和节奏，再续写或改写其中一段；每首 $0.07。

[音乐 API](/zh/audio-api) 上的谷歌 Lyria 音乐模型：`POST https://api.beatapi.io/v1/audios/tasks`。描述一首歌、给它你的歌词，或两者都给；指定时长和节奏；之后还可以续写，或改写其中一段。每次调用生成一首歌，固定一个价，与歌曲长度无关。

> **Warning**
>
> **Beta 说明。** Lyria 经第三方线路通过谷歌 Flow Music 提供，不是谷歌自己的官方接口。调用可能排队比平时久或短时不可用，下面的参数也可能调整。失败的任务不扣费。

## 型号

| 型号            | 说明                                        |
| ------------- | ----------------------------------------- |
| `lyria-3.5`   | 谷歌旗舰音乐模型：带丰富人声、歌词对齐和完整编曲的完整歌曲，最长四分钟。推荐使用。 |
| `lyria-3-pro` | 上一代 Lyria，同价。                             |

两个型号共用同一份请求合同和同一张价目表。歌曲为 48 kHz 立体声；主文件是 M4A，同时附带同一首歌的 WAV 和封面图。

## 写一首歌

`prompt` 描述这首歌：曲风、情绪、乐器、人声和结构。`lyrics` 放你自己的歌词，可以用 `[Verse]`、`[Chorus]` 等段落标记。两者给一个或都给；不给 `lyrics` 时由模型写词，在 `prompt` 里写 `instrumental` 表示不要人声。

```bash
curl https://api.beatapi.io/v1/audios/tasks \
  -H "Authorization: Bearer $BEATAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: lyria-song-001" \
  -d '{
    "model": "lyria-3.5",
    "prompt": "Mandopop ballad, warm female vocal, acoustic guitar and soft piano",
    "lyrics": "[Verse]\nThe night wind runs down the alley\n[Chorus]\nWe sing until the morning",
    "duration": 90,
    "bpm": 80
  }'
```

| 字段         | 含义                                           |
| ---------- | -------------------------------------------- |
| `prompt`   | 歌曲描述，最多 5000 字符。                             |
| `lyrics`   | 你的歌词，最多 5000 字符。                             |
| `title`    | 歌名，最多 80 字符。                                 |
| `duration` | 目标时长（秒），1–240。它是给模型的参考，不是硬性限制，见下文。           |
| `bpm`      | 节奏，1–300。                                    |
| `seed`     | 整数种子，0–2147483647。同一请求加同一种子会生成相近的歌，但不保证完全相同。 |

`duration` 和 `bpm` 是给模型的参考，不是硬性限制。实测给了完整歌词（主歌加副歌）、`duration: 90` 的歌出来 93 秒；只给两句副歌、`duration: 40` 的请求，被模型扩写成一首完整的歌，围绕副歌加了新的主歌，长 174 秒。在意时长时请给完整歌词。模型也可能加几句自己的哼唱，比如前奏的和声。一首歌约 30 到 70 秒生成。

## 操作一览

`action` 选择操作，默认 `generate`。每个操作只收自己的字段；多传一个字段返回 `400 bad_request`，报错里会点名该字段。价格为每次调用的美元价。

| `action`          | 作用                    | 必填                                                                                   | 可选                                     | 价格     |
| ----------------- | --------------------- | ------------------------------------------------------------------------------------ | -------------------------------------- | ------ |
| `generate`        | 生成一首新歌。               | `prompt`、`lyrics`，或两者都给                                                              | `title`、`duration`、`bpm`、`seed`        | \$0.07 |
| `extend`          | 从某个时间点续写你的一首 Lyria 歌。 | `source_task_id`（+ `audio_id`）、`prompt`（怎么续）、`continue_at`（秒）                        | `duration`（续多少秒，最多 164）、`title`、`seed` | \$0.07 |
| `replace_section` | 改写你的一首 Lyria 歌的某一段。   | `source_task_id`（+ `audio_id`）、`prompt`（怎么改）、`section_start`、`section_end`（秒，结束晚于开始） | `title`、`seed`                         | \$0.07 |
| `lyrics`          | 只写歌词和配套的风格描述，不出音频。    | `prompt`（最多 3000 字符）                                                                 | 无                                      | \$0.02 |

Suno 专有的字段（`custom_mode`、`style`、`instrumental`、`negative_tags`、`persona_id` 等）和 `audio_url`，Lyria 都不收。

## 对自己的歌继续操作

[通用规则](/zh/audio-api)同样适用；Lyria 的后续操作要指向你自己的 Lyria 任务，`audio_id` 就是该任务的 `output.tracks[0].id`（可以不传）。续写返回的是到 `continue_at` 为止的原曲加上新的部分；改写一段返回的是替换了那一段的整首歌。每次都是新任务，曲目 id 也是新的。

从第 60 秒起续写 30 秒：

```json
{
  "model": "lyria-3.5",
  "action": "extend",
  "source_task_id": "task_9Fh2Lq",
  "continue_at": 60,
  "duration": 30,
  "prompt": "A piano break, then the chorus once more"
}
```

改写第 10 到 20 秒：

```json
{
  "model": "lyria-3.5",
  "action": "replace_section",
  "source_task_id": "task_9Fh2Lq",
  "section_start": 10,
  "section_end": 20,
  "prompt": "Only acoustic guitar in this part"
}
```

先写词，再用 `generate` 唱出来：

```json
{
  "model": "lyria-3.5",
  "action": "lyrics",
  "prompt": "A Mandarin pop song about a summer day by the sea"
}
```

`lyrics` 任务完成后没有文件；`output.data` 里是歌词和风格描述，可以分别作为 `generate` 的 `lyrics` 和 `prompt` 传入：

```json
{
  "lyrics": [
    { "title": "Orange Coast", "text": "[Verse 1]\nIced orange soda, bubbles in the glass\n..." }
  ],
  "style": "Mandopop, summer pop, breezy acoustic guitar riff, light tropical percussion"
}
```

## 任务结果

写歌类操作返回一首曲目。`output.media` 列出三个文件：M4A 格式的歌曲（`audio/mp4`，也在 `output.url` 和 `tracks[0].audio_url` 里）、同一首歌的 WAV，以及封面图（`tracks[0].image_url`）。`tracks[0].lyrics` 是模型实际唱的歌词，包括它加的句子；`tracks[0].duration` 是时长（秒）。

## 错误

| 信息                                                                                                        | 处理方式                                |
| --------------------------------------------------------------------------------------------------------- | ----------------------------------- |
| `generate needs "prompt" (a description of the song), "lyrics", or both`                                  | 传描述、歌词，或两者都传。                       |
| `field "custom_mode" is not supported by model lyria-3.5`                                                 | 这是 Suno 的字段，Lyria 不收。               |
| `"duration" adds at most 164 seconds for action extend`                                                   | 每次最多续写 164 秒，分多次续。                  |
| `"source_task_id" is required for action extend: the id of your own Lyria task that made the song`        | 指明产出这首歌的 Lyria 任务。                  |
| `source_task_id was made by suno-v6, which lyria-3.5 cannot work on; use a suno model for this follow-up` | Suno 的歌要用 Suno 型号操作。                |
| `"section_end" must be after "section_start"`                                                             | 修正段落起止时间。                           |
| `"action" must be one of: [generate extend replace_section lyrics]`                                       | Lyria 只有这四个操作；分轨、翻唱、转 WAV 是 Suno 的。 |

## 价目表

两个型号同价，单位为美元每次调用。30 秒和四分钟的歌一个价。

| 操作                                    | 价格     |
| ------------------------------------- | ------ |
| `generate`、`extend`、`replace_section` | \$0.07 |
| `lyrics`                              | \$0.02 |