@prysmai/sdk extends the openai client, so all your existing OpenAI code works
unchanged — plus typed helpers for routing previews, usage, savings, proof verification,
and BRAIN.md auto-discovery.
Drop-in replacement for OpenAI
Access the PRYSM extensions
Every response carries aprysm block (routing, cost, latency, proof). Use
extension() for clean, typed access:
extension() returns null for responses without a prysm block. The shortcuts
routing(), cost(), and proof() are also exported.
BRAIN.md auto-discovery
Drop aBRAIN.md in your project root and the SDK finds it
automatically, applying your routing rules, cost caps, and blocked models:
Orchestration (v2)
Beyond routing to one model,orchestrate() runs a prompt across several models —
cascading, ensembling, decomposing, or debating — and returns one synthesized answer plus
a PrysmProof v2. Pick the objective with a policy; PRYSM plans
the strategy (or you force one). See How orchestration works.
{ messages } form is
accepted too:
Code Mode (v2)
code() writes code, reviews it with a separate critic model, and repairs against that
feedback until the review passes or a budget/iteration cap is hit. In depth, several
diverse coders run in parallel and the best candidate is kept. PRYSM never executes the
generated code. See How Code Mode works.
{ task } form is
accepted too:
Compliance (v2)
Load the providers your organization approves and PRYSM routes only to models that satisfy your policy — non-compliant models are filtered out before scoring. See compliance routing.compliancePreview() is a pure dry-run (no model call, no keys needed): it shows which
models a policy allows vs excludes, the Compliance Cost Premium, and a sample attestation.
orchestrate() accepts a compliance spec.
Excluded models can never be selected, and the result carries a compliance decision plus an
attestation in its PrysmProof:
Helpers
Validate a BRAIN.md before shipping
TypeScript
The package ships type declarations. Result and option types are exported for use in your own signatures:Configuration
If
PRYSM_API_KEY is unset, the SDK falls back to OPENAI_API_KEY — so migrating
existing code can be a one-line base-URL change.Next steps
MCP server
Give Claude Desktop, Cursor, or Windsurf cost-aware routing as a native tool.
API reference
The endpoints these helpers call, documented field by field.