@prysmai/sdk — a fully-typed OpenAI drop-in for Node/TypeScript with routing, cost, proof, and BRAIN.md auto-discovery.
@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.
import { Prysm } from "@prysmai/sdk";const client = new Prysm(); // apiKey from $PRYSM_API_KEY, baseURL from $PRYSM_BASE_URLconst resp = await client.chat.completions.create({ model: "auto", // let PRYSM pick the best model messages: [{ role: "user", content: "Write a TypeScript quicksort" }],});console.log(resp.choices[0].message.content);
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.
const r = await client.orchestrate( "Compare three database designs for a 40-person team", { policy: "depth" }, // "efficiency" | "balanced" | "depth");console.log(r.choices[0].message.content);console.log(r.prysm.orchestration.models_used); // which models contributedconsole.log(r.prysm.orchestration.agreement); // how strongly they agreed
Force a strategy, widen the ensemble, or cap spend — and the { messages } form is
accepted too:
const r = await client.orchestrate({ messages: [{ role: "user", content: "Prove that the square root of 2 is irrational" }], policy: "depth", strategy: "debate", // single | cascade | ensemble_moa | rank_fuse | // decompose_and_route | self_consistency | debate k: 3, // ensemble / sample width maxCostUsd: 0.05, // soft budget hint, USD});
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.
const r = await client.code( "Write a thread-safe LRU cache in TypeScript with tests", { policy: "depth" }, // "efficiency" | "balanced" | "depth");for (const f of r.files) { console.log(f.path); console.log(f.content); }console.log(r.passed); // did the critic pass?console.log(r.prysm.code.coder_models); // who wrote itconsole.log(r.prysm.proof.proof_hash); // verifiable proof
Force the models, cap iterations, or skip the critic loop — and the { task } form is
accepted too:
const r = await client.code({ task: "Implement rate limiting middleware", coderModel: "claude-sonnet-4.5", // who writes the code reviewerModel: "deepseek-r1", // who critiques it maxIters: 4, // generate + up to 3 repairs maxCostUsd: 0.1, // soft budget hint, USD});const quick = await client.code("Write a hello world", { review: false }); // single shot
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.
const p = await client.compliancePreview("summarize this report", { compliance: { jurisdiction: ["EU"], frameworks: ["GDPR"], data_residency: ["EU"] },});console.log(p.allowed_models); // only EU/GDPR providers surviveconsole.log(p.compliance_cost_premium); // what compliance costs vs. unrestricted
Then enforce the same policy on a real run — orchestrate() accepts a compliance spec.
Excluded models can never be selected, and the result carries a compliance decision plus an
attestation in its PrysmProof:
const r = await client.orchestrate("Explain photosynthesis.", { policy: "balanced", compliance: { provider_allowlist: ["anthropic"] }, // confine to approved providers});console.log(r.prysm.compliance); // the exclusion decisionconsole.log(r.prysm.proof.compliance); // the attestation
Prefer to declare it once and version it: put a compliance: block in your
BRAIN.md and it applies to every request automatically.
await client.route("debug this function"); // dry-run: which model, est. cost (no call)await client.usage(); // your usage statsawait client.savings("gpt-5.2"); // est. $ saved vs. an all-premium baselineawait client.verifyProof(requestId); // verify a PrysmProofawait client.modelsCatalog(); // 21 models with pricing