The Big Picture
promptlibretto assembles prompts from composable pieces — like a musical score built from parts.
Instead of one monolithic prompt string, you define routes, context layers, and injections that snap together at generation time.
Once you've tuned and tested a configuration in the studio, export it as JSON. In your project, a single call loads the full prompt pipeline — context, route, injections, sampling, and output policy — ready to run:
from promptlibretto import load_engine
eng = load_engine("analyst_v2.json")
result = eng.run(input="How do I get my first 10 paying users?")
Step through to see each piece add to the prompt on the right →
Base Context & Route
Base Context is your long-lived framing — persona, constraints, stable facts. It appears in every prompt.
A route is a named strategy for one kind of prompt. It bundles a composition recipe, sampling defaults, and an output policy. A route can define a runtime schema to create structured inputs.
Overlays
Overlays are temporary layers stacked on top of the base context — transient facts, signals, or emphasis. Each has a name and priority (higher = appears first). Some are fixed, others are filled at runtime via templates.
Injections
Injections are reusable fragments that modify the active route — adding instruction text, few-shot examples, and overriding sampling or output policy. Use them to represent conditional logic or stylistic variants.
Generation & Output
When you hit Generate, the engine assembles all the active layers, sends the final prompt to the model, and validates the response. Enable Debug Trace to inspect the exact prompts and attempts.
Pre-Generate & Export
Pre-Generate previews assembled sections before sending. Export saves the entire configuration as JSON, loadable with promptlibretto.load_engine(). Runtime overlays and schema fields become function arguments.
Ensemble
The Ensemble page fans out the same input across multiple saved exports, each running independently with its own route, context, and config. Compare results side-by-side to find the best model for the job.