Fun-Music generates complete songs with male or female vocals in Chinese or English from a text prompt describing the music style and scene, or from custom lyrics.
Overview
Fun-Music is an end-to-end music generation model. Provide a natural language description or custom lyrics, and it returns a complete song:
prompt: Describe the music style, scene, mood, and instrument preferences. The model writes lyrics and generates a song automatically.lyrics: Provide custom lyrics. The model composes and performs a song based on your lyrics.gender: Select male or female vocals (fun-music-v1 only).- Streaming and non-streaming output
- MP3 and WAV audio output
Differences between the two models
Fun-Music provides two models with the following differences:
Feature | fun-music-v1 | fun-music-preview |
|---|---|---|
prompt | Required (at least one of | Required |
lyrics | Optional if | Optional; if provided, |
Vocal gender (gender) | Supported | Not supported |
Audio output formats
Set the format parameter to specify the output format:
Format | Characteristics | Use cases |
|---|---|---|
| Lossy compression, small file size | Streaming, online playback, storage |
| Lossless format, larger file size | Post-production, high-quality playback |
Prerequisites
- An API key. For more information, see Get an API key.
- The API key configured as an environment variable (recommended):
{WorkspaceId} in the sample code with your actual workspace ID. For more information, see Workspace management.Quick start
The following examples demonstrate three typical use cases.
- Generate a song from a prompt
- Generate a song from lyrics
prompt parameter with a description of the music style and scene. The model writes the lyrics and composes the song.Composition guide
Prompt
prompt is the primary parameter for describing your music creation intent. The model writes lyrics, arranges music, and generates a song based on your description.
Writing tip: Use specific descriptions of mood, scene, and instrument preferences for better results.
- Recommended:
Melancholic piano, rainy night yearning - Not recommended:
Melancholic music(too vague)
Style | Prompt example |
|---|---|
Folk | A warm, healing folk song with acoustic guitar, telling a story of a lazy afternoon in a cafe |
Traditional Chinese | A traditional Chinese song with guzheng and bamboo flute, evoking misty landscapes and a farewell between wanderers |
Rock | Intense rock with distorted electric guitar, dense drum beats, singing about youthful rebellion and freedom |
Ballad | A slow ballad with piano accompaniment, quiet and deep, with a touch of melancholy, expressing longing and memories |
Rap | A hip-hop rap with a sharp beat, 808 bass drums, full of street energy, telling stories of city life |
Children's song | A cheerful children's song with xylophone and hand drums, simple and catchy rhythm, teaching kids about nature |
Lyrics
The lyrics parameter accepts your lyrics. The model composes a song that follows them closely. Use song section tags to control the arrangement of song sections.
Song section tags
Tag | Description |
|---|---|
| Intro, sets the mood |
| Verse, tells the story |
| Chorus, emotional climax |
| Bridge, shifts perspective |
| Outro, gradual fade-out |
- Originality: Don't copy or imitate lyrics, rhyme schemes, or signature phrases from published songs.
- Content safety: Don't include content related to politics, violence, pornography, vulgarity, horror, or drugs. Keep the content positive and emotionally genuine.
- Language: Only Chinese and English lyrics are supported. Japanese, Korean, and other languages aren't supported.
Vocal gender (gender)
The gender parameter selects the vocal gender. Only supported by the fun-music-v1 model. The default is female.
female: Female vocals (default)male: Male vocals
Advanced features
Streaming output
Streaming mode returns audio data progressively as it's generated, which is ideal for real-time playback. Both fun-music-v1 and fun-music-preview support this mode. To enable streaming output, add X-DashScope-SSE: enable to the request header.
- Non-streaming mode:
lyricsaccepts 5-350 Chinese characters or 5-2,000 English characters;promptaccepts 1-2,000 characters. - Streaming mode:
lyricsaccepts 300-350 Chinese characters or 200-250 English words;promptaccepts 5-1,000 characters (Chinese or English).
Supported models and regions
- China (Beijing)
- fun-music-v1
- fun-music-preview
API reference
Music generation API reference
FAQ
Can I specify instruments, tempo, or mood?
Yes. Describe them directly in your prompt, such as "piano accompaniment, slow tempo, melancholic." The model follows these descriptions as closely as possible. More specific prompts produce more accurate results. For detailed prompt writing tips, see Prompt.
Which model should I choose?
fun-music-v1 supports vocal gender selection and generates higher quality audio. fun-music-preview supports custom lyrics and prompt-based generation. For a detailed comparison, see Differences between the two models.
How long are audio download URLs valid?
Audio file download URLs are valid for 24 hours. Download the files within this period. After the URL expires, call the API again to generate a new one.
What's the difference between lyrics and prompt?
The lyrics parameter takes your lyrics, and the model composes a song based on them. The prompt parameter takes a natural language description of the music style and scene, and the model writes lyrics and generates music automatically. Parameter requirements differ by model: for fun-music-v1, at least one of the two parameters is required; if both are provided, lyrics takes effect. For fun-music-preview, prompt is required; lyrics is optional and takes priority over prompt when provided.
When should I use streaming vs. non-streaming mode?
Use non-streaming mode if you only need the final audio file. The API call is simpler. Use streaming mode if you need audio data delivered progressively during generation, such as for real-time playback.
What are the parameter limits for streaming vs. non-streaming mode?
Character limits for lyrics and prompt differ between the two modes. In non-streaming mode, lyrics accepts 5-350 Chinese characters or 5-2,000 English characters, and prompt accepts 1-2,000 characters. In streaming mode, lyrics accepts 300-350 Chinese characters or 200-250 English words, and prompt accepts 5-1,000 characters (Chinese or English).