Wattfare documentation
Wattfare is an OAuth-like consent layer for AI spend. Your users connect their own inference budget, set a cap, and you call any model through one SDK — charged to them, not you.
Shipping an AI feature usually means you pay for every token your users burn. Costs are unpredictable, a single power user can wreck your margins, and you carry the risk. Wattfare flips that around: your users bring their own AI budget and approve a spending cap once, in a hosted consent popup. You make model calls on their behalf — metered against that budget, billed to them.
Think “Sign in with Google”, but for AI spend. One button connects a user's inference budget to your app: metered, capped, and revocable at any time. Your secret key never leaves your backend; the browser only ever holds a short-lived, scoped session token.
Why Wattfare
openai/gpt-4o-mini for
anthropic/claude-sonnet-4 with a string.
Three SDK surfaces
The wattfare package has no root export — you import only the surface you need.
Each is a thin, focused layer over the same HTTP API.
useWattfare() hook that wire the whole flow into React.
At a glance
Installing is one command. On your backend, inference is a drop-in AI SDK provider — if you've used the Vercel AI SDK, this will look familiar:
npm install wattfare import { Wattfare } from "wattfare/server";
import { generateText } from "ai";
const wf = new Wattfare({ secretKey: process.env.WATTFARE_SECRET_KEY! });
// Scoped to one of *your* user ids — no Wattfare account for end users.
const ai = wf.user("user_123");
const { text } = await generateText({
model: ai.model("openai/gpt-4o-mini"), // billed to the user's budget
prompt: "Say hello.",
});
The only Wattfare-specific lines are constructing the client and calling wf.user(id).
Everything downstream is standard AI SDK. Usage is metered automatically against the connected
user's budget.