AI Music API and Sound Effects API: curl, Python and MCP Examples

FastMetal's music and sound effects APIs turn a text prompt into an MP3 your app or agent can use. This walkthrough goes from a free price quote to a finished take to an MCP agent call, using real responses.
You need a FastMetal API key and some balance:
export FASTMETAL_API_KEY="sk-..."
Step 1: Quote before you generate
/v1/audio/quote returns the price without calling the model or billing anything. For music, add "op": "music":
curl -sS -X POST https://api.fastmetal.ai/v1/audio/quote \
-H "Authorization: Bearer $FASTMETAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"op": "music", "model": "ace-step/ace-step-1.5", "prompt": "Energetic synthwave, driving drums", "duration_seconds": 30}'
The response looks like this (amount left out):
{
"object": "audio.quote",
"op": "music",
"model": "ace-step/ace-step-1.5",
"amount": "<price of one take>",
"currency": "usd",
"per": "take",
"duration_seconds": 30,
"instrumental": true
}
A request the real endpoint would refuse (a length the model doesn't sell, a prompt that's too long) is refused here too.
Step 2: Generate a music take
Send the model, the prompt and the length to /v1/audio/music. ACE-Step 1.5 also takes bpm, a whole number from 30 to 300.
curl -sS -X POST https://api.fastmetal.ai/v1/audio/music \
-H "Authorization: Bearer $FASTMETAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "ace-step/ace-step-1.5", "prompt": "Energetic synthwave, driving drums, pulsing bass, bright retro synth leads, night drive through a neon city", "duration_seconds": 30, "bpm": 120}' \
-o synthwave.mp3 -D headers.txt
The call waits for the take and returns the MP3 itself. Ours came back in about 11 seconds:
Measurements and the charge are in the headers. From the real headers.txt (charge left out):
HTTP/2 200
content-type: audio/mpeg
x-fm-charge: <amount> <currency>
x-fm-checks: length=ok; level=ok
x-fm-duration-seconds: 30.000
x-fm-requested-seconds: 30
x-fm-duration-seconds is the length FastMetal measured by decoding the take. Silent takes and takes far shorter than requested are refused and not billed.
Step 3: Generate a sound effect
Sound effects go to /v1/audio/sound-effects, with a length from 1.5 to 6 seconds:
curl -sS -X POST https://api.fastmetal.ai/v1/audio/sound-effects \
-H "Authorization: Bearer $FASTMETAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "mirelo/sfx-2.0", "prompt": "A retro video game coin pickup sound", "duration_seconds": 2}' \
-o coin.mp3 -D headers.txt
Sound effect headers add loudness measurements:
x-fm-attribution: Generated using Mirelo's technology.
x-fm-charge: <amount> <currency>
x-fm-checks: length=ok; level=ok
x-fm-duration-seconds: 2.000
x-fm-id: 207c1cf3-7c25-4507-aa9a-5a42e4fd2fc7
x-fm-loudness-lufs: -23.6
x-fm-peak-dbfs: -1.2
x-fm-requested-seconds: 2
x-fm-attribution is the credit line a model asks for; show it wherever your users pick a sound. x-fm-loudness-lufs is integrated loudness, which varies a lot between models and prompts. Add "normalize": true and FastMetal applies one gain toward -23 LUFS, at the same price.
Step 4: Call it from Python
With "delivery": "json" the response is JSON: the audio is base64 in audio.base64, alongside the measurements (measured), the checks (checks) and the charge breakdown (charge). Handy when your app keeps records.
import base64, os, requests
r = requests.post(
"https://api.fastmetal.ai/v1/audio/sound-effects",
headers={"Authorization": f"Bearer {os.environ['FASTMETAL_API_KEY']}"},
json={
"model": "elevenlabs/sound-effects-v3",
"prompt": "A soft, clean user interface button click",
"duration_seconds": 1.5,
"normalize": True,
"delivery": "json",
},
timeout=120,
)
r.raise_for_status()
data = r.json()
with open("click.mp3", "wb") as f:
f.write(base64.b64decode(data["audio"]["base64"]))
print(data["measured"], data["normalize"]["gain_db"])
When we ran it, the model's clip measured -30.6 LUFS; normalize applied 7.1 dB of gain and returned -24.2 LUFS. limited_by was true_peak: the -1 dBTP ceiling stopped it short of the -23 LUFS target. original_audio holds the clip as the model made it.
Step 5: Let an agent do it over MCP
Add FastMetal's MCP server to Claude Code and your agent can make music and sound effects:
claude mcp add --transport http fastmetal https://mcp.fastmetal.ai/mcp --header "Authorization: Bearer ${FASTMETAL_API_KEY}"
Three tools:
generate_music: makes music.takes(1 to 3) asks for separate takes in one call, each billed.generate_sound_effect: makes a sound effect, withnormalizeandresponse_format(mp3 or wav).get_audio: fetches a take that wasn't ready in time, by the ID it returned;wait: truewaits for it.
Every tool takes dry_run: true for a free price check, and a request_id makes a retry return the first result instead of billing again. A request to the agent might read:
Make two 60-second takes of a bright chiptune title-screen theme with ace-step/ace-step-1.5 at 130 BPM. Show me the dry_run price first.
Gotchas
- Unknown fields get a 400 naming the field, with nothing billed. There's no seed and no loop option.
- Music with vocals isn't sold;
instrumentalcan only betrue. - If the balance can't cover the take, the request is refused and nothing is billed.
- Each account can make a limited number of takes at once. Past the limit, the error says when to retry.
Next steps
Fields and errors are listed in the music API docs and the sound effects API docs. For voiceover, the speech API works with the same key. Rates are on the pricing page.
Create a free account and get an API key.