Scrawn LogoScrawn Docs
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:

import { scrawn, tag } from "@scrawn/core";

const biller = scrawn({
  apiKey: process.env.SCRAWN_KEY as `scrn_${string}`,
  baseURL: process.env.SCRAWN_BASE_URL || "http://localhost:8069",
  tags: ["PREMIUM_CALL", "EXTRA_FEE"] as const,
  expressions: ["MY_EXPR"] as const,
  retryCount: 3,
});

The factory accepts a single config object:

ParamTypeDefaultDescription
apiKeystringYour Scrawn API key (starts with scrn_)
baseURLstringBase URL of your Scrawn backend (e.g. http://localhost:8069)
securebooleantrueWhether to use TLS for gRPC. Set to false for local dev
tagsreadonly string[]Known tag names for compile-time type checking on biller.tag()
expressionsreadonly string[]Known expression names for compile-time type checking on biller.expr()
retryCountnumber2Auto-retry attempts on transient network errors. Set to 0 to disable

Functions

The core methods you call in your code to track usage, bill AI tokens, and collect payments.

Reference & Guides

Pricing expressions, production patterns, and framework integration.