lmaudio reference

Every type, method, flag and exit code of lmaudio 0.2.2, generated from the schema and signature list that the released binary prints, with notes from the repository README and examples.

Command line

usage: lmaudio --version | --notices | --lmcode-schema [--json] | --lmcode-signatures | [--dry-run] --lmcode FILE [FILE ...]
Command or variableEffect
lmaudio --versionPrints the release identity, for example lmaudio 0.2.2.
lmaudio --noticesPrints the third-party software notices with the upstream license texts.
lmaudio --lmcode-schemaPrints the embedded schema as readable JSON.
lmaudio --lmcode-schema --jsonPrints the exact schema bytes the compiler binds a program to (schema version 2, name lmaudio).
lmaudio --lmcode-signaturesPrints every canonical signature the host registry provides, one per line, standard catalog included.
lmaudio --lmcode FILE [FILE ...]Runs compiled lmcode program files. This is what run_lmcode calls; the compiler owns the program files.
lmaudio --dry-run --lmcode FILERuns a program without writing any file. The flag comes before --lmcode. The result envelope carries dry true.
LMAUDIO_MAX_MEMORY_MBEnvironment variable: total memory budget in MiB, default 4096. A value that is not a positive whole number is a usage error on every command.

Exit codes and result envelope

Exit codeEnvelopeMeaning
0ok trueThe program ran and every audio.assert_close held.
2phase cli, code CLI_USAGEUnknown or misplaced arguments, or an invalid LMAUDIO_MAX_MEMORY_MB.
3phase load, for example code LOAD_BAD_BYTECODE or LOAD_UNBOUNDThe program file cannot be read, or it imports a function the host does not provide.
3phase run, code RUN_HOSTA host error with a source line and column: a failed audio.assert_close, a missing WAV file, an invalid argument, or the memory budget being exceeded.
Envelope fieldTypePresentMeaning
okboolalwaystrue when the run succeeded
resultJSON valuesuccesswhat the block stored with lmcode_return_set or lmcode_return_put; null when it stored nothing
drybooldry runstrue for a --dry-run invocation
phasestringfailurecli, load or run
codestringfailurefor example CLI_USAGE, LOAD_BAD_BYTECODE, LOAD_UNBOUND, RUN_HOST
messagestringfailurereadable message; run errors start with the block line and column
line, columnintrun failuresposition inside the block

Schema summary

ItemValue
dsl.schema2
namelmaudio
contextaudio: Audio
enumsnone
host free functionsnone
host typesAudio, Buffer, Spectrum, Spectrogram, Biquad
host signatures171 (Audio 49, Buffer 83, Spectrum 17, Spectrogram 10, Biquad 11, plus the context declaration)

Units: durations in seconds, frequencies in Hz, sr is the sample rate (100 to 384000 Hz, 44100 when the overload without it is used). Where a note names parameters, the names come from the repository README; rows without a parameter list show the types only, because the schema does not publish parameter names.

Audio (context object audio)

The context object audio. Generators return a Buffer.

MethodSignaturesNotes
silencesilence(int, float) -> Buffer; silence(float, int) -> Buffer; silence(float) -> Buffersilence(dur, sr). Sample rate defaults to 44100 when omitted.
sinesine(float, float, float, int) -> Buffer; sine(float, float, float) -> Buffer; sine(float, float) -> Buffersine(f, dur, amp, sr).
cosinecosine(float, float, float, int) -> Buffer; cosine(float, float, float) -> Buffercosine(f, dur, amp, sr).
sawsaw(float, float, float, int) -> Buffer; saw(float, float, float) -> Buffersaw(f, dur, amp, sr). PolyBLEP band-limited.
squaresquare(float, float, float, float, int) -> Buffer; square(float, float, float, int) -> Buffer; square(float, float, float) -> Buffersquare(f, dur, amp, duty, sr). PolyBLEP band-limited.
triangletriangle(float, float, float, int) -> Buffer; triangle(float, float, float) -> Buffertriangle(f, dur, amp, sr).
chirpchirp(float, float, float, float, string, int) -> Buffer; chirp(float, float, float, float, string) -> Bufferchirp(f0, f1, dur, amp, mode, sr); mode is linear or log.
impulseimpulse(float, float, float, int) -> Buffer; impulse(float, float, float) -> Bufferimpulse(dur, at, amp, sr).
noisenoise(string, float, float, int, int) -> Buffer; noise(string, float, float, int) -> Buffernoise(color, dur, amp, seed, sr); color is white, pink or brown. Seeded, so repeatable.
exprexpr(string, float, int) -> Buffer; expr(string, float) -> Bufferexpr(formula, dur, sr). Any formula in t, n, sr and dur, for example 0.5*sin(2*pi*440*t).
fmfm(float, float, float, float, float, int) -> Buffer; fm(float, float, float, float, float) -> Bufferfm(fc, ratio, index, dur, amp, sr). Chowning two-operator FM; index is β in radians.
pluckpluck(float, float, float, float, float, int) -> Buffer; pluck(float, float, float) -> BufferDaisySP string voice.
modalmodal(float, float, float, float, float, float, int) -> Buffer; modal(float, float, float) -> BufferDaisySP modal voice.
barbar(int, int, float, float, float, float, int) -> Bufferbar(bc_left, bc_right, stiffness, t60, dur, amp, sr). Euler-Bernoulli bar; boundary 1 clamped, 2 pinned, 3 free.
drumdrum(string, float, float, float, float, float, int) -> Buffer; drum(string, float, float, float) -> Bufferdrum(kind, f, dur, decay, tone, accent, sr); kind is kick, synth_kick, snare, synth_snare or hihat.
sequencesequence(string, float, string, int) -> Buffer; sequence(string, float, string) -> Buffersequence(notes, bpm, instrument, sr). Notes as text such as C4:1 E4:0.5 R:0.5 C4+E4+G4:2; instruments sine, saw, square, triangle, fm, pluck, karplus, modal, pad.
note_freqnote_freq(string) -> floatFrequency of a note name such as A4.
midi_freqmidi_freq(float) -> floatFrequency of a MIDI note number such as 69.
load_wavload_wav(string) -> BufferReads PCM16, PCM24, float32 and WAVE_FORMAT_EXTENSIBLE files.
stereostereo(Buffer, Buffer) -> Bufferstereo(left, right) builds a two-channel buffer.
biquad_designbiquad_design(string, float, float, float, int) -> Biquad; biquad_design(string, float, float, int) -> Biquadbiquad_design(kind, f, q, gain_db, sr). Returns the filter object for exact response queries.
printprint(string) -> voidWrites one report line to stderr.
centscents(float, float) -> floatcents(f, ref): pitch distance in cents.
dbdb(float) -> floatdb(x): level in decibels.
save_textsave_text(string, string) -> voidsave_text(path, text) writes a text file, for example a table for a plotting host.
karpluskarplus(float, float, float, float, int, int) -> Buffer; karplus(float, float, float, float) -> Bufferkarplus(f, dur, amp, t60, seed, sr). Karplus-Strong string with an allpass for fractional-delay tuning.
additiveadditive(float, float, float, string, int) -> Buffer; additive(float, float, float, string) -> Bufferadditive(f0, dur, amp, partials, sr). Partials are amplitudes such as 1 0.5 0.33, or ratio:amplitude pairs such as 1:1 2.76:0.5. Band-limited.
assert_closeassert_close(float, float, float) -> voidassert_close(actual, expected, tol). A failure stops the run with exit code 3.

Buffer

Mono or stereo 32-bit float audio, at most 200 million frames. Processing methods return a new Buffer.

MethodSignaturesNotes
srsr() -> intSample rate in Hz.
channelschannels() -> int1 or 2.
framesframes() -> intNumber of sample frames.
durationduration() -> floatLength in seconds.
getget(int) -> float; get(int, int) -> floatget(i) or get(i, ch): one sample.
channelchannel(int) -> BufferOne channel as a mono buffer.
to_monoto_mono() -> BufferDownmix.
gaingain(float) -> BufferLinear gain.
gain_dbgain_db(float) -> BufferGain in decibels.
normalizenormalize(float) -> Buffer; normalize() -> Buffernormalize() or normalize(peak).
lufslufs() -> floatITU-R BS.1770-4 integrated loudness with gating. Needs a sample rate of at least 8 kHz.
normalize_lufsnormalize_lufs(float) -> Buffernormalize_lufs(target).
multiplymultiply(Buffer) -> Buffermultiply(env): sample-wise product, used for envelopes and ring modulation.
convolveconvolve(Buffer) -> Bufferconvolve(ir): FFT convolution with an impulse response.
patternpattern(string, float, int) -> Buffer; pattern(string, float) -> Bufferpattern(steps, bpm, steps_per_beat). Step sequencer: X accent, x hit, o ghost, digits 1 to 9 gain, a dot is a rest and | is a bar line.
granulargranular(float, float, float, float, float, float, int) -> Buffergranular(dur, grain, density, position, pos_spread, pitch_spread, seed). Grain clouds and time-stretch.
schroeder_dbschroeder_db() -> BufferThe Schroeder decay curve as a buffer.
rt60rt60() -> floatReverberation time from T30, falling back to T20.
pitch_track_csvpitch_track_csv(string, float, float, float, float) -> Bufferpitch_track_csv(path, hop, win, fmin, fmax) writes a YIN pitch track.
normalize_rmsnormalize_rms(float) -> BufferNormalize to an RMS level.
fadefade(float, float, string) -> Buffer; fade(float, float) -> Bufferfade(in, out) or fade(in, out, shape); shape is linear or cosine.
adsradsr(float, float, float, float, float) -> Buffer; adsr(float, float, float, float) -> Bufferadsr(a, d, s, r) or adsr(a, d, s, r, gate).
panpan(float) -> Bufferpan(position) from -1 to 1, equal power. Stereo input is downmixed to mono first.
sliceslice(float, float) -> Bufferslice(start, end) in seconds.
padpad(float, float) -> Bufferpad(before, after) adds silence in seconds.
concatconcat(Buffer) -> BufferAppends another buffer.
mixmix(Buffer, float, float) -> Buffer; mix(Buffer, float) -> Buffer; mix(Buffer) -> Buffermix(other), mix(other, gain) or mix(other, gain, offset).
reversereverse() -> BufferTime reversal.
resampleresample(int) -> Bufferresample(sr). Kaiser-windowed sinc conversion.
biquadbiquad(string, float, float, float) -> Buffer; biquad(string, float, float) -> Bufferbiquad(kind, f, q) or biquad(kind, f, q, gain_db). RBJ biquads; the repository examples use lowpass, highpass, bandpass, notch, peak, lowshelf and highshelf.
svfsvf(string, float, float, float) -> Buffer; svf(string, float, float) -> BufferState-variable filter.
ladderladder(float, float, float, string) -> Buffer; ladder(float, float) -> Bufferladder(cutoff, res) or ladder(cutoff, res, drive, mode). Moog ladder filter; the examples use mode lp24.
lpf_sweeplpf_sweep(float, float, float) -> Bufferlpf_sweep(f0, f1, res): resonant low-pass sweep.
delaydelay(float, float, float) -> BufferDelay effect.
reverbreverb(float, float, float) -> Bufferreverb(feedback, lpf, wet). Feedback-delay-network reverb.
zitarevzitarev(float, float, float, float) -> Bufferzitarev(rt60_low, rt60_mid, damping, wet). A clean-room FDN with zita-rev1-style controls, not zita-rev1.
choruschorus(float, float, float, float) -> BufferModulation effect.
flangerflanger(float, float, float, float) -> BufferModulation effect.
phaserphaser(float, float, float, int, float) -> BufferModulation effect.
overdriveoverdrive(float, float) -> BufferDistortion.
wavefoldwavefold(float, float) -> BufferWavefolding distortion.
bitcrushbitcrush(int, float) -> BufferBit-depth and rate reduction.
compresscompress(float, float, float, float, float) -> Buffercompress(ratio, thresh_db, attack, release, makeup_db). Feed-forward compressor.
paulstretchpaulstretch(float, float) -> BufferExtreme time-stretch.
rmsrms() -> float; rms(int) -> floatRMS level; the int overload selects a channel.
peakpeak() -> float; peak(int) -> floatPeak level.
dc_offsetdc_offset() -> float; dc_offset(int) -> floatMean value.
energyenergy() -> float; energy(int) -> floatSignal energy.
zcrzcr() -> float; zcr(int) -> floatZero-crossing rate.
pitchpitch() -> float; pitch(float, float) -> floatpitch() or pitch(fmin, fmax). One YIN estimate for the most energetic window; 0 when unvoiced.
peak_freqpeak_freq() -> float; peak_freq(string) -> floatFrequency of the strongest spectral peak; the string overload names the window.
centroidcentroid() -> float; centroid(string) -> floatSpectral centroid in Hz.
thdthd() -> float; thd(float, int) -> floatTotal harmonic distortion; the examples call the second overload as thd(f0, 9).
snr_dbsnr_db(Buffer) -> floatsnr_db(ref): signal-to-noise ratio against a reference buffer.
spectrumspectrum() -> Spectrum; spectrum(string) -> Spectrum; spectrum(string, int) -> Spectrumspectrum(), spectrum(window) or spectrum(window, nfft). FFT of any length; windows rect, hann, hamming, blackman, flattop.
spectrogramspectrogram(int, int, string, float) -> Spectrogram; spectrogram(int, int) -> Spectrogramspectrogram(win, hop) or spectrogram(win, hop, window, fmax). STFT.
save_wavsave_wav(string) -> Buffer; save_wav(string, int) -> Buffersave_wav(path) or save_wav(path, bits) with bits 16, 24 or 32. Returns the buffer.
save_csvsave_csv(string) -> Buffer; save_csv(string, int) -> Buffer; save_csv(string, int, int) -> Buffersave_csv(path), save_csv(path, max_points) or save_csv(path, max_points, stride).

Spectrum

Returned by Buffer.spectrum.

MethodSignaturesNotes
binsbins() -> intNumber of bins.
nfftnfft() -> intTransform length.
srsr() -> intSample rate.
freq_atfreq_at(int) -> floatFrequency of bin i.
mag_atmag_at(int) -> floatMagnitude of bin i.
db_atdb_at(int) -> floatLevel of bin i in dB.
phase_atphase_at(int) -> floatPhase of bin i.
mag_at_freqmag_at_freq(float) -> floatMagnitude at a frequency.
peak_binpeak_bin() -> intIndex of the strongest bin.
peak_freq_inpeak_freq_in(float, float) -> floatpeak_freq_in(lo, hi): strongest peak between two frequencies.
peak_freqpeak_freq() -> floatFrequency of the strongest peak.
peak_magpeak_mag() -> floatMagnitude of the strongest peak.
centroidcentroid() -> floatSpectral centroid.
parseval_energyparseval_energy() -> floatEnergy computed from the spectrum.
ifftifft() -> BufferInverse transform back to a buffer.
save_csvsave_csv(string) -> Spectrum; save_csv(string, float) -> SpectrumWrites freq_hz, magnitude, db and phase_rad columns. The optional float is the highest frequency written.

Spectrogram

Returned by Buffer.spectrogram.

MethodSignaturesNotes
framesframes() -> intNumber of time frames.
binsbins() -> intNumber of frequency bins.
srsr() -> intSample rate.
time_attime_at(int) -> floatTime of frame i.
freq_atfreq_at(int) -> floatFrequency of bin i.
mag_atmag_at(int, int) -> floatMagnitude at frame and bin.
db_atdb_at(int, int) -> floatLevel at frame and bin.
ridge_freqridge_freq(int) -> floatStrongest frequency in one frame.
save_csvsave_csv(string) -> Spectrogram; save_csv(string, float) -> SpectrogramWrites the grid for a plotting host; the examples pass a dB floor such as -80.0 as the second argument.

Biquad

Returned by audio.biquad_design.

MethodSignaturesNotes
b0b0() -> floatCoefficient.
b1b1() -> floatCoefficient.
b2b2() -> floatCoefficient.
a1a1() -> floatCoefficient.
a2a2() -> floatCoefficient.
gain_atgain_at(float) -> floatExact magnitude at a frequency.
db_atdb_at(float) -> floatExact level in dB at a frequency.
phase_deg_atphase_deg_at(float) -> floatExact phase in degrees at a frequency.
applyapply(Buffer) -> BufferFilters a buffer.
save_response_csvsave_response_csv(string) -> Biquad; save_response_csv(string, int, float, float) -> Biquadsave_response_csv(path) or save_response_csv(path, points, f_lo, f_hi). Writes freq_hz, gain, db and phase_deg columns.

String arguments

The schema declares no enums; these string values are the ones documented in the repository README or used by its examples.

ArgumentValues
chirp modelinear, log
noise colorwhite, pink, brown
drum kindkick, synth_kick, snare, synth_snare, hihat
sequence instrumentsine, saw, square, triangle, fm, pluck, karplus, modal, pad
biquad and biquad_design kindlowpass, highpass, bandpass, notch, peak, lowshelf, highshelf
ladder modelp24
spectrum and spectrogram windowrect, hann, hamming, blackman, flattop
fade shapelinear, cosine
bar boundary (int)1 clamped, 2 pinned, 3 free
save_wav bits (int)16, 24, 32
pattern stepsX accent, x hit, o ghost, 1 to 9 gain, a dot for a rest, | bar line

Limits

LimitValue
Sample rate100 to 384000 Hz
Channels1 or 2
Buffer lengthat most 200 million frames
Memory budget4096 MiB by default, LMAUDIO_MAX_MEMORY_MB to change
Audio output formatWAV, 16, 24 or 32 bit
WAV input formatsPCM16, PCM24, float32, WAVE_FORMAT_EXTENSIBLE

Standard library (lmcode_std_v3)

The lmcode runtime inside lmaudio registers the standard catalog itself, so every block can call it next to the host API. lmaudio 0.2.2 reports 377 canonical signatures from lmaudio --lmcode-signatures: 171 host signatures and 206 standard ones. The current lmcode_std_v3 catalog has 226 canonical signatures; the 20 that this release does not ship are the REST and CLI group described at the end of this section. The lmaudio implementation source is private, so the public repository carries no std.lock; the count above is what the released binary reports. lmaudio picks up the remaining 20 signatures when a release built on the newer runtime ships; confirm with lmaudio --lmcode-signatures.

GroupSignaturesIn lmaudio 0.2.2Names
Strings17yesstr_contains, str_ends_with, str_find, str_is_float, str_is_int, str_len, str_lower, str_match, str_repeat, str_replace, str_starts_with, str_substr, str_to_float, str_to_int, str_trim, str_upper, template_render
Math16yesmath_abs, math_ceil, math_floor, math_max, math_min, math_pow, math_round, math_sqrt
Files5yesfile_append, file_exists, file_lines, file_read, file_write
Encoding4yesstr_base64_decode, str_base64_encode, str_hex_decode, str_hex_encode
JSON and templates12yesjson_parse, Json methods
Return values (runtime)24yeslmcode_return_null, lmcode_return_put, lmcode_return_put_null, lmcode_return_set
Collections124yesfloat_list, float_map, float_pq, float_queue, float_stack, int_list, int_map, int_pq, int_queue, int_stack, str_list, str_map, str_pq, str_queue, str_split, str_stack, FloatList methods, FloatMap methods, FloatPQ methods, FloatQueue methods, FloatStack methods, IntList methods, IntMap methods, IntPQ methods, IntQueue methods, IntStack methods, StrList methods, StrMap methods, StrPQ methods, StrQueue methods, StrStack methods
Containers4yesFloatMap methods, IntMap methods
REST and CLI20norest_config, rest_route, rest_serve, rest_stop, rest_cli and 15 RestExchange methods

Strings are raw bytes: lengths and offsets are byte based. Standard collections and Json values live for one run. Relative file paths resolve against the working directory of the host process, and the standard file functions apply no sandbox or root check. In lmaudio the lmcode_return functions are the way to send values back to LMScript.

String functions

FunctionBehavior
str_contains(string, string) -> boolByte substring search; an empty needle matches.
str_ends_with(string, string) -> boolByte suffix comparison; an empty suffix matches.
str_find(string, string) -> intReturn the first byte offset or -1; an empty needle returns 0.
str_is_float(string) -> boolAccept a complete signed decimal with optional decimal point and exponent, including representable subnormals. Reject whitespace, hex, NaN/infinity, overflow and underflow to zero.
str_is_int(string) -> boolReport whether the complete signed decimal token fits int64.
str_len(string) -> intReturn the raw byte length, including NUL and invalid UTF-8 bytes.
str_lower(string) -> stringLowercase ASCII A-Z bytes; preserve every other byte.
str_match(string, string) -> boolMatch a whole byte string with *, ?, classes, ranges, negation, and backslash escapes.
str_repeat(string, int) -> stringRepeat raw bytes; reject negative counts and platform-unrepresentable result sizes.
str_replace(string, string, string) -> stringReplace nonoverlapping byte matches left to right; an empty search leaves bytes unchanged. No implicit result-size budget.
str_starts_with(string, string) -> boolByte prefix comparison; an empty prefix matches.
str_substr(string, int, int) -> stringReturn a byte slice; clamp negative starts and overlong counts, with nonpositive counts empty.
str_to_float(string) -> floatParse the same complete decimal grammar as str_is_float; return 0.0 on invalid input, overflow or underflow to zero. Preserve valid signed zero.
str_to_int(string) -> intParse a complete signed decimal int64 token; return zero on failure.
str_trim(string) -> stringRemove ASCII space and bytes 0x09 through 0x0d from both ends.
str_upper(string) -> stringUppercase ASCII a-z bytes; preserve every other byte.
template_render(string, Json) -> stringRender arbitrary text with <path>, <items[0]>, <items:{item|body}; separator=", "> and <if(flag)>yes<else>no<endif>. Loop index is zero-based. << emits <. Inserted values remain literal.

Math functions

FunctionBehavior
math_abs(float) -> floatAbsolute value; integer arithmetic wraps, and float signed zero is cleared.
math_abs(int) -> intAbsolute value; integer arithmetic wraps, and float signed zero is cleared.
math_ceil(float) -> floatIdentity for int; ceiling for binary64 while preserving signed zero.
math_ceil(int) -> intIdentity for int; ceiling for binary64 while preserving signed zero.
math_floor(float) -> floatIdentity for int; floor for binary64 while preserving signed zero.
math_floor(int) -> intIdentity for int; floor for binary64 while preserving signed zero.
math_max(float, float) -> floatMaximum; integer comparison, or NaN propagation with first-operand ties for floats.
math_max(int, int) -> intMaximum; integer comparison, or NaN propagation with first-operand ties for floats.
math_min(float, float) -> floatMinimum; integer comparison, or NaN propagation with first-operand ties for floats.
math_min(int, int) -> intMinimum; integer comparison, or NaN propagation with first-operand ties for floats.
math_pow(float, float) -> floatFloat power follows IEEE/libm special cases.
math_pow(int, int) -> intInteger exponentiation wraps modulo 2^64; the exponent must be nonnegative.
math_round(float) -> floatIdentity for int; binary64 nearest integer with halfway cases away from zero.
math_round(int) -> intIdentity for int; binary64 nearest integer with halfway cases away from zero.
math_sqrt(float) -> floatBinary64 square root for float.
math_sqrt(int) -> intExact floor integer square root; the argument must be nonnegative.

File functions

FunctionBehavior
file_append(string, string) -> voidCreate or append all raw bytes to a regular file.
file_exists(string) -> boolReturn true only when metadata identifies a regular file; missing and nonregular paths return false.
file_lines(string) -> StrListRead raw bytes and split on every LF, preserving CR and empty fields: empty file gives [""], and "a\n" gives ["a", ""]. Return an arena-owned StrList.
file_read(string) -> stringRead a complete regular file as raw bytes.
file_write(string, string) -> voidCreate or truncate a regular file and write all raw bytes.

Encoding functions

FunctionBehavior
str_base64_decode(string) -> stringDecode canonical padded RFC 4648 Base64; reject whitespace, URL-safe symbols, invalid padding and nonzero pad bits. Empty input is legal.
str_base64_encode(string) -> stringEncode bytes as canonical padded RFC 4648 Base64 without line breaks. Empty input is legal.
str_hex_decode(string) -> stringDecode an even number of ASCII 0-9/a-f/A-F digits; reject separators, prefixes and whitespace. Empty input is legal.
str_hex_encode(string) -> stringEncode bytes as lowercase ASCII hex. Empty input is legal.

JSON, templates and constructors

FunctionBehavior
float_list() -> FloatListConstruct an empty FloatList in the active collection arena.
float_map() -> FloatMapCreate an insertion-ordered byte-key map.
float_pq() -> FloatPQCreate an empty FloatPQ in the run arena.
float_queue() -> FloatQueueCreate an empty FloatQueue in the run arena.
float_stack() -> FloatStackCreate an empty FloatStack in the run arena.
int_list() -> IntListConstruct an empty IntList in the active collection arena.
int_map() -> IntMapCreate an insertion-ordered byte-key map.
int_pq() -> IntPQCreate an empty IntPQ in the run arena.
int_queue() -> IntQueueCreate an empty IntQueue in the run arena.
int_stack() -> IntStackCreate an empty IntStack in the run arena.
json_parse(string) -> JsonParse strict UTF-8 JSON eagerly; int64 integers, finite binary64 decimals, depth <=256, duplicate decoded keys rejected.
str_list() -> StrListConstruct an empty StrList in the active collection arena.
str_map() -> StrMapConstruct an empty insertion-ordered StrMap in the active collection arena.
str_pq() -> StrPQCreate an empty StrPQ in the run arena.
str_queue() -> StrQueueCreate an empty StrQueue in the run arena.
str_split(string, string) -> StrListSplit raw bytes on every nonoverlapping nonempty separator into a StrList.
str_stack() -> StrStackCreate an empty StrStack in the run arena.

Return value functions

lmcode_return_set replaces the block result with one value, lmcode_return_put adds one named field, and the null forms store JSON null. The accepted value types are listed in the table.

FunctionOverloadsSignatures
lmcode_return_null1lmcode_return_null() -> void
lmcode_return_put11lmcode_return_put(string, FloatList) -> void; lmcode_return_put(string, FloatMap) -> void; lmcode_return_put(string, IntList) -> void; lmcode_return_put(string, IntMap) -> void; lmcode_return_put(string, Json) -> void; lmcode_return_put(string, StrList) -> void; lmcode_return_put(string, StrMap) -> void; lmcode_return_put(string, bool) -> void; lmcode_return_put(string, float) -> void; lmcode_return_put(string, int) -> void; lmcode_return_put(string, string) -> void
lmcode_return_put_null1lmcode_return_put_null(string) -> void
lmcode_return_set11lmcode_return_set(FloatList) -> void; lmcode_return_set(FloatMap) -> void; lmcode_return_set(IntList) -> void; lmcode_return_set(IntMap) -> void; lmcode_return_set(Json) -> void; lmcode_return_set(StrList) -> void; lmcode_return_set(StrMap) -> void; lmcode_return_set(bool) -> void; lmcode_return_set(float) -> void; lmcode_return_set(int) -> void; lmcode_return_set(string) -> void

Standard types and their methods

TypeMethodsSignatures
FloatList7add(float) -> FloatList; at(int) -> float; clear() -> FloatList; contains(float) -> bool; index_of(float) -> int; len() -> int; set(int, float) -> FloatList
FloatMap10clear() -> FloatMap; get(string) -> float; get_or(string, float) -> float; has(string) -> bool; key_at(int) -> string; keys() -> StrList; len() -> int; remove(string) -> bool; set(string, float) -> FloatMap; values() -> FloatList
FloatPQ6clear() -> FloatPQ; empty() -> bool; len() -> int; peek() -> float; pop() -> float; push(float, float) -> FloatPQ
FloatQueue7at(int) -> float; clear() -> FloatQueue; empty() -> bool; len() -> int; peek() -> float; pop() -> float; push(float) -> FloatQueue
FloatStack7at(int) -> float; clear() -> FloatStack; empty() -> bool; len() -> int; peek() -> float; pop() -> float; push(float) -> FloatStack
IntList7add(int) -> IntList; at(int) -> int; clear() -> IntList; contains(int) -> bool; index_of(int) -> int; len() -> int; set(int, int) -> IntList
IntMap10clear() -> IntMap; get(string) -> int; get_or(string, int) -> int; has(string) -> bool; key_at(int) -> string; keys() -> StrList; len() -> int; remove(string) -> bool; set(string, int) -> IntMap; values() -> IntList
IntPQ6clear() -> IntPQ; empty() -> bool; len() -> int; peek() -> int; pop() -> int; push(int, float) -> IntPQ
IntQueue7at(int) -> int; clear() -> IntQueue; empty() -> bool; len() -> int; peek() -> int; pop() -> int; push(int) -> IntQueue
IntStack7at(int) -> int; clear() -> IntStack; empty() -> bool; len() -> int; peek() -> int; pop() -> int; push(int) -> IntStack
Json11as_bool() -> bool; as_float() -> float; as_int() -> int; as_string() -> string; at(int) -> Json; get(string) -> Json; has(string) -> bool; keys() -> StrList; kind() -> string; len() -> int; to_json() -> string
StrList8add(string) -> StrList; at(int) -> string; clear() -> StrList; contains(string) -> bool; index_of(string) -> int; join(string) -> string; len() -> int; set(int, string) -> StrList
StrMap10clear() -> StrMap; get(string) -> string; get_or(string, string) -> string; has(string) -> bool; key_at(int) -> string; keys() -> StrList; len() -> int; remove(string) -> bool; set(string, string) -> StrMap; values() -> StrList
StrPQ6clear() -> StrPQ; empty() -> bool; len() -> int; peek() -> string; pop() -> string; push(string, float) -> StrPQ
StrQueue7at(int) -> string; clear() -> StrQueue; empty() -> bool; len() -> int; peek() -> string; pop() -> string; push(string) -> StrQueue
StrStack7at(int) -> string; clear() -> StrStack; empty() -> bool; len() -> int; peek() -> string; pop() -> string; push(string) -> StrStack

A for loop can iterate any standard list directly, because each list type provides len and at.

REST endpoints and stateless CLI interfaces

The current lmcode_std_v3 catalog includes the former lmcode_std_rest_v1 module: 10 standard interfaces, 5 functions and 15 RestExchange methods. They are documented here so that a program written for another host reads the same way, but lmaudio 0.2.2 does not provide them: a block that calls one of them compiles with a current lmscript and is then refused by the host at load time with code LOAD_UNBOUND, before any host work starts.

InterfaceSignatureRole
RestGet(exchange: RestExchange) -> voidhandler for GET routes
RestPost(exchange: RestExchange) -> voidhandler for POST routes
RestPut(exchange: RestExchange) -> voidhandler for PUT routes
RestDelete(exchange: RestExchange) -> voidhandler for DELETE routes
RestPatch(exchange: RestExchange) -> voidhandler for PATCH routes
RestHead(exchange: RestExchange) -> voidhandler for HEAD routes
RestOptions(exchange: RestExchange) -> voidhandler for OPTIONS routes
RestHandler(exchange: RestExchange) -> voidhandler bound to a route by rest_route
CliCommand(exchange: RestExchange) -> voidcommand handler dispatched by rest_cli
CliOption(exchange: RestExchange) -> voidoption handler dispatched by rest_cli
SignatureBehavior in the catalog
rest_cli(StrList) -> stringAuto-register annotated REST and CLI routes, dispatch a single stateless CLI argv request through CliOption and CliCommand/REST handlers, and return the response body.
rest_config(string, string) -> voidSet a configuration or initial session store entry on the global single-session REST controller before serving.
rest_route(string, string, string) -> voidRegister a route pattern for an HTTP method and bind it to a @tag RestHandler entry.
rest_serve() -> voidAuto-register annotated REST routes, validate route bindings, and arm the global single-session stdio server loop.
rest_stop() -> voidStop the active REST stdio server loop after the current exchange finishes.
RestExchange.body() -> stringReturn the raw request body bytes.
RestExchange.get(string) -> stringRead a string value from the global single-session store, or empty string when absent.
RestExchange.has_header(string) -> boolReturn whether the request contains a case-insensitive header name.
RestExchange.has_query(string) -> boolReturn whether the request URL contains the query key.
RestExchange.header(string) -> stringRead a case-insensitive request header value, or empty string when absent.
RestExchange.increment(string) -> intIncrement a decimal integer counter in the global single-session store and return the new value.
RestExchange.json(string) -> voidValidate strict UTF-8 JSON, set default content-type to application/json, and replace the response body.
RestExchange.method() -> stringReturn the canonical uppercase HTTP method of the request.
RestExchange.param(string) -> stringRead a matched path parameter by name.
RestExchange.path() -> stringReturn the decoded request path without query string.
RestExchange.query(string) -> stringRead the last decoded query value for a key, or empty string when absent.
RestExchange.send(string) -> voidSet default content-type to text/plain; charset=utf-8 if unset and replace the response body.
RestExchange.set(string, string) -> voidStore a key-value pair in the global single-session store.
RestExchange.set_header(string, string) -> voidSet or replace a case-insensitive response header.
RestExchange.status(int) -> voidSet the HTTP response status code (100..599).

Route templates accept {param} and {rest...} placeholders as well as :param and :rest... placeholders. rest_cli(argv) is the stateless CLI mode: it dispatches options, commands and REST routes for one argument list and returns the response body.