Skip to main content
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.md by walking up from the current working directory. The API accepts the parsed config per request via brain_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.
PRYSM parses with a full YAML parser when available and ships a dependency-free subset parser as a fallback, so 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.
Guardrails win on purpose. A budget cap or compliance block must beat a routing preference. If you prefer claude-sonnet-4.5 for writing but set a max_cost_per_request it can’t satisfy, the cap wins — your spend is protected.
Cost estimate (step 4): PRYSM compares (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

A “write a poem” prompt matches the rule (→ 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, so writing and copy both mean write. Use whichever spelling reads best.

Validation

Validate a BRAIN.md before you ship it — via the API, the CLI, or an SDK:
Response
  • valid is false iff errors is non-empty.
  • Errors block shipping: unknown locked model, unknown rule model, non-positive max_cost.
  • Warnings are advisory: unknown blocked/fallback model; every fallback also blocked.
  • normalized is 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

  1. Human-first, machine-clean. Reads like notes; parses like config.
  2. Safe by default. Guardrails (cost, blocked) always beat preferences.
  3. Dependency-free. Works without a YAML library; works without PRYSM.
  4. Forward-compatible. Unknown top-level keys are preserved, not rejected — new fields never break old parsers.