Designed for tablet+. View on a tablet or larger screen for the intended layout.
CORE_WORKSHOP_v1.0
SPEAKER NOTES MODE — press s to hide
BLOCK 4 · AI GATEWAY (PRODUCTION) 3:30 – 3:43 · 13 min · 5L / 8HO · Lab

TOPIC 4.5 / 10 · HO #4 + STORAGE CHECK

Budget + storage check

Attach a budget — your circuit breaker. Then take three minutes to look at where the workshop's Bifrost actually lives on disk — the production-grade persistence behind everything you've built so far.

4.5

Budget — the circuit breaker

10 min 3L / 7HO 3:30 – 3:40
Slide 1 / 3 · Budgets compose three ways

Where budgets attach

TEAM SCOPING               (a VK can belong to a team — inherits team-level caps)
   └── VIRTUAL KEY         (each VK carries its own budgets[] — multiple caps, different reset windows)
        └── PROVIDER CONFIG  (a VK can also cap per-provider — e.g., $50/h OpenAI, $200/h Anthropic)
  • Multi-budget per VK — one VK can have $50/day AND $1000/month simultaneously (v1.5.0+ — budgets are an array)
  • Per-provider caps inside a VK — useful when one VK fans across providers with different cost profiles
  • Team scoping — VKs that share a team_id inherit team budgets

Bifrost evaluates every cap that touches the request; first one hit wins.

Slide 2 / 3 · 402 Payment Required

When a cap trips

  • Bifrost returns HTTP 402
  • Body includes which cap tripped and which scope
  • The gateway is your circuit breaker
  • Runaway loop hits one VK's cap, not your whole infra

📋 Dry-run capture target: exact 402 JSON shape → Block 4 - 402 response sample.md

Slide 3 / 3 · Five clicks to budget attached

HO #4 — Attach a budget (7 min)

  1. Sidebar → ModelsBudgets & Limits
  2. Create Budget
  3. Name: workshop-vk-budget · limit: $0.50 · reset: 1h
  4. Scope: attach to workshop-vk-1 (the VK from 4.4)
  5. Save → confirm budget appears active
4.5.5

Where it all lives

3 min 2L / 1HO 3:40 – 3:43 ★ LOAD-BEARING (storage model)
Slide 1 / 3 · Two layers, three modes

Bifrost's two config layers

Layer What it holds Behavior
config.json (file) Storage backends, encryption key, plugins (e.g. semantic_cache), $schema header, and optionally providers + governance for bootstrap File-based. Edit → restart to load.
config_store (SQLite default) Providers, Virtual Keys, governance rules, prompts — runtime mutable UI-driven. Writes go to SQLite. Survives restarts.

Everything you did in Beats 4.2–4.5 is in config_store. It's already persisted.

Three operating modes:

Mode config_store.enabled What goes where When to use
Pure UI (workshop default) true, file is minimal All providers + governance via dashboard Fastest start; the UI is the source of truth
Bootstrap + UI true, file has providers + governance File seeds an empty config_store on first run; UI takes over after Reproducible bring-up; infra-as-code feel for the bootstrap, UI for daily edits
File-only false (UI disabled) Everything in config.json; restart-to-change Multi-node clusters; declarative-only shops

Precedence rule: If config_store has data, the file's providers/governance are ignored after first run.

Slide 2 / 3 · Where it lives on disk

Workshop-local storage: ./bifrost/

./bifrost/                ← Beat 4.1.3 set this via --app-dir
├── config.json           ← plugins (semantic_cache); restart-to-load
├── config.db             ← providers, VKs, budgets, routing rules, prompts (SQLite)
├── config.db-shm         ← SQLite shared-memory (WAL mode)
├── config.db-wal         ← write-ahead log
├── logs.db               ← LLM request/response logs (separate SQLite)
└── logs.db-shm / logs.db-wal
  • Defaults note: If --app-dir is NOT specified, Bifrost uses the OS config directory — ~/.config/bifrost/ on macOS/Linux. We chose workshop-local so attendees with pre-existing Bifrost installs don't collide.
  • Production note: SQLite is the default for single-node OSS. The storage swap (SQLite → PostgreSQL via config_store.type: "postgres" in config.json) is the foundation real production deployments build on. Same UI, different backend — invisible to attendees' app code.
Slide 3 / 3 · Verify (60-second HO)

Restart-safe by default

  1. Ctrl-C your Bifrost terminal
  2. npm run bifrost again
  3. Refresh the dashboard
  4. Providers · VK · budget · all still there

"Restart-safe by default. That's production-grade behavior, not an accident."

Production-tier callout: OSS gives you this on day one. A real production deployment runs on Bifrost Enterprise — same persistence model, plus clustering (multi-node), SSO / OIDC (Okta, Entra, Google, GitHub), Vault for API key management, RBAC + team-level governance, and in-VPC deployment. The mental model you're learning now is what scales up.