Skip to Content
Mélodium 0.10.3 is now available!
DocsExamplesOverview

Examples

Showcase: larger demos

The showcase/ track combines several capabilities at once (remote LLMs, speech, distributed compute, CI/CD) into larger demos, without stopping to explain every concept along the way.

ExampleWhat it showsNeeds beyond installing Mélodium
Smart LLM RouterA JavaScript routing function sends each prompt to the cheapest LLM tier that can handle itan LLM provider API key
AI Voice AssistantLocal speech-to-text, a remote LLM, and text-to-speech chained across two entrypoints (chat and voice)an LLM provider API key; voice also needs an ElevenLabs key and a microphone
CI PipelineA three-stage CI pipeline (build, test, package) running entirely on provisioned cloud containersa Mélodium Services API token, or a local podman/docker compose setup
CI Failure TriageCI step output classified by a small JS function, with only genuine failures sent to an LLM for diagnosisa Mélodium Services API token and an LLM provider API key
Distributed LLM ClusterAn HTTP front-end that provisions a remote worker on demand to run the LLM, keeping ml off the front-end entirelya Mélodium Services API token and an LLM provider API key

Learning path: the tutorial track

Create a file named hello-world.mel, and write this code:

#!/usr/bin/env melodium #! name = hello_world #! version = 0.1.0 #! require = std:0.10.* use std/engine/util::startup use std/engine/log::logInfoMessage treatment main() { startup() logInfoMessage(message = "Hello World!") startup.trigger -> logInfoMessage.trigger }

Then run it using melodium run hello-world.mel.

$ melodium run hello-world.mel [2012-12-21T01:32:45.678Z] info: info: Hello World!

That single file is as far as inline snippets go. Real Mélodium projects live in a directory with a Compo.toml, and the best way to learn the language from there is the tutorial/ track in the Mélodium repository: ten short, self-contained steps, each introducing one or two new concepts, in increasing order of difficulty. Clone the repository to run them:

git clone https://github.com/melodium-tech/melodium.git cd melodium/examples/tutorial

Each step is its own directory. Run a step from inside its own directory, because several of them read or write files relative to the current working directory:

cd 01_hello_melodium melodium run Compo.toml [arguments...]
StepIntroducesNeeds beyond installing Mélodium
01: Hello, MélodiumTreatments & connections, Block<T> vs Stream<T>, functions, startup()nothing
02: Flow & GenericsGeneric treatments, std/flow combinators, arithmetic & comparisonnothing
03: Text & FilesFile I/O, regular expressions, text compositionnothing
04: JSON ToolkitParsing & validating JSON, Option unwrappingnothing
05: HTTP ClientCalling a remote HTTP API, telling network failure from application errorinternet access
06: HTTP Server APIThe HttpServer model, routing, the @HttpRequest contexta free TCP port and curl
07: SQL CRUD APIA SqlPool model shared across requests, combined with an HTTP servera reachable PostgreSQL database
08: JavaScript TransformThe JavaScriptEngine model, transforming structured data with JSnothing
09: Process PipelineRunning an external command as a treatment, streaming through its stdin/stdoutthe sort command in PATH
10: Distributed ComputationThe distrib package: running a treatment on another enginea second Mélodium engine (melodium dist)

Every example, tutorial or showcase, is a self-contained Mélodium project (Compo.toml + one or more .mel files) with its own README explaining what it does and why it is built the way it is. Run any of them the same way:

melodium run <example-dir>/Compo.toml [entrypoint] [-- --arg value …]

See the examples README for the full capability map (which package demonstrates what) and a note on how each example was verified.