SDK Reference
Overview
SDK reference for Scrawn functions, pricing DSL, and production patterns
Everything you need to integrate Scrawn into your application.
Configuration
scrawn() is the factory that creates your billing instance:
// scrawn/biller.ts
import { scrawn } from "@scrawn/core";
import { TAGS, EXPRESSIONS } from "./pricerefs";
export const biller = scrawn({
apiKey: process.env.SCRAWN_KEY,
baseURL: process.env.SCRAWN_BASE_URL,
httpUrl: process.env.SCRAWN_HTTP_URL,
tags: TAGS,
expressions: EXPRESSIONS,
});The factory accepts a single config object:
Prop
Type
Functions
The core methods you call in your code to track usage, bill AI tokens, and collect payments.
Usage Tracking
Track billable events manually or automatically with middleware.
AI Token Billing
Meter AI token usage per-call with streaming, the AI SDK wrapper, or manual tracking.
Collect Payments
Generate a checkout link when a user's balance crosses your threshold.
Webhook Verification
Verify incoming webhooks - fetches the public key, verifies the signature, returns the typed event.
Reference & Guides
Pricing expressions, production patterns, and framework integration.