Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

HTTP API

claudius studio, claudius serve and a claudius mcp that runs its own session answer HTTP on http://127.0.0.1:7878 (--port, CLAUDIUS_PORT). The studio, in its window and in the browser, uses nothing but this API, so anything it does you can do with curl. The types are plain serde structs in the claudius-api crate (crates/claudius-api/src/lib.rs), which also compiles to WebAssembly for the web studio.

Routes

routeanswer
GET /api/hello{"name":"claudius","version":"0.1.0","state":1,"ears":false,"studio":{"version":"0.1.0","seconds":3}}: is this claudius, which version, the state version, whether earshot’s models are loaded, and the studio that follows it (the last to ask for the state with ?studio=, in the last minute; null when none has)
GET /api/metricshow fast this claudius has run since it started, in Prometheus’ text format: for each of rendering, listening with the ears and decoding a recording, how many times (claudius_render_total), the seconds of audio (claudius_render_audio_seconds_total), the seconds they took (claudius_render_seconds_total) and the last one’s speed in seconds of audio a second (claudius_render_speed); its version (claudius_build_info), uptime and the song’s changes. A Prometheus server can scrape it; nothing leaves the computer unless something asks
GET /api/statethe state at once
GET /api/state?since=Nthe state as soon as its version is past N (long polling); a studio window adds &studio=<its version>, which /api/hello then reports
GET /api/state?settled=1the state once no job runs and the render is of the current song
POST /api/commandruns one command (JSON body) and answers with a reply
GET /api/scriptthe song as a script, text/plain (// no song yet: try song("house") before the first song)
GET /api/referencethe script language reference, text/markdown
GET /api/soundsevery sound name: drum voices, synth presets, installed instruments, and every pack; also the installed kits’ drums (kit), the roles each synth preset is made for (synth_roles), what each synth preset and drum voice is in a few words (about), and for each role the styles a part may be written in, each with what it plays (styles)
GET /api/genres?q=WORDSthe genres as the state lists them, or those that answer the search q, best first: a name or another name, an era, a scene, an artist or a sound (?q=west%20coast)
POST /api/hearwhat was said to the command palette, heard: the body is a WAV file of it (Content-Type: audio/wav), at most 30 s, any rate and channels; the answer is {"heard", "text"}, the words as the speech model heard them and as the palette reads them, words claudius knows put right (“undu” as undo, “base” as bass when the song has a bass), both empty when nothing was said. The speech model downloads the first time (17 MB). 415 for another content type, 422 for a file that is no WAV or is too long
GET /api/find?q=WORDSthe studio’s actions the command palette finds for WORDS (optional limit, 12 by default and 40 at most), best first: {"query", "found": [{"id", "name", "place", "keys", "score", "by"}], "done": [...], "proposed": [...], "told": [...], "reading", "by_meaning", "read_as"}, where by says whether an action was found by its name or by what the words mean (meaning), done holds the changes in the state’s history the words find that go_back can reach (at most 5: id, what undo calls it as name, what it changed as place), proposed holds what the words ask of the song, read as what claudius would do for it, for the person to confirm (at most 4, the likeliest first: said, what it does in words; detail, what it does to each track when it does more than one thing; commands, the commands that do it; reading, what was read: its kind, tracks, numbers, way, the change it goes back to before as about, and by_model when the request model read it; and score), told holds the answers to a question the words ask about the song, from the song as it is (said, and detail under it; none when they ask none), reading says the request model is still reading words the readings proposed nothing for (ask again in a moment; the first such words download it), by_meaning says whether the embedding model is there yet (the first request downloads it), and read_as, when a word was typed with a slip, the words as they were read (each such word as the word meant, which the rest was found for); all the actions, in order, for no words
GET /api/search?among=genres&q=WORDSwhat a search field’s words find among the genres (among=genres) or the sounds (among=sounds), best first (optional limit, 40 by default and 400 at most): {"query", "among", "names", "by_meaning"}, where names holds those the words find, as the studio’s own search finds them, then those near what the words mean, and by_meaning says whether the embedding model is there yet (the first search downloads it); 400 for anything else to search among
GET /api/audio/{version}.wavthe master of that render, 48 kHz 24-bit
GET /api/audio/{version}.mp3the same as MP3, encoded on the first request
GET /api/stems/{version}/{track}.wavone track of a render made with stems
GET /api/window?from=S&secs=Nthe live mix: N seconds (1 by default, 10 at most) of the song as it is now from S seconds, mixed from the tracks the last render made (below)
GET /api/export/{version}/{name}.{ext}?format=SPECthat render in another format, as a download named {name}.{ext}
POST /api/release/artworkthe release’s artwork, as the file itself with Content-Type: image/jpeg, image/png or application/octet-stream (40 MB at most); answers with a reply
GET /api/release/artworkthe artwork as it was given
GET /api/release/preview.pngthe artwork at most 512 pixels on a side, as PNG
POST /api/samplea recording whose vocals to sample into the song, as the file itself, as for /api/takes; optional name (whose extension says the format), count, bars, find, sections (comma-separated), how (phrases, passage, chops or stabs), every (how often each phrase comes round) and kinds (comma-separated, the kinds of piece) in the query, as for sample_song; answers with a reply
POST /api/groovea recording whose drums’ groove to take, as the file itself, as for /api/takes; optional name (whose extension says the format, and whose 92bpm says the tempo), groove (what to call it), lanes (comma-separated) and bpm in the query, as for extract_groove; answers with a reply
POST /api/pitch-check?id=IDthe answers to pitch check id, sung from its first beat, as the file itself, as for /api/takes; answers with a reply saying what claudius heard, and the voice it heard becomes the person’s (voice)
GET /api/library/search?q=WORDSthe recordings the free online libraries offer for WORDS (optional limit, 20 by default), as a JSON array of LibraryHit: id, title, creator, licence, seconds, page, audio (where to fetch it from this claudius) and credit; a command takes one’s id as library:<id> wherever it takes a recording’s path
GET /api/library/audio?id=IDa recording a search found, downloaded once into the samples folder with its credit, to hear
POST /api/sample/piecesa recording, as the file itself, whose pieces the auto-sampler offers; optional name, seed, count, bars, find and kinds (separated by commas) in the query, as for sample_pieces; answers with a reply, and the pieces go in the state’s pieces
GET /api/pieces/FILEa piece the auto-sampler offers, to hear (as pieces names it)
POST /api/takes?from=SECTIONa recording as a take, as the file itself (WAV, FLAC, Ogg, MP3 or AIFF) with Content-Type: audio/... or application/octet-stream (300 MB at most); optional name and role in the query, as for add_take, and request, the id of the take request it answers; answers with a reply
POST /api/analyze?name=FILEa recording to listen to, as the file itself with Content-Type: audio/... or application/octet-stream (300 MB at most), named in the query so that its extension says its format (WAV, FLAC, MP3, AAC, ALAC, Ogg, AIFF …); answers with a reply whose message is what analyze says, and heard: what was heard as the studio shows it (its bpm, steady, key, key_confidence, swing, lufs, secs; bars, each with its start in seconds and its chord and numeral; sections, each with its start_bar, bars, kind and energy and whether its kick, bass, hats and harmony play; phrases, where its voice sings each phrase, [from, to] in seconds; waveform, its peak envelope to draw it by, about
1000 points from 0 to 1, as a render’s; progression_a, progression_b, bars_per_chord; kick, snare and hats, a strength for each sixteenth of a bar; bass, in words), and audio, its id and the tracks claudius keeps of it until it analyzes another
GET /api/listened/{id}/{track}a track of the recording analyzed last as a WAV file, id its answer’s heard.audio.id: recording, and with the ears the parts it took it apart into, vocals, drums, bass and other; 404 once another is analyzed
POST /api/remake?name=FILEa recording to rework (or flip, or remake), sent as for /api/analyze; optional genre, seed, bpm, sampled and flip in the query, as for remake, and a ticket that stop_remake names it by; answers with a reply
GET /api/projectthe open song as a project file (application/octet-stream, named after the song in Content-Disposition): the song, the recordings it plays and its release; what stays out of it (Apple loops, a pack’s sounds, a file this computer no longer has) is said in X-Claudius-Note; 404 with no song
POST /api/project?name=FILEa project the demo saved, as the file itself (a .claudius, or the .zip an earlier demo saved: both are zips) with Content-Type: application/zip or application/octet-stream (300 MB at most), named in the query; claudius unpacks it into a song folder of its own under ~/Music/claudius, named after the file, and opens it there; answers with a reply
/mcpthe MCP endpoint
POST /api/phoneserves the page a phone plays along on, with a new key (or answers with the one being served): {"url": "http://192.168.1.23:7879/?key=…", "phones": 0}, also in the state as phone; 503 when the computer is on no network
DELETE /api/phonestops serving it
POST /api/chat/agent{"agent": "claude"} (claude, gemini or codex): starts that agent for the chat, which claudius runs on this computer and talks to over the Agent Client Protocol, in place of one running; the state’s chat.agent names it while it runs. A claudius others reach (--public, a token, --files) says no, as chat.starts_agents does (security)
DELETE /api/chat/agentstops it
POST /api/transportwhere the studio’s song is, {"playing": true, "at": 12.5} (seconds from its start), for the phone’s page to follow; the studio sends it as it plays while the page is served
GET / and anything elsethe web studio; when it is not built, a page that says how to build it

state, since, settled and timeout combine as described below; timeout is in seconds, 20 by default and 600 at most.

Versions and long polling

Two numbers tell a client what changed:

  • version goes up on every change to anything in the state: a log line, the progress of a job, a new render, an edit.
  • song_version is the version at which the song itself last changed. A render belongs to the song version it was made from, in render.version, so the render is current when render.version >= song_version.

A client keeps itself up to date with one request in flight:

curl -s http://127.0.0.1:7878/api/state                 # version 7
curl -s 'http://127.0.0.1:7878/api/state?since=7'       # returns when the version passes 7, or after 20 s

since=N answers as soon as the version is greater than N, and after timeout seconds otherwise, with whatever the state is then. The client takes the version of each answer as its next since. A since ahead of the server’s version, as after a restart, waits out the timeout once and then answers with the current version.

settled=1 waits for something else: that no job is running and that the render is of the current song. That is the moment the verdict describes the song as it is now. When the session renders only on request (--no-auto-render) and no render was asked for, it is settled at once. settled takes precedence over since.

curl -s -X POST http://127.0.0.1:7878/api/command -H 'Content-Type: application/json' \
  -d '{"cmd":"new_song","genre":"house","seed":9,"bpm":126}'
curl -s 'http://127.0.0.1:7878/api/state?settled=1&timeout=120'    # returned after 6.5 s, with the render and verdict

The MCP tools wait the same way after every edit.

The state

GET /api/state returns a State. Here it is after the request above, with long lists cut short:

{
  "version": 7, "song_version": 2, "busy": null, "progress": null, "cancellable": false, "ears_loading": false,
  "can_undo": true, "can_redo": false,
  "undo_label": "new song: Crimson Tide — house at 126 BPM in G dorian (seed 9)", "redo_label": null,
  "log": ["sample library: Apple Loops and your folders",
          "new song: Crimson Tide — house at 126 BPM in G dorian (seed 9)",
          "rendered in 6.3 s: -9.9 LUFS, verdict 92.6 — 93/100 (arc 0.86, mix 0.92, theory 1.00). Fix first: nearly mono (correlation 0.96): widen pads, chords and effects; the drop is only 2.8 LU louder than the breakdown (aim for 3-7): thin the break or push the drop"],
  "genres": [{ "name": "deep_house", "family": "house", "aliases": ["deep", "soulful house", "lounge house"],
               "description": "Deep house: softer four-on-the-floor, ...", "bpm": [118.0, 124.0] }],
  "song": {
    "title": "Crimson Tide", "genre": "house", "seed": 9, "bpm": 126.0, "key": "G dorian", "swing": 0.5257842,
    "bars": 72, "seconds": 137.14285714285714,
    "progressions": [["A", ["i7", "IV9", "i7", "VIImaj7", "i7", "IV9", "i7", "V7"]], ["B", ["i7", "ii7", "i7", "VIImaj7"]]],
    "sections": [{ "name": "intro", "kind": "intro", "start_bar": 0, "bars": 8, "energy": 0.35950592,
                   "layers": ["kick", "hat", "perc"], "prog": "A", "variant": "sparse",
                   "filter_in": true, "build": false, "gap": false, "impact": false, "fills": false }],
    "layers": ["kick", "clap", "hat", "ohat", "shaker", "perc", "bass", "chords", "pad", "lead", "arp"],
    "tracks": [{ "name": "kick", "kind": "drum", "role": "kick", "sound": "sampled bd (tr909:bd)",
                 "level_db": 0.0, "pan": 0.0, "reverb": 0.0, "delay": 0.0, "duck": 0.0,
                 "muted": false, "solo": false, "loudness": -13.0, "fx": [], "bus": "drums" }],
    "drums": [{ "lane": "kick", "pattern_bars": 4,
                "variants": [["main", [0.99353635, 0.0, 0.0, 0.0, 0.9903264, 0.0, 0.0, 0.0]]] }],
    "parts": [{ "name": "bass", "role": "bass", "style": "syncopated", "styles": ["offbeat", "syncopated", "offbeat"],
                "preset": "saw_bass", "presets": ["organ_bass", "pluck_bass", "saw_bass", "sub_bass", "808", "reese",
                "acid", "wobble", "log_drum", "fm_bass", "rubber_bass", "moog_bass", "dist_bass", "deep_bass",
                "salamander:piano"],
                "register": [33, 52], "density": 0.42195085 }],
    "script": "// Crimson Tide — house (seed 9)\n// song(\"house\", 9);   // uncomment to start over from the generator\n...",
    "lineage": ["generated: house seed 9"]
  },
  "render": {
    "version": 2, "url": "/api/audio/2.mp3", "seconds": 137.75695833333333, "lufs": -9.918853251636394,
    "true_peak_db": -1.05, "bpm": 126.0,
    "sections": [["intro", 0.0, 15.238095238095237], ["groove", 15.238095238095237, 76.19047619047619]],
    "waveform": [0.7832023, 0.6933847, 0.24473634, 0.7832023],
    "stems": []
  },
  "verdict": {
    "total": 92.55483794905726,
    "summary": "93/100 (arc 0.86, mix 0.92, theory 1.00). Fix first: nearly mono (correlation 0.96): widen pads, chords and effects; the drop is only 2.8 LU louder than the breakdown (aim for 3-7): thin the break or push the drop",
    "scores": [["arc", 0.8594193282170034], ["mix", 0.92], ["theory", 1.0]],
    "issues": [[0.35, "nearly mono (correlation 0.96): widen pads, chords and effects", "width+"],
               [0.0695062248036405, "the drop is only 2.8 LU louder than the breakdown (aim for 3-7): thin the break or push the drop", "form"]],
    "ears": null,
    "measures": [["arc_correlation", 0.76], ["band_air_db", -18.5], ["band_low_db", -3.4]]
  }
}

State

fieldtypemeaning
versionintegergoes up on every change
song_versionintegerthe version of the last change to the song
songSongView or nullthe open song, null before the first one
renderRenderView or nullthe latest finished render; it may be of an older song version while a new render runs
verdictVerdictView or nullthe verdict of that render
busystring or nullthe running job: "rendering", "listening", "mutating: judging 4 variations", "evolving: generation 2 of 3 done", "saving", or a step of listening to a recording sent with /api/sample, /api/groove, /api/remake or /api/analyze: "taking song.mp3 apart into its voice, drums, bass and the rest", "sampling the voice of song.mp3"
progressnumber or null0 to 1, when the job knows it
cancellableboolwhether busy is a job that cancel stops; a step of listening to a recording runs to its end
ears_loadingbooleanearshot’s models are still loading; until they are, verdicts come from the meters and music theory only
can_undo, can_redoboolean
undo_steps, redo_stepsintegerhow many edits undo can take back, one at a time, and redo can bring back
undo_label, redo_labelstring or nullwhat undo would take back, what redo would bring back
historyDone listthe last 200 changes made to the song, the latest first, as its history keeps them: each change’s id (what go_back takes), its kind (edit, undo, redo, back for a going back, or moved when a save copied the song’s takes into its folder), its label (what undo calls it), what it changed in words (said: “added the whistle track (lead), playing the synth whistle; tempo 124 to 128”), when (at, milliseconds since 1970), and whether go_back can still take the song back to before it (can_go_back)
logstringsthe last 200 lines of the session log, oldest first
genresGenreInfo listevery genre: name, description, bpm range
releaseReleaseView or nullthe release in the making for the song: its details (as set_release takes them), song_title, what the artwork is and its artwork_version, the checks (each a level, problem, warning or note, what it is about and its message) of the render checked, whether it is ready, where the last kit went, and the made_options
pitch_checkPitchCheck or nullthe last pitch check asked of the person: its id, bpm, the notes to play (t and d in beats, p MIDI), where each phrase’s answer goes (answers, beats), how long it lasts (beats), the asker’s note, its status (waiting, taken or cancelled), and, once sung, claudius’ answer
voicestring or nullthe person’s voice as their last pitch check heard it, in words
piecesPiecesView or nullthe auto-sampler’s last offer: the recording, the take’s seed, and its pieces, each with its id, place in the recording, bars, how sung it is, where its phrase is sung (from and to, in seconds) and the section of the recording it is in (“hook 2”), where to hear it as it was cut (raw) and treated, and its treatment in words
chatChatViewthe chat with the assistants: its messages (the last 200, the oldest first; each with its id, higher than the one before, after a clear too, from (null for the person, else who wrote it), text, at in ms since 1970, and reply_to), and the assistant listening now with listening_until (ms since 1970), or null
take_requestTakeRequest or nullthe last take someone asked the person to record: its id, from, role, name and note as request_take gave them, its status (waiting, taken or cancelled), and, once taken, claudius’ answer to the take

SongView

fieldmeaning
title, genre, seed, bpm, key, swingthe song’s settings; key reads like "A minor"
bars, secondsits length
progressions[name, [numerals]] pairs, "A" and "B" in generated songs
sectionsSectionView per section: name, kind, start_bar, bars, energy, layers, prog, variant, the flags filter_in, build, gap, impact, fills, and takes: where it starts in each take it plays, in bars from the take’s start
layersevery name a section can switch on: drum lanes, parts, loops, pattern tracks
tracksTrackView per track: name, kind (drum, part, loop, pattern, fx), role, sound in words, the mix (level_db, pan, reverb, delay, duck, muted, solo), its bus, its chain of effects fx (each as the song keeps it, a map named by fx, as fx() writes it), loudness in the master (LUFS while playing) once rendered, and for a take, seconds: how long its recording is
mixMixView: the buses as [name, effects], the master chain, its lufs and ceiling_db, and the reverb and delay the sends feed
drumsDrumView per lane: lane, pattern_bars, variants as [name, velocities] with one velocity per sixteenth (0 for none), and trigs as [name, [[step, trig]]] for the steps with a trig (prob, cond, ratchet, ramp, flam, nudge, pitch, decay, tone, pan, each only where it differs from its default), and the lane’s own time and feel as lane() sets it: length (sixteenths before it starts again, when it has a length of its own), speed (1), swing (when it has its own), groove and groove_amount (1)
groovesthe names of the grooves the song keeps, heard in recordings or written as tables; lanes play them as they play claudius’ own
partsPartView per generated part: name, role, style, the styles its genre offers, preset, the presets it may switch to, register (MIDI low, high), density, and cycles: for each progression its sections play, then each it has notes written out for and plays nowhere now, prog, the beats its cycle comes round in, whether it is written out, and its notes ({t, d, p, v}, beats from the cycle’s start), as the theory engine writes them or as written
scriptthe song as a script; running it on the song changes nothing
lineagewhat was done to the song, oldest first

The last entry of tracks is always fx, the transition effects (crashes, risers, impacts), whose mix scripts set with mix("fx", ...).

RenderView

fieldmeaning
versionthe song version it was rendered from
url/api/audio/<version>.mp3; the same path ending in .wav gives the 24-bit master
seconds, lufs, true_peak_db, bpmthe master’s length and loudness
sections[name, start seconds, end seconds], for drawing the arrangement
waveformabout 1000 peak values from 0 to 1
stemstrack names with a stem at /api/stems/<version>/<name>.wav (empty unless rendered with stems)

VerdictView

fieldmeaning
total0 to 100
summaryone line: the total, the scores, the first three issues
scores[name, 0..1] for mix, arc, theory, and with the ears genre, production (and refs)
issues[severity 0..1, what, where to fix it], worst first
earsEarsView or null: genre_query, genre_z, best_alt, best_alt_z, production_z, worst_flaw, worst_flaw_z, sounds_like, p_real
measures[name, value] meters: lufs, true_peak_db, band_*_db, stereo_correlation, drop_minus_break_lu, …
fixes{target, label} for each issue one change fixes (the quick_fix command makes it), absent when none

The critic and the ears explains every score, measure and issue target.

Commands

POST /api/command takes one command as a JSON object tagged by "cmd", with Content-Type: application/json. The fields marked optional may be left out.

cmdfieldswhat it does
new_songgenre; optional seed, bpm, key, loops (false), sampled (as the genre is), sample_search, complexity (0 to 1; the genre’s own)composes a new song; sampled builds it on samples from free libraries, sample_search searches for its phrase with your words (Songs built on samples), complexity says how layered it is
loadpathopens a song folder, a blueprint.json, a script file (run on the open song), or a project the demo saved (a .claudius file, or the .zip an earlier demo saved, unpacked into a song folder of its own under ~/Music/claudius)
open_textname, textopens a song from a file’s text, as the studio sends a file chosen on its computer: a blueprint.json’s when name ends in .json, otherwise a script’s; saving makes a song folder of its own
saveoptional path, optional stems (true: each track on its own in stems/)writes blueprint.json and song.rhai now, then the whole folder from a render (see Jobs); default folder: the one the song lives in under ~/Music/claudius (opened from or saved to), else ~/Music/claudius/<genre>-<title>-<seed>
rename_songtitlegives the song another title, an edit undo takes back; a song saved in a folder claudius named moves to the one its new title names, with its history, and is saved there
exportformats (such as ["mp3", "flac:16"]), optional pathwrites the latest render in those formats, when it is of the song as it is now (otherwise: the song has changed since its last render: render it, then export); default folder as for save
set_releasedetails (every field of ReleaseDetails: artist, title, writers, made …), optional artwork (a JPEG or PNG file)replaces what stores are told about the release, and checks it again
write_kitoptional pathwrites the release kit from the latest render, when it is of the song as it is now and nothing stops the release; default release/ in the song’s folder
set_tempobpmas tempo()
set_keykeyas key(): the progressions follow a change of mode
set_swingswingas swing()
set_progressionname, chords (strings)as prog()
set_sectionindex; optional name, bars, energy, layers, prog, variant, filter_in, build, build_style (classic, roll, sweep, riser or drop_out, or several stacked with +, as roll+riser; naming one turns the build-up on), build_amount (0 to 1), build_bars (the bars at the section’s end the build-up takes, 0 for each part’s own length; naming some turns it on), gap, gap_beats (how long the gap lasts, in beats; turns it on), impact, fills, source (where it starts in the song’s takes, in bars from their start: 16.25 is a beat into the 17th bar) and take (the take source is for; every take when not given)changes any of a section’s properties; with source, the section plays the takes from there
add_sectionafter, kind, bars, like (optional)inserts a section of kind after index after, set as the section named like, else as the song’s nearest section of the kind, else as the genre writes the kind (its layers and energy), else, for a bridge, as a bridge of the song’s own (under its neighbours, its drums thinned to those that keep time, on chords of its own that lead into the section after it), else as section after at the kind’s energy; with none of the song’s takes, so that every other section plays the same stretch of them
remove_sectionindexremoves a section (a song keeps at least one)
move_sectionfrom, tomoves a section
split_sectionindex, atsplits a section at bars in (1 to its length less one): the first keeps its name, how it starts and where it plays each take; the second (verse_b) plays each take on from where the section had reached it, keeps how it ends (a build-up, a gap), and starts its chords again from the first
toggle_layersection, layerswitches a track on or off in a section
set_drum_steplane, variant, step, velocitysets one sixteenth (0 removes the hit); a new variant starts as a copy of main
set_drum_patternlane, variant, stepsa whole variant in step notation, as drum()
set_triglane, variant, step (a sixteenth, from 0); optional trigwhat the step does beyond striking, as trig() sets it; no trig clears it, and a step without a hit gets one
set_lanelane; optional length (0: its pattern’s), speed, swing (0: the song’s), groove ("": none), groove_amount, late_ms (-80 to 80: every hit that far behind the beat; ahead, below zero)the lane’s own time and feel, as lane() sets it
set_partname; optional style, preset, register ([low, high]), density, reseed (false), late_ms (-80 to 80)as part(); reseed writes the part again with a new seed
add_trackname (one word of letters, digits, _ and -, not one the song has), kind (drum or part); optional role (a part’s: bass, chords, pad, keys, lead, arp), sounda drum lane, silent until its steps are written, playing sound (a drum voice or a kit’s tr909:bd), as drum() and drum_sound(); or a part of your own, as part() with a role, playing sound (a synth preset or an instrument; the genre’s draw when left out). It plays where the form names it, else in every section with energy 0.6 or more
remove_tracknamea drum lane, part, loop, take or pattern track out of the song and every section, as remove()
set_notespart, prog; optional notes ([{t, d, p, v}], beats from the cycle’s start; velocity 0.8 when left out)the part’s notes over that progression written out, as notes(): they replace what the theory engine writes there (an empty list rests); without notes, the theory engine writes it again, as clear_notes()
set_mixtrack; optional level_db, pan, reverb, delay, duck, drive_db, muted, solo, busas mix()
set_fxtarget (track:<name>, bus:<name>, master, send:reverb, send:delay), fx (effects as TrackView.fx has them; a send takes exactly one)replaces that chain, as fx(), bus(), master(#{ fx }) and send_fx() do; an effect it cannot read is refused with its place and why
run_scriptcoderuns a script on the song
analyzepaththe analysis of an audio file, as text in the reply’s message
song_likeoptional genre, seeda new song like the recording analyzed last, in the genre (the open song’s by default): its tempo, halved or doubled into the genre’s range when it is outside, its key, progressions, form and swing, none of its sound
change_genregenre (any number fused with +); optional seedthe song in another genre, one change undo takes back: its form, chords and key, recordings, written notes, lead melody and pattern tracks kept, the genre’s drums, bass, parts, sounds, swing and mix playing it (Changing the genre)
tunetrack; optional strength, speed_ms, humanize, vibrato, scale (chords, key, chromatic or notes such as "C D E G A"), offa tune effect first in the track’s chain, the one there changed with what is given, or with off taken out (Tuning a voice)
assess_voicetake, or path and optional keyhow a take of the song or an audio file is sung (Your voice), as text in the reply’s message; changes nothing
remakepath; optional genre, seed, bpm, sampled (true), flip (false)a rework of the file in the genre, all of it through in its own sections and on its chords with the genre’s drums and bass under it (Remaking a song from audio); flip: true, a new song of the genre on its hook and pieces of it; sampled: false, a new song on its skeleton only; the genre defaults to the open song’s, and the tempo to the recording’s, or double or half it when that is nearer the genre’s range (half only where the recording holds its chords two bars)
harmonizepart; optional style (block, the default, a chord style: sustain, half, stabs, offbeat, pump, syncopated, charleston, or a comping idiom: skank, gospel, house_piano …), sound, name (<part>_chords)chords under the part’s melody, as a new part that harmonizes it, on in the sections the melody plays in; for block, on the melody’s own sound
generate_trackwhat (drums, percussion, bass, chords, keys, pad, strings, lead, arp); optional genre (the song’s), replace (a part of the song), name (<genre>_<what>), seeda track written the way the genre plays it: a part as the genre’s own part of the role is (its idiom, a sound from its palette, its register, density, voicing and mix), added where the song plays its part of the role or in place of replace (its name, mix and sections kept); the genre’s drums in place of the song’s lanes of their names and beside the others; its percussion beside the song’s drums. Each is another take
vary_tracktrack (a part or a drum lane); optional take (false)a variation of the take it plays (a part’s idiom keeps its cells and draws their details again; a lane is varied a step or two, its strong hits kept), or with take, another take (a part’s seed anew; a lane from the template of the genre it was written as, the song’s or the one its drums were generated from)
swap_soundoptional track (a part or a drum lane), to, only (drums or parts, with no track)another sound for the track: to (one of its swaps, or any synth preset, installed instrument or drum sound), or its next_swap, the next of its swaps no other track plays; block chords under a part change with it. With no track the whole song swaps: the drums onto the next_kit (or to, one of kits) and each part onto its next sound. It runs as part() with a preset and drum_sound(), so every note, pattern and mix setting stays; a part played by a rack runs as rack(), the layers that play the sound it is heard by on the new one and the rest (the sub under a stacked bass) as they were
add_takepath, from (a section’s name); optional name (take1, take2, …), role (vocal, lead, chords, keys, bass, drums, texture; lead)the recording as a take: it plays once from the start of section from and on through the sections after it as long as it lasts; the song keeps a copy
trim_taketrack; optional start (0) and end (its end), in seconds into its recordingthe take cut down to that much of its recording (Takes): it plays from the start of the same section, the sections past its new end drop it, and the recording stays for undo
sample_piecespath (a file, or library:<id>); optional seed (0: the best; any other: another draw), count (phrases, 2, 1 to 4), bars (1 to 8; the fewest of 1, 2, 4 or 8 each phrase fits in), find, kinds (phrase, hook, passage, break, bass, stab; every kind it holds by default)the auto-sampler’s pieces of the recording, the phrases numbered as they come in it, each as it was cut and through a treatment, in pieces (each with its kind and what it scored for, about), before any goes into the song; when phrases were asked for and none could be cut but other pieces could, those are offered and no_phrase says why
redraw_piecesoptional seed (the next take)the same recording’s pieces drawn again, other pieces than the last where there are any
keep_pieceskeep ([{"id": 1, "treated": true, "chopped": false}]); optional sections, every (once, 2, 4, 8, 16 or through; as the song suits)the pieces chosen sampled into the song, each as it was cut or through its treatment, whole or chopped onto pads (chopped), coming round as every says; the offer goes
sample_songpath; optional count (2, 1 to 4), bars (1, 2, 4 or 8; a passage 4, 8 or 16), find (“a person singing”), sections, how (phrases, passage, chops or stabs), every (as for keep_pieces), kinds (as for sample_pieces)samples the recording’s vocals into the song: its best phrases sung whole, those sample_pieces offers first, as loops vox1, vox2 …, placed and mixed; with kinds, the best piece of each kind, kept as its kind plays. The reply says where each came from and went
extract_groovepath; optional name (the file’s), lanes (every drum lane), bpmthe groove of the recording’s drums, kept with the song, and the lanes put in it; its tempo is bpm, else an Apple Loop’s from GarageBand’s catalogue, else one in the file’s name (92bpm), else heard. The reply says the tempo and what it heard
transcribe_drumstake, or path; optional bars (1, 2 or 4; the recording’s, up to 4), variant (main), bpm, keep_take (false)a beat, played or beatboxed, as the song’s drums: its kicks, snares and hats folded into a pattern and written into the kick, snare (else clap) and hat lanes; steps hit only some times round play with that chance; a take goes quiet unless keep_take
add_hitsfrom (a section’s name), hits ([{lane, t, v}]: the lane struck, beats from the section’s start, velocity, 0.8 when left out); optional bars (1, 2 or 4; as much of 4 as was played), variant (main), grid (0.25, a sixteenth; 0 keeps the hits where they were played), start and beats (when the take began and how long it went on, in beats from the section’s start; 0 and its last hit)drums played on pads (a phone’s, a MIDI controller’s) as the lanes they strike, folded into a pattern; a step struck only some of the times round plays with that chance, as hard as it was struck on average
add_scratchfrom (a section’s name), track (one of the song’s tracks, * for the whole mix, or a sample from the library as the phone’s GET /api/library names it, lib:...), optional recording (a record recorded off a microphone in place of the track’s, a WAV file in base64, up to 10 s; mono at 24 kHz, as the phone sends it, keeps a command under its 1 MiB), moves ([{t, at, fader}]: seconds into the scratch, seconds into the record, the crossfader from 0, shut, to 1, open, open when left out); optional bar (0, the first), bars (1, up to 8), name (scratch1, scratch2, …), role (lead)a scratch kept as a take that plays from the start of section from: the track alone over the bars is the record, read back and forth along the moves through the crossfader
transcribe_taketake, sounds (presets or instruments); optional name (melody), role (lead), chromatic (false), keep_take (false), style (line)the take’s melody as notes, played by a new part for each sound; the take goes quiet unless keep_take
add_notesfrom (a section’s name), notes ([{t, d, p, v}]: beats from the section’s start, length in beats, MIDI pitch, velocity, 0.8 when left out), sounds; optional name (played), role (lead), style (line), request (the take request the notes answer)notes played or written, chords and all, as a new part for each sound
request_takefrom (a section’s name); optional role (as add_take’s, or a part’s: pad, arp …), name, note (what to record, for the person)asks the person to record a take: the studio’s Record window opens for it; the request goes in take_request, waiting, and replaces one asked before
cancel_take_requestidthe person will not record the take asked for, as the Record window’s Not now says
chat_saytextthe person writes to the assistants in the studio’s chat (4000 characters at most)
chat_answertext; optional from (who writes: “an assistant”), reply_to (the id of the message it answers)an assistant writes in the chat, as send_message does
chat_listenoptional from, seconds (50, 1 to 300)an assistant listens for what the person writes: chat.listening names it until 20 s after seconds
clear_chatthe chat’s history goes, in the state and in chat.jsonl
request_pitch_checkoptional low and high (MIDI, default 57 and 69), noteasks the person for a pitch check: the Record window opens with its phrases; it goes in pitch_check, waiting, and replaces one asked before
cancel_pitch_checkidthe person will not do the pitch check now
quick_fixoptional target (one of the verdict’s fixes; none: all of them)makes the verdict’s quick fixes as one edit; refused while the verdict is of the song before its last change
mutateoptional count (4, 1 to 32), keep_best (true)a job: tries variations and keeps the best if it beats the song
evolveoptional generations (3, 1 to 20), children (6, 2 to 32)a job: an evolutionary search from the song
install_packsoptional names (the missing default packs when left out)a job: downloads sample packs, as claudius setup does; not the opt-in packs, whose licence is unclear, and not on a shared claudius
renderoptional stems (false)a job: renders and judges the song
undo, redo
go_backto (a change’s id in the state’s history)the song as it was before that change: it and every change since are undone, as that many undos would, and redo brings them back one at a time; refused for a change undo can no longer take back (can_go_back false)
togethersaid (what undo calls it), commands (edits of the song: set_mix, set_tempo, set_key, swap_sound, toggle_layer, remove_track and the other edits, but no undo, redo, go_back or together)the edits made as one change, which the history records as one and undo takes back at once; when one fails, none is made and the song stays as it was. The palette sends it for a request in plain words a person confirmed
cancelstops a mutation or evolution after its current candidate or generation
stop_remaketicket (the one sent with /api/remake)stops that remake wherever it is: under way, its file still on its way, or not arrived yet; it answers stopped, and the song stays as it was
{"cmd": "set_tempo", "bpm": 124}
{"cmd": "set_section", "index": 0, "energy": 0.5, "layers": ["kick", "hat"]}
{"cmd": "set_drum_step", "lane": "kick", "variant": "main", "step": 3, "velocity": 0.6}
{"cmd": "set_part", "name": "bass", "style": "rolling", "reseed": true}
{"cmd": "add_track", "name": "lead2", "kind": "part", "role": "lead", "sound": "saw_lead"}
{"cmd": "add_track", "name": "conga", "kind": "drum", "sound": "tr909:lt"}
{"cmd": "run_script", "code": "tempo(126); mix(\"lead\", #{ level: -2 });"}

set_tempo, set_key, set_swing, set_progression, set_drum_pattern, set_part, add_track, remove_track, set_notes and set_mix are turned into the matching script call and run as a script, so they accept exactly what the script functions accept and fail with the same messages (add_track checks its name first). The other edits change the blueprint directly. Every edit that changes the song is one undo step with a label, and starts a render after 200 ms unless the session runs with --no-auto-render.

Jobs

render, mutate, evolve and save are jobs. A job runs on its own thread, one at a time, and the command answers as soon as it has started. Follow it in busy, progress and log, or wait with settled=1. A mutate or evolve while a job runs is refused, and the refusal leaves the version as it was; render and save wait for the job in progress instead:

{"ok": true, "message": "rendering after the job in progress", "version": 4}
{"ok": false, "message": "busy (rendering); try again when it is done, or cancel it", "version": 4}

A save writes blueprint.json and song.rhai at once. Asked for while the session is idle, it starts its own render; asked for during a job, such as the render that follows an edit, it waits, and the job slot passes straight to it when that job ends, so the session never looks idle in between and settled=1 waits for the save too:

{"ok": true, "message": "saving to /tmp/cl-save2 (blueprint.json and song.rhai now, the audio after the render)", "version": 14}
{"ok": true, "message": "saving to /tmp/cl-save2: blueprint.json and song.rhai now, the audio once the current job (rendering) is done", "version": 4}

Either way the save renders the song as it is when its turn comes and rewrites the whole folder from that render, so the score in it is always the song its audio plays: song.wav, song.mp3, blueprint.json, song.rhai, project.json, report.json, verdict.json, credits.txt when sample packs play, and with "stems": true each track’s stem in stems/ as 32-bit float, about 120 MB a track for a five-minute song. Each file appears only once it is whole, and a write that fails leaves the file as it was. The log then says saved <folder>, or could not save <folder>: <reason>, as when the disk has no room for the folder’s audio and 256 MB to spare:

could not save /Users/me/Music/claudius/house-neon-7: there is not room for it on the disk: it takes about 1.4 GB, and 900 MB is free (the stems are 1.3 GB of it)

cancel does not stop a render that has started.

Replies and errors

Every command answers with a Reply:

fieldmeaning
okwhether the command did what it was asked
messagewhat happened, or why not
versionthe state version after the command
{"ok": true, "message": "new song: Crimson Tide — house at 124 BPM in G dorian (seed 9)", "version": 2}
{"ok": false, "message": "no progression 'Z' (there are A, B)", "version": 11}
{"ok": false, "message": "Runtime error: expected ']', found the end (line 1, position 12)", "version": 11}

A command claudius understood but refused (a bad edit, a script error, a busy session) answers 200 OK with "ok": false, and changes nothing. The HTTP status says when the request itself is wrong:

statuswhenbody
400 Bad Requestthe JSON is not a commanda Reply whose message starts with not a command: and names the unknown cmd or the missing field
401 Unauthorizeda token is required and missing or wrongthis claudius needs its token (Authorization: Bearer <token>, or ?token=<token>)
403 Forbiddenthe Host header is not a loopback name and the server is not --publicclaudius only answers on localhost (start it with --public and a --token to share it)
404 Not Foundno such render or stemno render of version 999, no stem 'kick' in render 13 (render with stems), audio is /api/audio/{version}.wav or .mp3
413 Payload Too Largea command body over 1 MiBFailed to buffer the request body: length limit exceeded
415 Unsupported Media Typea command without Content-Type: application/jsoncommands are JSON (Content-Type: application/json)

Audio

/api/audio/{version}.wav and .mp3 serve the render of song version version, with Range requests, so players can seek:

$ curl -sI -H 'Range: bytes=0-99' http://127.0.0.1:7878/api/audio/13.wav
HTTP/1.1 206 Partial Content
content-type: audio/wav
accept-ranges: bytes
content-range: bytes 0-99/72955106
content-length: 100

The MP3 is encoded on the first request (a second or two for a song) and kept. A session keeps its last ten renders on disk, so older versions return 404. Stems exist only for a render made with {"cmd": "render", "stems": true}, and only the latest render’s stems are served and kept, as 24-bit WAV; the copies a save with stems writes into the song folder are 32-bit float.

The live mix

/api/window?from=S&secs=N mixes N seconds of the song as it is now, from S seconds in, from the tracks the last render made, through the buses, returns and master, at the loudness that render settled (design 0023). The studio asks for one window after another from just after its playhead while the song plays and is newer than its render, so that a fader, a pan or a send is heard as it moves. The body is the song’s version, the window’s first sample and its sample rate, each 8 bytes little-endian, then the samples, left and right in turn, as 32-bit floats:

$ curl -s 'http://127.0.0.1:7878/api/window?from=2&secs=0.5' | head -c 24 | od -A d -t u8
0000000                   14               96000
0000016                48000

When there is no window to be had that way, the answer is a 409 that says why, and the next render plays the song: no song or no render yet, an edit of a track’s own sound (bass changed its sound: the next render plays it), or of the song’s length.

Who may call it

The server is written for one person on one computer, and opens up only when asked. The security model has the reasoning; these are the rules as a client sees them.

Host names. Without --public, every request must name a loopback host in its Host header: localhost, 127.0.0.1 or [::1], with any port. Anything else gets 403, which stops a web page from reaching claudius through DNS rebinding. It is not access control: any program on the machine can send Host: localhost.

Tokens. With --token <secret> (or CLAUDIUS_TOKEN), and always with --public, which makes a token when it is given none, every request must carry the token, in one of three ways:

  • Authorization: Bearer <secret>;
  • ?token=<secret> in the URL, which also answers with Set-Cookie: claudius_token=<secret>; Path=/; HttpOnly; SameSite=Strict, so a browser opened at /?token=<secret> keeps working without it. When the request came through https (X-Forwarded-Proto: https, which tunnels send), the cookie is also Secure;
  • that cookie.

The comparison takes the same time wherever the strings differ. CORS preflight requests (OPTIONS) are answered before the token check, so a browser can ask what is allowed.

Commands are JSON. /api/command refuses any other content type, and the MCP endpoint does the same, so a page on another site cannot send a command with a plain form post or a no-cors fetch.

CORS. Cross-origin requests are allowed from pages served by http://localhost, http://127.0.0.1 and http://[::1] on any port, for GET, POST and DELETE, with the headers Content-Type, Authorization, mcp-session-id and mcp-protocol-version. Pages from anywhere else, including https://localhost, get no Access-Control-Allow-Origin, so the browser does not let them read the answer.

Security headers. Every response carries:

x-content-type-options: nosniff
referrer-policy: no-referrer
x-frame-options: DENY
content-security-policy: frame-ancestors 'none'

so a browser does not guess content types, leak the address in a Referer, or let another page frame the studio.