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 — ordered system + user sections
- Sampling defaults — temperature, max_tokens, etc.
- An output policy — validation, cleanup, required patterns
Leave the selector on auto-route or pick one explicitly.
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 at export time, others are filled at runtime.
Runtime overlays use a template with {} as the insertion point. At call time the value replaces {} — e.g. a template The user's industry is {} with value SaaS produces The user's industry is SaaS. Optional runtime slots are dropped when empty; required ones raise an error.
Injections
Injections are reusable fragments that modify the active route — adding instruction text and overriding sampling or output policy.
Multiple injections stack. Use the pencil button to tweak text for this session without changing the source.
Generation & Output
When you hit Generate, the engine:
- Selects a route (auto or explicit)
- Assembles system + user prompts from all layers
- Sends to the provider with resolved config
- Validates the response against the output policy
- Retries if validation fails
Enable Debug Trace to inspect the exact prompts and attempts.
Pre-Generate & Export
Pre-Generate previews assembled sections before sending — drag to reorder, fill in runtime slot values.
Export saves as JSON, loadable with promptlibretto.load_engine(). Runtime overlays become function arguments.
Snapshots capture the full studio state to return to later.
Ensemble
The Ensemble page fans out the same input across multiple saved exports, each running independently with its own route, context, and config.
A Shared Directive is sent to every selected model — your request, question, or instruction. This is additional prompt input on top of each export's built-in prompt.
Context Overrides let you inject extra key-value pairs per-model or across all models — filling in runtime slots or adding context without editing the export.
Compare results in cards view or spot differences with diff view.