Skip to content

Latest commit

 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Receipts

A live audit layer for AI decisions — every answer itemized by model, cost, and judgment. Shown here on a support desk: routine questions get a fast, cheap model; sensitive ones escalate to a stronger model; repeats are free from cache; and the ones a bot shouldn't touch are held for a human. Built on BTL Runtime — routing, classification, caching, and live cost, all real.

Built for the BTL Runtime Hackathon (Jul 3–5, 2026).

Live: https://receipts-hackathon.onrender.com — sign in with Google and try it.

Every reply comes with a live ledger entry showing which model answered, whether it was served free from cache, or escalated to a stronger model — and the real cost of that message.

Why

AI support desks are a black box: you don't know what they cost per conversation, and one model answers everything, routine or sensitive. Receipts makes routing and cost visible, live, using BTL Runtime's multi-provider gateway and caching as the actual product feature, not background plumbing.

How this uses BTL Runtime

Every part of the ledger is a real BTL Runtime call, not a simulation. Routine questions are routed to btl-2; messages that hit an escalation keyword (refund, cancel, complaint, lawyer, manager, angry, furious) are routed to gpt-5-5 instead — real multi-provider routing based on message content, both through BTL's gateway. The cost shown on every message is computed from BTL's own GET /v1/account/pricing, not a hardcoded number. btl-2 is billed at an explicit per-token rate, so its cost is exact; gpt-5-5 is priced under BTL's shared_savings model, which only publishes a benchmark price range, so its cost is a midpoint estimate — labeled est. in the ledger wherever it's shown. And the stats row on the ledger panel — requests, cache hits, savings vs. list price, average latency — is pulled live from BTL's own GET /v1/usage/summary: your workspace's real usage and savings, live from BTL Runtime, surfaced directly in the product UI instead of staying backend plumbing.

Status

Built incrementally, verified at each step with real API calls — nothing in this repo is mocked.

  • Real BTL Runtime chat completions (POST /api/chat)
  • Duplicate-question cache detection (repeat questions cost $0, no second API call)
  • Escalation routing to a stronger model for sensitive questions
  • Real per-message cost from BTL's pricing data
  • Live usage/savings panel (GET /api/usage, proxying GET /v1/usage/summary)
  • Google sign-in with server-side token verification (POST /api/auth/verify)
  • Deployed to a public URL (https://receipts-hackathon.onrender.com)

Stack

  • Node.js + Express backend
  • Vanilla HTML/CSS/JS frontend (no framework)
  • BTL Runtime (api.badtheorylabs.com/v1) — the only model provider called, per the hackathon's one rule
  • Google Identity Services for sign-in

Running locally

npm install
cp .env.example .env   # fill in BTL_API_KEY at minimum
npm start

Visit http://localhost:$PORT (defaults to 3000 if PORT isn't set).

Live deployment: https://receipts-hackathon.onrender.com

Environment variables

Variable Required for
BTL_API_KEY Any chat call, pricing, and usage summary
GOOGLE_CLIENT_ID Sign-in (client-side button + server-side token verification)
PORT Which port the server listens on (most hosting platforms set this automatically)
SESSION_SECRET Reserved for future session-signing — not currently read by any code

API routes

Route Does
GET /api/health Health check
POST /api/chat Sends {message}, returns {reply, model, status, usage, cost} — routes to cache, default model, or an escalated model depending on the question
GET /api/usage Proxies BTL's live usage/savings summary
POST /api/auth/verify Verifies a Google ID token server-side, returns {name, email, picture, verified} or 401

Author

Built by solutionkanu12 — sole author and contributor.

About

receipt

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages