task_id, then poll the task status until it reaches the SUCCESS or FAILED terminal state.
Music generation is a long-running autoregressive task. Generating a complete song usually takes from tens of seconds to a few minutes.
Endpoint
POST https://api.stepfun.ai/v1/audio/music
Capabilities
Three task types are provided, covering four use cases:
When
text_to_music is used without lyrics, the server generates the lyrics automatically.
Common Conventions
Request Headers
Unified Error Response
All non-2xx responses use the following structure:error.type and should not match against the message text.
The response also returns an x-should-retry header:
- Parameter, authentication, and resource errors (400 / 401 / 404):
false - Rate limiting and transient service failures (429 / 500 / 503):
true - Quota-related 429s cannot be resolved by retrying and must still be handled separately based on
error.type.
data: prefix.
Submit a Music Generation Task
POST https://api.stepfun.ai/v1/audio/music/submit
Request Parameters
taskstringrequired
Task type. Supportstext_to_music,music_cover, andvocal_to_music.model_idstringrequired
Music model identifier. Fixed tostepaudio-3-music-preview.captionstringrequired
Style description such as genre, vocals, emotion, and key.lyricsstringoptional
Lyrics, with support for song-structure tags. Required formusic_coverandvocal_to_music; fortext_to_music, the server writes the lyrics automatically when omitted.instrumentalbooleanoptional
Whether to generate a pure instrumental. Defaultfalse. Only supported bytext_to_music.song_audiostringoptional
Base64 encoding of the complete reference song. Required formusic_cover.vocal_audiostringoptional
Base64 encoding of the dry vocal without accompaniment. Required forvocal_to_music.response_formatstringoptional
Output format. Supportswav,flac,opus,mp3, andpcm. Defaultwav.sample_rateintegeroptional
Output sampling rate. Default48000; when omitted or set to0, the model’s native sampling rate is kept.bit_rateintegeroptional
MP3 / Opus bit rate, in kbps.lyrics_rewritebooleanoptional
Whether to rewrite the provided lyrics. Defaultfalse.disable_caption_rewritebooleanoptional
Whether to skip automatic rewriting ofcaption. Defaultfalse.max_tokensintegeroptional
Upper limit on generated tokens. Default16000.temperaturenumberoptional
Sampling temperature. Default0.85;0is not currently supported.top_kintegeroptional
Sampling parameter. Default80.top_pnumberoptional
Sampling parameter. Default0.92.repetition_penaltynumberoptional
Repetition penalty. Default1.08.
Parameter Applicability Matrix
Parameter Notes
Instrumental and Lyrics
Wheninstrumental=true, lyrics must not be passed at the same time. The [Instrumental] tag in lyrics indicates only a local instrumental section and cannot replace the top-level instrumental=true.
Cover
Formusic_cover, the melody follows the reference song, while caption controls the style, timbre, arrangement, and emotion. Providing lyrics consistent with the sung content of the original song is recommended.
Vocal-to-Music
Forvocal_to_music, the melody mainly follows the dry vocal and preserves the vocal timbre of the input. The actual sung content of the dry vocal must be a subset or the full set of lyrics.
Caption Rewriting
By default, the server rewritescaption into a normalized English style prompt and returns it as rewritten_caption in the query endpoint.
disable_caption_rewrite=true cannot be used together with lyrics_rewrite=true; when used in a non-instrumental text_to_music scenario, lyrics must be provided explicitly.
Output Duration
The output duration is determined by the model and cannot be controlled precisely via parameters. The duration may differ across multiple generations from the same input, and is typically 1 to 3 minutes.Lyric Structure Tags
Each lyric structure tag must be on its own line. Common tags:[Intro][Verse 1][Pre-Chorus][Chorus 1][Bridge][Instrumental][Hook][Break][Drop][Ad-lib][Outro]
Caption Writing Tips
caption supports Chinese or English. Describing the following dimensions is recommended:
Response
task_id is used to query the task result and for troubleshooting.
Error Codes
Content moderation may return 451 synchronously at the submission stage, or return
FAILED with error.stage=censor during task execution.
Call Examples
- Song generation
- Instrumental
- Song cover
- Vocal-to-music
Query the Task Result
POST https://api.stepfun.ai/v1/audio/music/query
Polling once every 5 seconds until status reaches a terminal state is recommended; save the audio promptly once it succeeds.
Request Parameters
Task Status
In-Progress Response
Success Response
Failure Response
FAILED is a business terminal state; the HTTP status code is still 200.
Response Fields
Failure Stages
Query Error Codes
Query Example
Audio and Output Constraints
Using MP3 output to reduce the response size is recommended. PCM is a headerless raw stream and must be parsed as 48 kHz, 16-bit, stereo on your own.

