Skip to main content
Building autonomous agents with PRYSM gives you three things that are hard to bolt on after the fact: a hard spend ceiling that the model cannot talk its way around, a tamper-evident audit trail of every step, and a declarative config file that version-controls your routing preferences. This guide walks through each, with patterns you can drop into any agent framework.

The problem: agents call models you didn’t expect

A single-prompt call is easy to reason about. An autonomous agent is not. One mis-routed batch — a frontier model on a task that a budget model handles just as well — can dwarf a month of ordinary usage. And you usually find out on the bill, not in the logs. PRYSM solves this at three levels:
  1. Per-request cost caps (AgentGuard) — PRYSM downgrades requests that would exceed your cap instead of running them at full price.
  2. Model blocks — frontier models you never want an agent to touch are blocked server-side and routed around automatically.
  3. Verifiable trajectory — every step is hashed into a chain; a tamper-evident trajectory_proof proves what ran, in what order, at what cost.

1 — Configure once in BRAIN.md

A BRAIN.md in your project root sets the routing preferences, spend caps, and blocked models for every request from that context. It’s checked into version control and reviewed in pull requests — the spending policy is code, not a checkbox buried in a dashboard.
BRAIN.md
Scaffold a starter file from the terminal:
Validate it any time — works great in CI:
See AgentGuard for the full cap and block reference.

2 — Hard spend ceiling on agent runs

The /v1/agent/run endpoint executes a goal as a bounded, multi-step trajectory. Pass max_cost_usd and the run provably cannot exceed it — not “+5%”, at most that amount. Before each step, AgentGuard binds the step’s worst-case cost against the remaining budget and only runs it if it fits, downshifting intensity (Laser → Halo → Foton) under pressure rather than overspending.
The run never errors from budget pressure — it stops gracefully and returns the best partial result so far. Check status to distinguish clean completion from a budget stop.

Idempotency for retries

Pass idempotency_key to make a run retry-safe: a second request with the same key returns the original result without spending again.

3 — Verify the trajectory

Every step is hashed into a chain. The run returns a trajectory_proof that commits to every step — model, cost, intensity, input hash, output hash — in a tamper-evident bundle. Reorder, drop, or edit any step and verification fails. You can verify a trajectory without a PRYSM account — the verify endpoint is public:
See PrysmProof for how the chain-of-custody is constructed.

4 — Preview costs before the agent runs

Use a dry-run route call to estimate what any prompt would cost before committing:
Python
Or from the CLI:
This is especially useful for testing that a new max_cost_per_request cap behaves the way you expect before deploying an agent.

5 — AI-to-AI distribution via MCP

If your agent is Claude Desktop, Cursor, or Windsurf, give it cost-aware routing as a native tool — no API calls in application code required. Install the PRYSM MCP server and the agent calls prysm_route, prysm_usage, and prysm_savings as tools with its own key.
claude_desktop_config.json
See MCP Server for the full tool list and Cursor/Windsurf setup.

Reference

AgentGuard

Per-request caps, monthly budgets, and model blocks — enforced server-side.

Agent API

/v1/agent/run, trajectory retrieval, and the public verify endpoint.

PrysmProof

How every step is hashed into a tamper-evident chain.

BRAIN.md

Version-controlled routing config — rules, blocks, caps, and fallback chains.