
- Typed contracts. Inputs, outputs, and instructions are a Rust struct. The library renders the prompt and parses the response into your types; malformed model output becomes a typed error, not a string-parsing bug.
- Programs as data. A
#[module]function is read once at build time and projected into both a runnable function and a.dsrsartifact that cannot drift from the code. The artifact can be checked, diffed, served over HTTP, and embedded back into a build. - Recorded runs. Every run is captured as a trace. Strict replay turns recordings into free, deterministic tests; until-divergence replay re-runs only the steps a change actually affects.
- Optimizers. COPRO, MIPROv2, GEPA, SIMBA, and BootstrapFewShot tune instructions and few-shot demos against your metric and dataset, without modifying your code.
- Tools, agents, and Code Mode. Models call typed Rust tools in bounded loops, or write one sandboxed JavaScript program that calls all tools in a single round trip. A capability system gates every access at load time.
Start here
Quickstart
Install, configure a model, and make a typed call in five minutes
How DSRs thinks
The mental model: contracts, programs as data, and the three authoring lanes
Signatures
The first component: typed contracts for LM calls
Examples
Every runnable example in the repository, indexed
Components
Each component has exactly one page covering what it is, how to use it, and its complete API surface.
DSRs is a from-scratch Rust rewrite of the ideas in DSPy, designed around Rust’s type system rather than ported from Python. Source and issues: krypticmouse/DSRs.