# AI music API docs: run YuE by REST and MCP

The YueAI.net API starts the same runs as the bench: YuE (stage 1 `m-a-p/YuE-s1-7B-anneal-en-cot`, stage 2 `m-a-p/YuE-s2-1B-general`), ACE-Step, and the A/B compare of the two. Runs cost the same credits as on the bench and show up in [My runs](https://yueai.net/runs). The base URL is `https://yueai.net/api/v1`.

## Authentication

API keys come with any plan or credit pack. Create one in [Settings → API keys](https://yueai.net/settings/apikeys); the key starts with `sk_` and is shown once. Send it on every request:

```bash
curl https://yueai.net/api/v1/account \
  -H "Authorization: Bearer sk_..."
```

- No key: `401` "Missing API key: send Authorization: Bearer sk\_…".
- A wrong or revoked key: `401`.
- An account with no plan and no pack: `403` "The API comes with any plan or credit pack: see /pricing."

`GET /api/v1/models` is the only endpoint that needs no key.

## Limits

| Access                             | API runs per hour | Runs at once |
| ---------------------------------- | ----------------- | ------------ |
| Bench Run plan, or any credit pack | 10                | 1            |
| Batch Bench plan                   | 60                | 3            |

On top of the hourly limit, a user can start at most one run per second. Going over either limit returns `429` with code `rate_limited`. Starting a run while your parallel runs are all busy returns `429` "A run is already in the works…": wait for one to finish. `GET /api/v1/account` shows where you stand.

## Errors

Every error has the same shape and is sent with `cache-control: private, no-store`:

```json
{
  "error": {
    "message": "max_new_tokens must be 1500, 2000 or 3000.",
    "code": "invalid_tokens"
  }
}
```

`code` is present when there is one. The messages are written for people, so you can show them as they are.

| Status | When                                                                                                                                                                                                           |
| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `400`  | The body is not JSON ("Send a JSON body."), an unknown `engine`, a missing `own_words: true` (code `own_words_required`), a bad `webhook_url`, or a recipe problem (code `invalid_<reason>`, below).           |
| `401`  | Missing, wrong or revoked key.                                                                                                                                                                                 |
| `402`  | Not enough credits (code `insufficient_credits`).                                                                                                                                                              |
| `403`  | No plan or pack on the account.                                                                                                                                                                                |
| `404`  | The run, or the `parent_id`, is not yours or does not exist.                                                                                                                                                   |
| `422`  | The request was refused by screening (code `refused`): lyrics of an existing song, a named artist or band to sound like, or text that breaks the [Acceptable Use Policy](https://yueai.net/acceptable-use). Nothing is charged. |
| `429`  | Rate limit (code `rate_limited`) or all your parallel runs are busy.                                                                                                                                           |
| `503`  | The name check could not answer, or a run could not be checked: retry shortly. Nothing is charged.                                                                                                             |
| `500`  | "Run failed": the run could not be started. Nothing is charged.                                                                                                                                                |

Recipe problems return `400` with code `invalid_<reason>`:

| `reason`           | Meaning                                                                                     |
| ------------------ | ------------------------------------------------------------------------------------------- |
| `genre`            | No genre tags.                                                                              |
| `genre_long`       | Genre text too long.                                                                        |
| `lyrics_short`     | No tagged segment in the lyrics.                                                            |
| `lyrics_long`      | Lyrics over 3,000 characters.                                         |
| `lyrics_tags`      | A segment is not tagged [verse], [chorus], [bridge] or [outro].                             |
| `lyrics_language`  | The lyrics are not English; only the English YuE model is offered.                          |
| `segment_long`     | A segment has more than 16 lines.                                                           |
| `segments`         | `segments` is not a whole number from 1 to 4.                        |
| `segments_missing` | The lyrics have fewer tagged segments than `segments`.                                      |
| `tokens`           | `max_new_tokens` is not one of 1500, 2000 or 3000.                                          |
| `too_many_tokens`  | `segments` × `max_new_tokens` is over the full-run limit of 6,000 tokens. |
| `precision`        | `precision` is not `bf16` or `int8`, or an int8 run is over 3,000 tokens.  |
| `seed`             | `seed` is not a whole number from 0 to 2147483647.                                          |
| `title`            | `title` is longer than 80 characters.                                                       |
| `artist_style`     | The genre or title names an artist or asks for a cover or sound-alike.                      |

## Start a run

`POST /api/v1/runs`

```bash
curl https://yueai.net/api/v1/runs \
  -H "Authorization: Bearer sk_..." \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: night-drive-001" \
  -d '{
    "genre": "synthpop electronic female bright vocal",
    "lyrics": "[verse]\nCity lights are fading slow\nWe keep driving, nowhere to go\n\n[chorus]\nNight drive, night drive\nHold on till the morning light",
    "segments": 2,
    "max_new_tokens": 2000,
    "precision": "bf16",
    "seed": 42,
    "own_words": true,
    "title": "Night drive",
    "webhook_url": "https://example.com/hooks/yueai"
  }'
```

| Field            | Type                     | Notes                                                                                                                                                   |
| ---------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `engine`         | `"yue"` or `"ace-step"`  | Optional; `yue` by default.                                                                                                                             |
| `genre`          | string                   | Space-separated tags: genre, instrument, mood, gender, timbre (the repository's `genre.txt`). `genre_description` is accepted as an alias.              |
| `lyrics`         | string                   | English lyrics in segments tagged [verse], [chorus], [bridge] or [outro] (the repository's `lyrics.txt`). Up to 3,000 characters. |
| `segments`       | integer                  | `--run_n_segments`: how many tagged segments, from the top, are rendered. 1 to 4.                                                |
| `max_new_tokens` | `1500`, `2000` or `3000` | Token budget per segment. `tokens` is accepted as an alias.                                                                                             |
| `precision`      | `"bf16"` or `"int8"`     | `int8` quantises stage 1. It is priced as a full run and must fit 3,000 tokens in total.                                               |
| `seed`           | integer                  | 0 to 2147483647. Leave it out for a random seed; the run records the seed it used.                                                                      |
| `title`          | string                   | Optional, up to 80 characters.                                                                                                                          |
| `parent_id`      | string                   | Optional: one of your runs to re-run or fork. Its recipe and title are the base; any field you send replaces that field.                                |
| `new_seed`       | boolean                  | With `parent_id`: re-run the parent's recipe with a fresh random seed.                                                                                  |
| `webhook_url`    | string                   | Optional: a public https URL with a hostname, under 500 characters, that gets the result. See [Webhooks](#webhooks).                                    |
| `own_words`      | `true`                   | Required. Confirms the lyrics are your own words or that you have the right to use them; without it the call returns `400` `own_words_required`.        |

`segments` × `max_new_tokens` sets the price: up to 3,000 tokens is a run (692 credits), up to 6,000 tokens is a full run (1,232 credits); an int8 run is always a full run. An ACE-Step run costs 92 credits. Heavier settings are refused, not priced higher. Before anything runs, the genre, title and lyrics are screened. Every call must carry `"own_words": true`, the same confirmation the bench asks for.

The answer is `201` with the [run object](#the-run-object), in `running` state:

```json
{
  "data": {
    "id": "...",
    "object": "run",
    "engine": "yue",
    "status": "running",
    "...": "..."
  }
}
```

A run takes several minutes. Poll `GET /api/v1/runs/{id}` or pass a `webhook_url`.

### Idempotency

Send an `Idempotency-Key` header (8 to 128 printable ASCII characters) to make retries safe: the same key returns the same run instead of starting a second one. Without the header, an identical request from the same user within 10 seconds is treated as the same request.

## Start an A/B compare

`POST /api/v1/compare`

Runs one recipe on YuE and on ACE-Step. The body is the same as for a run, without `engine`. The YuE half must be a bf16 run of at most 3,000 tokens. It costs 782 credits.

```bash
curl https://yueai.net/api/v1/compare \
  -H "Authorization: Bearer sk_..." \
  -H "Content-Type: application/json" \
  -d '{"genre":"folk acoustic male warm vocal","lyrics":"[verse]\n...\n\n[chorus]\n...","segments":2,"max_new_tokens":1500,"own_words":true}'
```

```json
{
  "data": {
    "compare_id": "b_...",
    "runs": [
      { "engine": "yue", "...": "..." },
      { "engine": "ace-step", "...": "..." }
    ]
  }
}
```

Each half is its own run: poll each `id`, and each sends its own webhook. If one half fails, only that half's credits come back.

## List and fetch runs

`GET /api/v1/runs?page=1&limit=20`: your runs, newest first. `page` starts at 1; `limit` is 20 by default and at most 50.

`GET /api/v1/runs/{id}`: one run. `404` when it is not yours; `503` "Could not check this run, retry shortly" when its state could not be read.

`GET /api/v1/runs/{id}/audio`: the run's audio file (the run's `audio_url`), `404` until the run has succeeded. Add `?download=1` to get it as an attachment with a file name.

```bash
curl -OJ "https://yueai.net/api/v1/runs/<id>/audio?download=1" \
  -H "Authorization: Bearer sk_..."
```

Audio is deleted after 30 days, so download what you want to keep.

## Export a recipe

`GET /api/v1/runs/{id}/recipe` returns the recipe and the three files of a local run:

```json
{
  "data": {
    "recipe": {
      "model": "...",
      "genre": "...",
      "lyrics": "...",
      "segments": 2,
      "max_new_tokens": 2000,
      "precision": "bf16",
      "seed": 42
    },
    "files": { "genre.txt": "...", "lyrics.txt": "...", "run.sh": "..." }
  }
}
```

`run.sh` clones the YuE repository and calls `infer.py` with the same arguments: `--stage1_model m-a-p/YuE-s1-7B-anneal-en-cot`, `--stage2_model m-a-p/YuE-s2-1B-general`, `--run_n_segments`, `--stage2_batch_size 4`, `--max_new_tokens`, `--repetition_penalty 1.1` and `--seed`. Export is free.

## Account and models

`GET /api/v1/account`:

```json
{
  "data": {
    "credits": 120,
    "api_runs_per_hour": 10,
    "api_runs_last_hour": 3,
    "parallel_runs": 1
  }
}
```

`GET /api/v1/models` (no key needed) lists each engine with its price in credits, the compare, and the models that are not offered (status `not_offered`), such as the Chinese and Japanese/Korean YuE models and YuE2.

## The run object

| Field              | Notes                                                                                                                     |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------- |
| `id`               | The run id.                                                                                                               |
| `object`           | Always `"run"`.                                                                                                           |
| `engine`           | `"yue"` or `"ace-step"`.                                                                                                  |
| `model`            | The model label.                                                                                                          |
| `status`           | `running`, `succeeded` or `failed`.                                                                                       |
| `failure`          | When failed: `"refused"`, `"cap"` (hit the time cap) or `"error"`; otherwise `null`.                                      |
| `title`            | The title, if any.                                                                                                        |
| `credits`          | Credits charged. A failed run's credits are refunded automatically.                                                       |
| `compare_id`       | Set when the run is half of an A/B compare.                                                                               |
| `parent_id`        | Set when the run was forked from another run.                                                                             |
| `recipe`           | `model`, `title`, `genre`, `lyrics`, `segments`, `max_new_tokens`, `precision` (`"bf16"` or `"int8 stage 1"`) and `seed`. |
| `audio_url`        | `/api/v1/runs/{id}/audio` once succeeded (send your key), else `null`.                                                    |
| `duration_seconds` | Length of the audio, once known.                                                                                          |
| `web_url`          | The run in [My runs](https://yueai.net/runs): `https://yueai.net/runs?run=<id>`.                                                           |
| `created_at`       | ISO 8601 time.                                                                                                            |

## Webhooks

Pass `webhook_url` when you start a run. When the run ends we POST once to that URL:

```json
{
  "type": "run.succeeded",
  "data": { "id": "...", "status": "succeeded", "...": "..." }
}
```

`type` is `run.succeeded` or `run.failed`; `data` is the run object. The request has the user agent `YueAI-Webhooks/1` and a signature header:

```
YueAI-Signature: t=1764900000,v1=5f2c...
```

`v1` is the hex HMAC-SHA256 of `<t>.<raw body>` with your signing secret (it starts with `whsec_` and is on the [API keys](https://yueai.net/settings/apikeys) page). Check it, and reject requests whose `t` is more than 300 seconds from your clock:

```js


function verify(rawBody, header, secret) {
  const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')));
  if (Math.abs(Date.now() / 1000 - Number(parts.t)) > 300) return false;
  const expected = crypto
    .createHmac('sha256', secret)
    .update(`${parts.t}.${rawBody}`)
    .digest('hex');
  return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
}
```

Delivery is one attempt with a 10-second timeout; redirects are not followed. A webhook that is still owed for a run that ended in the last 24 hours is sent by a background job. Answer with any `2xx` quickly and do the work afterwards. If you miss a webhook, `GET /api/v1/runs/{id}` always has the result.

## MCP server

The same runs are available to AI assistants through our MCP server at `https://yueai.net/mcp` (Streamable HTTP). Sign in with OAuth, or send an API key as the bearer token. Its tools are `list_prices`, `run_yue` (engine plus recipe; it needs `own_words: true`), `compare_engines`, `get_run`, `export_recipe`, `list_runs` and `get_credits`. Set-up for each client is on the [MCP server](https://yueai.net/mcp-server) page.

## Help

Write to [support@yueai.net](mailto:support@yueai.net) or open a [ticket](https://yueai.net/settings/tickets) with the run id. YueAI.net is an independent platform and is not affiliated with HKUST, M-A-P or any underlying model provider. YuE and YuE2 are trademarks of their owners.

---

Source: https://yueai.net/docs · Site index for AI agents: https://yueai.net/llms.txt · Full content: https://yueai.net/llms-full.txt
