Skip to content

Music Generation (text/lyrics → full song or instrumental) ​

The platform's music capability is generation-oriented: you provide a style description (or bring your own lyrics), and the platform generates a complete song or an instrumental track (BGM) and returns an audio download URL — the entry point for video scoring, podcast intros, and interactive background music.

Music generation is accessed through the task endpoint in asynchronous task mode: submit (returns a task ID immediately) → poll the status → download the audio. Generation usually takes tens of seconds to a few minutes; the asynchronous form does not hold a long-lived connection, so clients do not need to relax their read timeouts.

The current music model is yaoshu-music — for its capability profile, use cases, and selection guidance, see "Model Square" in the Console.

1. Capabilities and Scenarios at a Glance ​

ItemDescription
Creation mode① Description mode: provide a style description only, and the platform writes the lyrics and sings them automatically; ② Custom mode: bring your own lyrics, which the platform sets to music and sings (a style description may be added)
Instrumental (no vocals)instrumental: true — for BGM / background music
Target duration10–360 seconds in custom mode (the key input for making the audio match a video's length); in description mode the duration is inferred by the platform
OutputAudio file (mp3), downloaded directly from result_url in the query response (a complete direct link; no API Key needed)
Output per taskThe platform generates 2 candidate tracks per task; the download URL points to 1 of them (the first track)
BillingBilled per task, independent of generation duration and number of candidate tracks; failed tasks are not charged

2. Submitting a Task ​

MethodPathDescription
POST/suno/submit/musicSubmit a music generation task (returns a task ID on success)
GET/suno/fetch/{task_id}Query a single task (status + result)
POST/suno/fetchBatch query tasks (pass an ids array in the body)

Authentication: Authorization: Bearer sk-your-api-key (platform API Key; all endpoints in this group share the same authentication).

2.1 Request Parameters ​

ParameterTypeRequiredDescription
modelstring✅yaoshu-music
customModebooleanNoExplicit creation mode: true = custom mode, false = description mode. Usually unnecessary — when omitted, the platform decides: providing any of style / lyrics / instrumental: true means custom mode; providing only prompt means description mode
instrumentalbooleanNotrue generates instrumental music without vocals; default false
stylestringConditionalStyle / mood / scene / instrument description (≤1000 characters). The core input for instrumental scenarios; to specify duration you must provide style or lyrics
lyricsstringConditionalCustom lyrics (≤5000 characters); structure tags control section arrangement (see "5. Creation Guide")
promptstringConditionalIn custom mode, used as lyrics (if lyrics is also provided, lyrics takes precedence); in description mode, used as the core creative description (≤3000 characters) and the platform writes the lyrics
titlestringNoTrack title (≤80 characters), custom mode only
durationnumberNoTarget duration in seconds, 10–360, effective in custom mode only, and must be sent together with style or lyrics; when omitted, generation uses the platform default of 20 seconds; cannot be sent when customMode: false is passed explicitly (in description mode the duration is inferred by the platform)
negativeTagsstringNoStyles / characteristics to exclude (≤1000 characters), custom mode only
vocalGenderstringNoVocal preference: m (male) / f (female), for custom-mode songs only (raises the probability only, not guaranteed)

At least one of style / lyrics / prompt must be provided; instrumental scenarios require style or lyrics; when customMode: true is passed explicitly, at least one of style / lyrics / negativeTags must be provided.

This capability does not support callbacks: do not pass callBackUrl — the platform provides no task callback channel (the parameter takes no part in state transitions and is rejected outright with a hint); always obtain task status by polling.

The parameters on this page are the complete supported set: parameters not listed here (weights, variation, vocal / image / video references and the like, common in other music APIs of this kind) are not accepted and not passed through by the platform — sending them raises no error but has no effect; do not rely on them.

2.2 Example: instrumental BGM (30 seconds) ​

bash
curl https://token.yaoshu.cc/suno/submit/music \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "yaoshu-music",
    "instrumental": true,
    "style": "calm ambient piano, soft pads, cinematic background music",
    "duration": 30
  }'

Success response (HTTP 200):

json
{ "code": "success", "data": "task_1LTQuPdCJV4KTNeuV80taY5KDEwil0nC" }

data is the task ID (string), used for subsequent queries and downloads.

2.3 Example: song (own lyrics + style) ​

bash
curl https://token.yaoshu.cc/suno/submit/music \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "yaoshu-music",
    "title": "ys-song-test",
    "style": "indie pop, warm acoustic guitar",
    "lyrics": "[Verse]\nMorning light on the window sill\n[Chorus]\nWe are going home tonight"
  }'

Song mode usually omits duration — the length follows naturally from the lyrics (the example above comes out at about 38 seconds).

2.4 Submission Failures ​

codeTrigger
music_input_requiredNone of style / lyrics / prompt was provided
style_requiredinstrumental: true but neither style nor lyrics was provided
duration_requires_styleOnly prompt was provided but duration was specified (the duration is not controllable in description mode; add style)
duration_requires_custom_modecustomMode: false was passed explicitly together with duration (in description mode the duration is inferred by the platform; to specify a duration, provide style/lyrics and set customMode: true)
custom_mode_input_requiredcustomMode: true was passed explicitly but none of style / lyrics / negativeTags was provided
invalid_durationduration out of range (valid 10–360 seconds)
callback_not_supportedcallBackUrl was passed (the platform provides no task callback channel; poll for status instead)

Failure responses look like:

json
{ "code": "invalid_duration", "message": "duration 取值需在 10~360 秒之间", "status_code": 400 }

2.5 Failure Forms (three layers by where they occur) ​

Where it occursHTTPResponse bodyTypical code
Request parameters invalid (platform-local validation; no task created, nothing billed)200{code, message, status_code}See the table above (the seven codes such as music_input_required)
Platform pre-check (the request never reaches business processing)401 / 433 / 503{"error":{...}}Authentication failure 401; request body cannot be parsed 433; no available route 503 + no_available_channel
Accepted but processing failed200{code, message, status_code}get_channel_failed (500), service-side rejection (502)

Always judge success by the response body code: business validation failures and platform-side processing failures still return HTTP 200 (the reason is written into code / message); only platform pre-checks return a non-200 status. Treat code == "success" as the sole success criterion and do not look at the HTTP status code alone. A task whose validation fails is not created and is not billed.

No available route (HTTP 503 + code: no_available_channel) — the most common causes are a misspelled model name, or the model not being enabled for the group your API key belongs to. message already echoes the model name you requested and the resolved group, so you can self-check right away (no need to go back to the platform for bisection); the sentence pattern varies slightly with the routing form, but these two pieces of context are always present:

json
{ "error": { "message": "no available public-model route in group default for model yaoshu-music-x", "type": "distributor_error", "code": "no_available_channel" } }

3. Polling the Task ​

bash
curl https://token.yaoshu.cc/suno/fetch/task_1LTQuPdCJV4KTNeuV80taY5KDEwil0nC \
  -H "Authorization: Bearer sk-your-api-key"
json
{
  "code": "success",
  "data": {
    "task_id": "task_1LTQuPdCJV4KTNeuV80taY5KDEwil0nC",
    "action": "MUSIC",
    "status": "SUCCESS",
    "progress": "100%",
    "duration": 38,
    "result_url": "https://cdn.example.com/audio/xxxx.mp3?auth_key=xxxx",
    "fail_reason": null,
    "submit_time": 1791738107,
    "finish_time": 1791738143
  }
}
FieldDescription
task_idTask ID
statusTask status (see the table below)
progressProgress (string percentage such as 20% / 100%), for reference only
durationDuration of the resulting music (integer seconds, rounded); null before success
result_urlAudio download URL (a complete direct link — request it directly, no API Key needed); valid only in the success state, null while failed or in progress
fail_reasonFailure reason (present only in the failure state)
submit_time / finish_timeSubmission / completion time (Unix seconds)
StatusMeaning
SUBMITTED / QUEUEDSubmitted, queued
IN_PROGRESSGenerating
SUCCESSGeneration complete, ready to download
FAILUREGeneration failed (reason in fail_reason), not billed

Fields such as id / user_id / group / channel_id / quota / properties in the response are platform-internal and can be ignored when integrating.

Polling cadence: start with a 10-second interval (measured: a 30-second instrumental and a song both complete about 40 seconds after submission); set an overall timeout of 5 minutes per task.

Query failure: the task does not exist, or does not belong to you → HTTP 404 + {"code":"task_not_exist","message":"task_not_exist","status_code":404} (unauthorized access and non-existence look identical, so the response does not leak whether a task exists). A batch query does not error on such task IDs; they simply do not appear in data.

Batch query (fetch several task statuses at once):

bash
curl https://token.yaoshu.cc/suno/fetch \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"ids": ["task_xxx1", "task_xxx2"]}'

data is an array of task objects (element structure identical to the single-task query). Tasks belonging to other users do not appear in the results.

4. Downloading the Audio ​

Once the task status is SUCCESS, download using result_url from the query response:

bash
curl -o music.mp3 \
  "https://cdn.example.com/audio/xxxx.mp3?auth_key=xxxx"
  • The download URL is result_url from the query response (a complete direct link); request it directly, no API Key needed
  • The link has a retention period (set by the storage provider); after expiry it returns 404/410
  • Download the file and copy it to your own storage as soon as the task succeeds — after expiry the platform keeps no fallback copy, and the only option is to regenerate

5. Creation Guide ​

5.1 How to Write a Style Description ​

style (or prompt in description mode) is the core determinant of the resulting track's character. Concretely describing mood, scene, and instrument preferences works far better than vague descriptions.

  • ✅ Recommended: melancholic piano piece, longing on a rainy night
  • ❌ Not recommended: sad music (too vague)

You can specify instruments, tempo, and emotion: just write them in, e.g. piano accompaniment, slow tempo, sorrowful. Two rules of thumb: piling up style tags (cinematic, ambient, soft piano) is more reliable than long prose sentences; for instrumental scenarios always state the mood and the instruments (mood alone without instruments easily drifts away from a scoring/BGM role).

StyleExample description
FolkA warm, healing folk song with acoustic guitar, about a lazy afternoon in a café
Guofeng (Chinese classical)A Guofeng song with guzheng and bamboo flute, evoking the distant mood of ink-wash landscapes, telling of parting across the martial world
RockPassionate rock with a wall of distorted electric guitars and dense drums, singing of youthful rebellion and freedom
BalladA slow, emotional ballad with piano, quiet and deep, tinged with light sorrow, suited to expressing longing and memory
RapHip-hop with a crisp beat and 808 bass, full of street energy, telling stories of city life
Children's songA cheerful, cute children's song with xylophone and tambourine, simple and lively rhythm, teaching kids about nature
Instrumental BGMcinematic ambient piano, soft pads, slow tempo, no vocals (use with instrumental: true)

5.2 Lyrics and Structure Tags ​

Pass your own lyrics in lyrics; the platform strictly sets those lyrics to music and sings them. Use structure tags to control section arrangement:

TagDescription
[intro]Intro, sets the atmosphere
[verse]Verse, tells the story
[chorus]Chorus, emotional peak
[bridge]Bridge, shift of perspective
[outro]Outro, fading close

Complete lyrics template (structure tags + section organization reference):

text
[intro]
Keys fall softly, the evening breeze is cool.
That summer, heartbeats quietly ran hot.

[verse]
By the classroom window, sunlight slanted across your face.
Borrowing half an eraser, fingertips sparked a current.
On the way home from school, bicycle bells chased the clouds.
You said the future was far; I wanted to walk to its end.

[chorus]
Youth is an unopened letter, filled with vows of courage.
Even as the world flickers bright and dim, with you I see the light.

[bridge]
Later, wind and rain broke the paper umbrella, silence took the place of answers.
But the song in my heart is unfinished, still waiting for a "don't drift away".

[outro]
The piano fades, starlight fills the long street.
The story isn't over; the next page is still ablaze.

5.3 Creation Requirements ​

① Lyrics must be original — plagiarism of published songs is strictly prohibited, as is imitating a well-known song's rhyme scheme or signature phrasing; ② content must be wholesome (no political, violent, pornographic, vulgar, horror, drug, or other illegal content); ③ only Chinese or English lyrics are supported.

5.4 Choosing Among the Three Parameters ​

GoalWhat to send
Let the platform write the lyrics and singSend only style (style) or prompt (creative description)
Set your own lyrics to music and singSend lyrics (optionally add style for extra style guidance; when both lyrics and prompt are sent, lyrics takes precedence)
Instrumental only, no vocalsinstrumental: true + style
Audio matching a video's length (BGM)instrumental: true + style + duration (fill in the video's length, 10–360 seconds)

6. Limits ​

  • style ≤1000 characters; lyrics ≤5000 characters; prompt in description mode ≤3000 characters; title ≤80 characters; negativeTags ≤1000 characters (over-limit errors are passed through)
  • duration is effective in custom mode only (must be sent together with style or lyrics); valid range 10–360 seconds
  • instrumental: true produces instrumental music without vocals, and vocalGender is meaningless
  • Lyrics support Chinese or English only
  • One task generates 2 candidate tracks; only the first track's download URL and duration are currently exposed
  • In description mode the duration is inferred by the platform and cannot be specified
  • Generation takes tens of seconds to a few minutes (measured: a 30-second instrumental takes about 35 seconds, a song about 36 seconds; longer tracks take longer) — poll the task status rather than waiting on a single synchronous request
  • Tasks that stay in a non-terminal state for a long time are automatically marked failed and the charge is refunded (the timeout threshold is a platform-side parameter, currently 24 hours)

This page covers the task-based form that replaced the older synchronous endpoint (POST /api/v1/services/audio/music/generation, which returned Base64 audio in a single request): the old endpoint has been taken offline (calls return 404), and the old request body (input.* parameters) no longer applies. With the task form, submission and generation are decoupled, long runtimes no longer occupy a long-lived connection, and the target duration can be specified.

7. Billing ​

Billed per task — independent of generation duration and number of candidate tracks; one task counts as one billing unit. The unit price is shown on the model pricing page in the Console. Failed tasks are not billed (a rejected submission creates no task and incurs no charge). For the platform's general billing and failure semantics, see API Integration Overview §5.

Public documentation for platform users