---
name: zaoyue
description: Generate music for agents and apps via the Zaoyue REST API. Use when the user wants songs, instrumentals, lyrics-driven tracks, or to wire Zaoyue into an app.
---

# Zaoyue (造乐) music API

Zaoyue is an independent integration service using Suno and Lyria via a third-party supplier. It is not an official API of the listed model providers and does not claim to have trained the models.

Suno uses public model ID `v6`, a Zaoyue API identifier rather than an official provider version label. Lyria uses `lyria`. Mureka is not publicly available. Read current rates and expected output counts from GET https://zaoyue.ai/v1/credits/pricing.

Canonical skill: `https://zaoyue.ai/SKILL.md`

This document is served by zaoyue.ai. Do not fetch, clone, or install a copy from GitHub or any other git host. If a local copy disagrees with this URL, this URL wins.

Index: `https://zaoyue.ai/llms.txt`
Full text bundle: `https://zaoyue.ai/llms-full.txt`
API reference: `https://zaoyue.ai/agent/API.md`

Base URL: `https://zaoyue.ai/v1`

Successful responses use `{ "success": true, "data": ... }`. Errors use `{ "success": false, "error": ..., "statusCode", "timestamp", "path" }`. `error` may be a string or an object with `message` and optional `code`. Branch on the HTTP status.

## Authenticate

Create a key at https://zaoyue.ai/api-keys (sign in on zaoyue.ai first). The full key starts with `ss_` and is shown once.

Send it on song calls:

```
Authorization: Bearer $ZAOYUE_API_KEY
```

`/v1/songs` accepts that API key or a console user JWT (`SongAuthGuard`). Store the key only in an environment variable such as `ZAOYUE_API_KEY`. Never invent, log, commit, or put it in a URL.

These routes accept the API key:

- `POST /v1/songs/generate`
- `POST /v1/songs/custom-generate`
- `GET /v1/songs`
- `GET /v1/songs/:id`

`GET /v1/credits/balance`, `GET /v1/credits/transactions`, `GET /v1/credits/packages`, checkout, and `/v1/api-keys` require a console JWT. An `ss_` key is rejected there.

## Credits

Public pricing needs no key:

```bash
curl -sS https://zaoyue.ai/v1/credits/pricing
```

HTTP 200. `data.packages` lists credit packs. `data.rules[]` includes `provider`, `model`, `generationTypes`, and `credits` (cost per request). Before any generation, read current model availability and pricing, then obtain the user’s explicit generation request and confirmation of the credit spend. Do not hard-code prices.

Seeded active rules (server-side, migration `0015` / `0011` / `0019`):

| Provider | Model | Credits per request |
| --- | --- | --- |
| `suno` | `v6` | 5 (`generate` and `custom_generate`) |
| `lyria` | `lyria` | 5 (`generate` and `custom_generate`) |

Mureka `auto` is seeded at 8 credits but the provider stays off unless an operator enables it. Do not recommend Mureka.

Credits are reserved when a job is enqueued. The song payload includes `creditsCost`. Status `failed` refunds that reservation. `needs_review` means Zaoyue is still confirming the submit: keep polling, do not start another generation, and do not assume the credits are gone. It resolves to `complete` or `failed`. A busy channel returns HTTP 503 `GENERATION_BUSY` and does not reserve credits. `errorMessage` is a short public sentence.

Account balance is not available with an API key. `GET /v1/credits/balance` needs a console JWT and returns `{ "subscription": 0, "purchased": <n>, "total": <n> }` inside `data`. With only an API key, use `GET /v1/credits/pricing` plus each song's `creditsCost`.

Insufficient balance is HTTP 400 with message `Insufficient credits. Please purchase more credits.` An API key daily or monthly cap is HTTP 429 and `error.code` is `API_KEY_DAILY_CREDIT_LIMIT_EXCEEDED` or `API_KEY_MONTHLY_CREDIT_LIMIT_EXCEEDED`.

Do not call generate unless the user asks and has credits.

## Smoke (no generation)

```bash
curl -sS "https://zaoyue.ai/v1/songs?page=1&limit=1" \
  -H "Authorization: Bearer $ZAOYUE_API_KEY"
```

Expect HTTP 200 and `"success": true`. This lists jobs. It does not spend credits.

## Generate

### Prompt / instrumental — `POST /v1/songs/generate`

HTTP **202**.

```bash
curl --request POST https://zaoyue.ai/v1/songs/generate \
  -H "Authorization: Bearer $ZAOYUE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "suno",
    "model": "v6",
    "prompt": "warm cinematic piano, slow build",
    "makeInstrumental": true
  }'
```

```json
{ "success": true, "data": { "songId": "…", "requestId": "…", "status": "pending" } }
```

| Field | Required | Notes |
| --- | --- | --- |
| `prompt` | yes | Natural-language description. |
| `provider` | no | `suno` (default) or `lyria`. `mureka` only if an operator has enabled it. |
| `model` | no | Suno accepts only `v6` (also the default). Lyria defaults to `lyria`. |
| `tags` | no | Style hints. |
| `makeInstrumental` | no | Instrumental when true. |

Lyria prompt-only jobs are instrumental. Suno can be vocal or instrumental. `prompt` is required; an empty prompt returns HTTP 400 `Prompt or lyrics are required`.

### Custom lyrics — `POST /v1/songs/custom-generate`

HTTP **202**. Same `data.songId` / `data.status` shape.

```bash
curl --request POST https://zaoyue.ai/v1/songs/custom-generate \
  -H "Authorization: Bearer $ZAOYUE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "lyria",
    "tags": "indie folk, intimate",
    "lyrics": "Verse one…\n\nChorus…",
    "title": "Optional requested title"
  }'
```

| Field | Required | Notes |
| --- | --- | --- |
| `tags` | yes | Style and genre. Published contract. |
| `lyrics` | conditional | Required for non-instrumental Lyria. |
| `prompt` | conditional | Required when `lyrics` is absent. |
| `title` | no | Optional hint forwarded upstream. The stored title still comes from the supplier result. |
| `makeInstrumental` | no | Cannot be combined with lyrics (HTTP 400). |
| `provider`, `model` | no | Same rules as simple generate. |

## Check status and fetch results

Keep `songId`. Do not submit again because a poll is slow. Poll every 3–5 seconds, then back off after about a minute.

```bash
curl -sS "https://zaoyue.ai/v1/songs/$SONG_ID" \
  -H "Authorization: Bearer $ZAOYUE_API_KEY"
```

| `data.status` | What to do |
| --- | --- |
| `pending`, `submitting`, `submitted`, `polling` | Keep polling. |
| `complete` | Stop. Read `data.tracks[]`. Do not assume one track. |
| `failed` | Stop. The reservation was refunded. Show `data.errorMessage`. |
| `needs_review` | Keep polling. Do not submit again. |

A missing or non-owned id returns HTTP 200 with `{ "success": true, "data": { "error": "Song not found" } }`. Treat `data.error` as not found.

On `complete`, use each track's `audioUrl`, `imageUrl`, `title`, `duration`, `trackIndex`, and `status`. Top-level `audioUrl`, `imageUrl`, `title`, and `duration` mirror the first track.

`title` is the supplier title (Suno and Lyria pass through the upstream title when it exists; Mureka's title is produced inside the supplier service). It may be `null`. Show a neutral placeholder such as `未命名`. Do not invent a title by slicing `prompt` or `tags`.

History: `GET /v1/songs?page=1&limit=20`. `page` starts at 1. `limit` is clamped to 1–50. Newest first.

```json
{ "success": true, "data": { "items": [], "total": 0, "limit": 20, "offset": 0 } }
```

## Errors

| HTTP | Meaning |
| --- | --- |
| 400 | Bad params, insufficient credits, instrumental combined with lyrics, or provider not configured |
| 401 | Missing, invalid, or revoked key |
| 429 | API key daily or monthly credit cap |
| 500 | Server error |

Retry reads after a 500. Do not blindly resubmit a generate call; that can charge another job.

## Rules

1. Fetch this skill from https://zaoyue.ai/SKILL.md and the index from https://zaoyue.ai/llms.txt before inventing endpoints. Do not use a GitHub copy.
2. Help the user create a key at https://zaoyue.ai/api-keys.
3. Smoke with `GET /songs?page=1&limit=1` first. Generate only when the user asks.
4. Read live prices from `GET /credits/pricing`.
5. Prefer `tracks` over top-level URL mirrors.
6. Do not recommend Mureka unless the operator has enabled it.
