One gateway between your code and the model.
infer() and embed() are the only door to a model in this kit: every call resolves a versioned prompt, reserves against a per-tenant spend cap, crosses a guardrail on the way in and out, and reconciles usage in the same Postgres transaction as the result. Vercel AI SDK v7 sits behind it; your route handler calls infer(lane, input) and never touches a provider SDK directly. That door fronts all seven modules below: versioned prompts, metering, guardrails, and AI config on the call path; field encryption, the eval harness, and the credit ledger securing the data, the model swaps, and the spend behind it.
> infer("support-reply", input)
resolve prompt@v7 → guardrail(in) → reserve tokens against cap
✗ 402 Payment Required tenant_9f2 crossed daily_tokens cap
breaker: open · resets on window · zero calls reach the provider
One package, nine other Caisson packages behind it.
The AI-Production module family composes @caisson-sh/ai-config, @caisson-sh/ai-meter, @caisson-sh/credits, @caisson-sh/field-crypto, @caisson-sh/guardrails, @caisson-sh/kernel, @caisson-sh/prompt-registry, @caisson-sh/tenancy-rls, and @caisson-sh/ai-evals. Together they resolve and render versioned prompts, map lanes to providers, validate inputs and outputs, reserve and reconcile integer credits, isolate tenant data, encrypt sensitive fields, and run the same eval checks in CI. The production safeguards stay in explicit package boundaries instead of being scattered through route handlers.
Seven modules behind one chokepoint.
Versioned prompts with rollout history: promote or roll back a prompt by moving an alias pointer, no redeploy required.
PG-atomic token metering with per-tenant spend caps and a circuit breaker: a runaway prompt loop trips the breaker before it runs your bill up.
Input and output guardrails wired once, at the model boundary, instead of copy-pasted into every call site.
Per-tenant field encryption via HKDF-SHA256 + AES-256-GCM; a leaked tenant key exposes one tenant, never the table.
Regression-grade evals that run in CI: a model swap that scores below the committed baseline fails the build, not a customer's session.
PG-atomic credit ledger, grant, debit, and spend-cap credits with one integer denomination, fail-closed (402) on an empty balance.
Provider-agnostic config resolver plus a settings file: the lane-to-provider mapping infer() reads to pick a model. Base substrate, composed in with no separate install step.
Teams whose one fetch call is about to become a feature.
Teams that already have a route calling a model and have hit, or are about to hit, one of three failure modes: an unmetered retry loop triples the API invoice before anyone notices, a prompt edited inline three files deep breaks silently with no way to diff or roll it back, or user input reaches the model with no schema and no policy check on what comes back. If your AI feature is one fetch call today, this kit is the difference between that and a feature you can put a spend cap and an audit trail behind.
BYOK included.
The same reserve-before / reconcile-after chokepoint covers infer(), inferStream(), embed(), and embedMany(), so a runaway embedding job hits the same cap as a runaway chat loop. A tenant can also supply their own provider key instead of the shared platform lane; BYOK resolves the tenant's encrypted key ahead of the default, and a BYOK-backed call debits zero credits because the tenant pays the provider directly.
Every claim here is a control you can point at.
The caps and the breaker are configuration checked into your repo, enforced at call time, and reviewable in the same pull request as the feature that needs them.
# caisson.ai.toml, checked into your repo, enforced at call time [caps.default] daily_tokens = 1_000_000 on_exceed = "break" # open the circuit, return 402 [guardrails] input_schema = "schemas/chat-input.json" output_policy = "policies/content-policy.ts"
How it ships.
The gateway and all seven composed modules, in your own repo as TypeScript source. Scaffold it in with bunx --package @caisson-sh/cli create-caisson, or add it to an existing Caisson base.
The composed modules also work on their own: prompt registry, guardrails, and token metering each compose onto the base without the rest.
See the full lineup. Need regression evals in CI too? The eval harness is a separate standalone module: see it on the marketplace.
Common questions
What does token metering actually prevent?
What happens when a tenant hits their spend cap?
Can I use my own provider key instead of the platform lane?
Prove fit in week one.
Don't take the fit on faith, scaffold the audited base and run it on your own stack.
The first question is whether it fits the stack you already run. Answer it with code: scaffold the audited base in one command and deploy from the template the generator emits for your host. You own the source from the first line, so a week-one spike is a real evaluation on your own infrastructure — not a demo that disappears.
$ bunx --package @caisson-sh/cli create-caisson $ cd my-app $ bun install # ready to run — deploy from the Railway, Fly, or Vercel template
Ship the feature with the brakes on.
Scaffold a new project with the AI Production Kit included, or add it to an existing Caisson base.
$ bunx --package @caisson-sh/cli create-caisson