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.| Field | Type | Description |
|---|---|---|
name | string | Cosmetic project name (logs/dashboards). |
version | string | number | Cosmetic config version. |
model | model ID | Hard model lock. Routes every request to this model, overriding auto-routing and rules. |
max_cost_per_request | number > 0 | AgentGuard per-request USD cap. Over-budget selections are downgraded to a budget model. |
monthly_budget | number > 0 | AgentGuard monthly USD ceiling (alerts on approach). |
rules | rule[] | Per-signal routing rules (see below). First matching rule wins. |
quality_threshold | integer ≥ 0 | Word-count trigger for Quality mode. |
quality_signals | string[] | Extra keywords biasing toward Quality mode. |
fallback | model ID[] | Custom fallback order when a provider is unavailable or a model is blocked. |
blocked | model ID[] | Models PRYSM must never route to. Reroutes via fallback. |
compliance | object | Policy-as-Code gate: approved providers, jurisdictions, frameworks, certifications, data residency, blocked data classes. Non-compliant models are filtered out before scoring. |
log_level | minimal | standard | verbose | Routing-decision log verbosity. |
log_proofs | boolean | Emit a PrysmProof per request. |
The rule object
| Field | Type | Required | Description |
|---|---|---|---|
when | signal | yes | Intent signal that activates the rule (see below). |
model | model ID | yes | Model to route to when the signal fires. |
reason | string | no | Human note, surfaced in logs. |
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:Auto-routing
PRYSM classifies intent and picks the best model. See How routing works.
max_cost (guardrail)
If the chosen model’s estimated cost exceeds the cap, downgrade to a budget model
(
deepseek-v3.2).(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-v3.2. 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.
| Canonical | Accepted aliases |
|---|---|
code | coding, programming, dev |
write | writing, content, copy, copywriting |
analysis | research, analyze, analyse |
math | maths, calculation, calc |
translate | translation, i18n |
realtime | real-time, news, live |
simple | quick, lookup |
multimodal | vision, image, images |
reasoning | logic, reason |
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.