For agents / Examples
Examples for agents
Copy a render command to make a finished music file for a video, podcast, stream or game. Use the HTTP API or the public CLI.
For the CLI commands, download trickbeat.mjs into your working folder and run it with Node 18+. No checkout is needed. Every recipe sets the finished length with --duration (HTTP: "duration"), so no external trimming or fading is needed. The CLI also writes MIDI and stems; the HTTP API has the same formats.
- HTTP API: WAV, MIDI, stems and health
- 24-second podcast or stream intro
- The same intro with another lead instrument
- The same intro with quieter drums and another lead
- Background music for a 60-second video
- Seamless game menu loop of about 30 seconds
- MIDI and stems for that loop
HTTP API examples
No API key is needed. If you have a checkout, start npm run server from the repo root (Node only, no install) and replace https://api.trickbeat.org with http://127.0.0.1:8787. See the API quickstart and limits.
Health check
curl --fail --silent --show-error https://api.trickbeat.org/api/v1/health
WAV mix
curl --fail --silent --show-error https://api.trickbeat.org/api/v1/render \
-H 'Content-Type: application/json' \
-d '{"style":"lofi","seed":7,"picks":"ABAAAAA","loop":true,"format":"wav"}' \
-o song.wav
MIDI for editing
curl --fail --silent --show-error https://api.trickbeat.org/api/v1/render \
-H 'Content-Type: application/json' \
-d '{"style":"lofi","seed":7,"picks":"ABAAAAA","loop":true,"format":"midi"}' \
-o song.mid
Stems as a ZIP
curl --fail --silent --show-error https://api.trickbeat.org/api/v1/render \
-H 'Content-Type: application/json' \
-d '{"style":"lofi","seed":7,"picks":"ABAAAAA","loop":true,"format":"stems"}' \
-o song-stems.zip
WAV with fetch (Node.js 18+)
node --input-type=module <<'JS'
import { writeFile } from 'node:fs/promises';
const response = await fetch('https://api.trickbeat.org/api/v1/render', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ style: 'lofi', seed: 7, picks: 'ABAAAAA', loop: true, format: 'wav' }),
});
if (!response.ok) {
const retryAfter = response.headers.get('Retry-After');
throw new Error(`HTTP ${response.status}${retryAfter ? `; retry after ${retryAfter} seconds` : ''}: ${await response.text()}`);
}
const bytes = new Uint8Array(await response.arrayBuffer());
await writeFile('song-fetch.wav', bytes);
console.log(`HTTP ${response.status}: ${bytes.byteLength} bytes saved to song-fetch.wav`);
JS
Podcast or stream intro
Get a finished 24-second WAV from one call: exactly 24 s, 1,058,400 frames at 44.1 kHz. Pass --duration 24 to the CLI or "duration":24 in the HTTP body. No trimming or fading in an external editor. The engine keeps whole bars and adjusts the tempo (here 124 to 120 BPM), and the last 50 ms fade to zero. Without duration the same song runs 37.84 seconds. The call returns music only: no voice-over bed.
HTTP API
curl --fail --silent --show-error https://api.trickbeat.org/api/v1/render \
-H 'Content-Type: application/json' \
-d '{"style":"organ-house","seed":21,"picks":"AAAAABA","duration":24,"format":"wav"}' \
-o intro-24s.wav
The response header X-Trickbeat-Seconds is 24.
Public CLI
node trickbeat.mjs make --style organ-house --seed 21 --picks AAAAABA --duration 24 --out intro-24s.wav --base https://trickbeat.org/make/app/
The JSON result has requestedSeconds (24) and seconds (the actual length).
Another lead instrument
Add --lead epiano or "lead":"epiano" to play the same melody with a different voice. Notes, timing and the other layers stay the same. Valid ids: lead, brass, epiano, bell, guitar, marimba, whistle and chipSquare.
node trickbeat.mjs make --style organ-house --seed 21 --picks AAAAABA --duration 24 --lead epiano --out intro-24s-epiano.wav --base https://trickbeat.org/make/app/
curl --fail --silent --show-error https://api.trickbeat.org/api/v1/render \
-H 'Content-Type: application/json' \
-d '{"style":"organ-house","seed":21,"picks":"AAAAABA","duration":24,"lead":"epiano","format":"wav"}' \
-o intro-24s-epiano.wav
Quieter drums and another lead
Add --levels drums=60 (HTTP: "levels":{"drums":60}) next to --lead. The file is still exactly 24 s. Only the drums and the lead change; bass and chords stay the same. Levels are mix controls, not a promise of linear PCM amplitude.
node trickbeat.mjs make --style organ-house --seed 21 --picks AAAAABA --duration 24 --lead epiano --levels drums=60 --out intro-24s-edit.wav --base https://trickbeat.org/make/app/
curl --fail --silent --show-error https://api.trickbeat.org/api/v1/render \
-H 'Content-Type: application/json' \
-d '{"style":"organ-house","seed":21,"picks":"AAAAABA","duration":24,"lead":"epiano","levels":{"drums":60},"format":"wav"}' \
-o intro-24s-edit.wav
Optional MCP stdio (local package): trickbeat_make_song takes the same duration and lead. Call it with:
{"style":"organ-house","seed":21,"picks":"AAAAABA","duration":24,"lead":"epiano","out":"/absolute/path/intro-24s.wav"}
Background music for a 60-second video
Get a finished 60-second lo-fi WAV with a quiet lead for use under speech from one call: exactly 60 s, 2,646,000 frames. Pass --duration 60 to the CLI or "duration":60 in the HTTP body. No fade or padding in an external editor. The engine keeps whole bars and slows the tempo (here 80 to 72 BPM) so the last bar ends at 60 s, and the last 50 ms fade to zero. Without duration the same song runs 57 seconds at 80 BPM. The call returns music only: no voice-over.
HTTP API
curl --fail --silent --show-error https://api.trickbeat.org/api/v1/render \
-H 'Content-Type: application/json' \
-d '{"style":"lofi","seed":7,"picks":"AAAAABA","levels":{"drums":70,"bass":90,"chords":80,"lead":40},"duration":60,"format":"wav"}' \
-o video-60s.wav
Public CLI
node trickbeat.mjs make --style lofi --seed 7 --picks AAAAABA --levels drums=70,bass=90,chords=80,lead=40 --duration 60 --out video-60s.wav --base https://trickbeat.org/make/app/
The CLI JSON shows review.ok false with the warning "lead buried under chords". That is expected: the recipe keeps the lead at 40 percent to leave room for speech. The file is complete.
Continuous music at the original tempo
Add --loop (or "loop":true) to keep the tempo. The 12-second loop then repeats 5 whole cycles, exactly 60 s; the CLI JSON shows cycles 5.
node trickbeat.mjs make --style lofi --seed 7 --picks AAAAABA --levels drums=70,bass=90,chords=80,lead=40 --loop --duration 60 --out video-loop-60s.wav --base https://trickbeat.org/make/app/
Change the fourth pick for another melody hook, or add --lead for another lead instrument.
Optional MCP stdio (local package): trickbeat_make_song takes duration too. Call it with:
{"style":"lofi","seed":7,"picks":"AAAAABA","levels":{"drums":70,"bass":90,"chords":80,"lead":40},"duration":60,"out":"/absolute/path/video-60s.wav"}
Game menu loop
Get a finished loop of about 30 seconds from one call: pass --loop --duration 30 to the CLI or "loop":true,"duration":30 in the HTTP body. Loops keep their tempo and round to a whole number of cycles, so 30 s becomes 32 s: 5 cycles of 6.4 s, 1,411,200 frames at 44.1 kHz. Loops are not faded, so the file repeats without a seam. No tiling or tempo change in an external editor. Without duration you get one 6.4 s cycle to repeat in your game. Read the actual length in the CLI JSON (seconds, cycles) or in X-Trickbeat-Seconds.
HTTP API
curl --fail --silent --show-error https://api.trickbeat.org/api/v1/render \
-H 'Content-Type: application/json' \
-d '{"style":"8-bit","seed":12,"picks":"AAAAAAA","loop":true,"duration":30,"format":"wav"}' \
-o menu-loop.wav
Public CLI
node trickbeat.mjs make --style 8-bit --seed 12 --picks AAAAAAA --loop --duration 30 --out menu-loop.wav --base https://trickbeat.org/make/app/
MIDI and stems
Add --format midi to write a .mid instead of a WAV, and --stems <dir> to also write one WAV per layer: drums.wav, bass.wav, chords.wav, and lead.wav. CLI and HTTP stems have no extras.wav. All files use the same 32 s length, so the stems line up with the MIDI and the mix.
node trickbeat.mjs make --style 8-bit --seed 12 --picks AAAAAAA --loop --duration 30 --format midi --stems menu-stems --out menu-loop.mid --base https://trickbeat.org/make/app/
Over HTTP, send "format":"midi" for the MIDI, or "format":"stems" for a ZIP of the same WAVs plus a README.txt:
curl --fail --silent --show-error https://api.trickbeat.org/api/v1/render \
-H 'Content-Type: application/json' \
-d '{"style":"8-bit","seed":12,"picks":"AAAAAAA","loop":true,"duration":30,"format":"stems"}' \
-o menu-stems.zip
MIDI holds notes, tempo and approximate General MIDI programs, not the synth audio. Stems are the separate layers before the master limiter; their sum is not the finished mix, so keep the mix from the WAV above and match style, seed, picks, levels, loop and duration to it.
Optional MCP stdio (local package): trickbeat_make_song takes the same fields for the WAV and, with "format":"midi" and an out that ends in .mid, for the MIDI. trickbeat_make_stems writes the same four WAVs. All three are byte-identical to the CLI files. Call the stems tool with:
{"style":"8-bit","seed":12,"picks":"AAAAAAA","loop":true,"duration":30,"out_dir":"/absolute/path/menu-stems"}
and the song tool with {"style":"8-bit","seed":12,"picks":"AAAAAAA","loop":true,"duration":30,"out":"/absolute/path/menu-loop.wav"}.
Files, links and credit
- The MCP tools take
duration,leadandformatmidilike the CLI, and a field they do not know is an error that names the field. - Use absolute paths for local MCP
outandout_dir;outends in.wav, or in.midfor MIDI. These are local files on the machine running the MCP client and server, not download URLs. - A share link opens the same song in
/make/, not the rendered WAV. CLI, HTTP API and local MCP links carry levels when one is not 100, the lead (inst=lead:<id>), the duration (dur=<seconds>) and the loop (loop=1), each only when you used it. Save all render inputs for an exact re-render. - A person who opens the link and presses "Download as WAV" gets a file byte-identical to yours: the link opens the same file, 24 seconds for
duration24. - A wrong call names the bad field and the allowed values: HTTP answers 400 with JSON
errorandhint, the CLI prints{"error": ...}on stderr and exits 1, and MCP returns a tool error. Duration 90 gives "duration must be a number from 1 to 60 seconds." - The generated music is free to use, including commercially in videos, podcasts, streams and games. Credit is appreciated, not required:
Made with Trickbeat (trickbeat.org). The code licence is separate and not yet decided.
More
All agent interfaces · /llms-full.txt has these recipes in one plain file · /llms.txt is the short index.