BRAIN.md is a declarative routing configuration for PRYSM. Drop a BRAIN.md in your
project root and PRYSM reads it to customize how prompts are routed: which model handles
which kind of task, how much a request may cost, which models are off-limits, and what
to fall back to.
It’s an open standard — plain, human-readable, and YAML-compatible — so any tool can
read or write it, not just PRYSM.
Version 1.0 · Stable. All fields are optional; an empty
BRAIN.md is valid (PRYSM
uses its default auto-routing).File location & loading
- Location: project root, filename
BRAIN.md(case-sensitive). - Discovery: the SDKs and CLI auto-discover
BRAIN.mdby walking up from the current working directory. The API accepts the parsed config per request viabrain_config. - Optional: with no
BRAIN.md, PRYSM uses default auto-routing.
File format
BRAIN.md is YAML with Markdown affordances:
- Markdown headers (
#,##) begin with#, which is a YAML comment — so headers are free for human structure and ignored by the parser. - Everything else is standard YAML:
key: value, block sequences (- item), inline lists ([a, b]), quoted strings, booleans, numbers. - Inline comments (
# ...) are supported and stripped.
BRAIN.md works in any environment.
BRAIN.md
Field reference
All fields are optional.The rule object
max_cost is the canonical normalized name for max_cost_per_request. Use
max_cost_per_request in source files; both are accepted.Routing precedence
This is the heart of the spec. PRYSM resolves the model for each request in a fixed order. Later steps are guardrails and always win over earlier preferences:1
Auto-routing
PRYSM classifies intent and picks the best model. See How routing works.
2
rules (override)
The first rule whose
when signal is active replaces the auto choice.3
model (override)
An explicit model lock replaces the above.
4
max_cost (guardrail)
If the chosen model’s estimated cost exceeds the cap, downgrade to a budget model
(
deepseek-v4-flash).5
blocked (guardrail)
If the chosen model is blocked, reroute through the fallback chain.
(input_price + output_price) × 0.001 (USD
per MTok, a ~1K-token reference) against the cap. It’s a fast pre-flight estimate, not a
post-hoc bill.
Worked example
claude-sonnet-4.5), but the cap downgrades
it to deepseek-v4-flash. The guardrail wins. To honor the rule, raise the cap to ≥ 0.018
or remove it.
Signal vocabulary
Signals are intent categories. PRYSM normalizes aliases to a canonical signal, sowriting and copy both mean write. Use whichever spelling reads best.
Validation
Validate aBRAIN.md before you ship it — via the API, the CLI, or an SDK:
Response
validisfalseifferrorsis non-empty.- Errors block shipping: unknown locked model, unknown rule model, non-positive
max_cost. - Warnings are advisory: unknown
blocked/fallbackmodel; every fallback also blocked. normalizedis the canonical config PRYSM’s router consumes.
Editor autocomplete
A JSON Schema (Draft 2020-12) is published for autocomplete and inline validation. In VS Code with the YAML extension:.vscode/settings.json
Complete example
BRAIN.md
Design principles
- Human-first, machine-clean. Reads like notes; parses like config.
- Safe by default. Guardrails (cost, blocked) always beat preferences.
- Dependency-free. Works without a YAML library; works without PRYSM.
- Forward-compatible. Unknown top-level keys are preserved, not rejected — new fields never break old parsers.