Generate Music API guide
Generate Music API: Generate a song from structured lyrics and optional musical style tags.
Model overview
Generate a song from structured lyrics and optional musical style tags.
API integration
| Documentation | Value |
|---|---|
| API invocation identifier | heartmula-generate-music |
| Integration | Async task API |
Use this invocation identifier in API requests. Check your authorized model catalog for access. Follow the Quickstart for your first complete call.
Request parameters
Studio presets describe the form setup, not guaranteed server defaults. Send preset values explicitly to reproduce them.
Song lyrics with structure tags. Each paragraph represents a segment starting with a structure tag (e.g., [verse], [chorus], [bridge]) and ending with a blank line. Each line is a sentence without punctuation.
Studio preset: "".
Musical style tags (Optional). Describe the genre, mood, instruments, tempo, etc. For example: 'pop, upbeat, electronic, female vocals'.
Studio preset: "".
The random seed to use for the generation. -1 means a random seed will be used.
Studio preset: -1.
No parameters match. Clear the search or reset the filters.
Model rules
Parameter meaning
- Use comma-separated tags for genre, mood, instruments, tempo, and vocal characteristics.
- Separate lyric segments with blank lines and start them with a structure tag such as [verse] or [chorus].
Request examples
Replace example media URLs and YOUR_... input identifiers with your own valid resources. Examples are checked against the exported item schema; media access and paid execution are separate runtime checks.
Set MUSESPARK_API_KEY and a stable MUSESPARK_REQUEST_ID before submitting. Preserve the request ID for retries of the same request and use a new ID for new work. Python examples use requests; JavaScript examples use Node.js 20 or later. The standalone Quickstart includes task polling and recovery.
Compose an acoustic song
curl --fail-with-body 'https://api.musespark.ai/api/v1/openapi/task' \
-H "Authorization: Bearer $MUSESPARK_API_KEY" \
-H "X-Idempotency-Key: $MUSESPARK_REQUEST_ID" \
-H 'Content-Type: application/json' \
-d '{
"item_key": "heartmula-generate-music",
"parameters": {
"seed": -1,
"tags": "folk, warm, acoustic guitar, gentle vocals",
"lyrics": "[verse]\nMorning light across the bay\nWe set sail to greet the day\n\n[chorus]\nCarry our song across the sea\nBring the morning home to me\n"
}
}'Parameters used: seed · tags · lyrics.
Output
The intended result is a generated audio asset.
Creation returns a task ID inside data. Poll that task until completion, then save data.result.output_urls and any data.result.batch_results. See the task lifecycle for terminal states, result retention, and errors.
Troubleshooting
The input does not match the intended operation. Use comma-separated tags for genre, mood, instruments, tempo, and vocal characteristics.
For rejected inputs, check the field type, accepted values, and conditional requirements in Request parameters and Model rules. Correct the affected fields before submitting again.
If creation times out, preserve the request identity and any known task ID. Follow Errors, timeouts and retries before submitting again.
Related docs
The public input snapshot was exported on 2026-11-09. Current prices and availability are listed in the model center.