Generate music
text_to_musicGenerate music from a text prompt and save the resulting audio files locally; tracks are licensed for commercial social, brand, and advertising use.
Instructions
Generate music from a text prompt and save the resulting audio file(s) to a local directory. Generated tracks are fully licensed (music licensed via Shutterstock) and cleared for commercial use on social, brand content, and advertising.
⚠️ COST WARNING: This tool makes an API call to Sonilo which may incur charges. Only use when explicitly requested by the user.
Args: prompt (str): Description of the music to generate (1–1000 chars). duration (int, optional): Length in seconds (5–360). Omit it and Sonilo picks a length that suits the prompt. output_format (str, optional): 'm4a' (default), 'wav', or 'mp3' (320 kbps). Anything but 'm4a' requires the backend's async generation mode (submit + poll) instead of streaming — selected automatically, no user-facing mode param needed. variants_num (int, optional): 1-10, default 1. Generate this many distinct music variants in one request — each is its own creative direction with its own title, not just a re-roll. Cost scales linearly with N. Values above 1 require the backend's async generation mode (handled automatically, same as output_format='wav') and are never covered by the free trial — even a trial account is billed for variants beyond the first. stems (bool, optional): Default false. Pass stems=true to also get the track split into four separate instrument tracks — drums, bass, vocals and other — at no extra charge; it adds a few minutes to the wait (this tool then waits up to 75 minutes), so set it only when the user asks for stems or separated tracks. Uses the backend's async generation mode (handled automatically, same as output_format='wav'). If a stems result comes back with stems_error instead of (or alongside a partial) stems — surfaced here as a note in the returned text — only the separation failed or was skipped: the music itself generated fine, the saved audio files are valid, and the user was not charged for the separation — report it as a missing extra, not as a failed generation. output_directory (str, optional): Absolute path, or relative to SONILO_MCP_BASE_PATH. Defaults to SONILO_MCP_BASE_PATH (~/Desktop unless overridden).
Returns: One TextContent per generated audio stream, each containing the absolute path of the saved audio file (.m4a by default, .wav when output_format='wav'). At variants_num > 1, one entry per variant (suffixed -0, -1, ...), each labeled with its title when the backend provides one. stems=True: also one TextContent per saved stem file (drums/bass/vocals/other, per stream), or a note carrying stems_error when the free separation failed or was skipped.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"prompt": "<prompt>"
},
"name": "text_to_music"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stems | No | ||
| prompt | Yes | ||
| duration | No | ||
| variants_num | No | ||
| output_format | No | ||
| output_directory | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |