NullSpend Docs

NullSpend

The open-source profitability layer for AI-native SaaS. Per-request cost tracking, per-customer margin intelligence, budget enforcement, and Stripe revenue sync — across SDK, proxy, Claude Agent adapter, and MCP surfaces.

The open-source profitability layer for AI-native SaaS. Per-request cost tracking, per-customer margin intelligence, budget enforcement, and Stripe revenue sync — across SDK, proxy, Claude Agent adapter, and MCP surfaces.

The Problem

AI-native SaaS companies have 10–100x per-customer cost variance they cannot see, cannot control, and cannot bill correctly for. Two power users can quietly burn 40% of your inference bill while one runaway agent loop consumes thousands of dollars before anyone notices. Existing observability tools alert you after the spend has happened. NullSpend instruments cost at the request level, attributes it to customers and tags, enforces budgets before the upstream call fires, and syncs margins back to Stripe so finance, engineering, and the dashboard agree on the same numbers.

How It Works

NullSpend ships as four integration surfaces backed by one accounting engine. Pick the surface that matches how your code already calls LLMs — they share the same dashboard, budgets, and webhooks.

  SDK            Proxy           Claude Agent       MCP
  (TS / Python)  (drop-in URL)   (adapter)          (server + proxy)
        │             │               │                │
        └───────────┴───────────────┴───────────────┘

                       NullSpend core
             cost engine · enforcement · attribution

         ┌─────────────────────┼────────────────────┐
         ▼                      ▼                      ▼
     Dashboard              Webhooks                Stripe sync

SDK — wrap your existing provider client with createTrackedFetch (@nullspend/sdk or nullspend for Python). Your provider clients stay as-is, no URL change.

Proxy — swap one environment variable. Useful when you can't modify the call site.

# Before                                    # After
OPENAI_BASE_URL=https://api.openai.com/v1   OPENAI_BASE_URL=https://proxy.nullspend.dev/v1

Claude Agent adapter@nullspend/claude-agent routes Claude Agent SDK calls through the proxy with no other code changes.

MCP@nullspend/mcp-server exposes approval tools to any MCP client; @nullspend/mcp-proxy gates upstream MCP tool calls through budget enforcement and HITL.

Add an X-NullSpend-Key header (proxy) or pass an API key (SDK) and every request is tracked, budgeted, attributed, and visible.

Per-customer budgetsbind and gate cap each end-user independently in dollars and return paywall payloads on denial. See the Per-Customer Budgets guide for the conceptual model and the Unit Economics API reference for shapes.

What You Get

Three capability pillars, each available across every integration surface.

Cost intelligence

Cost trackingPer-request cost calculation across 56 models — input, output, cached, and reasoning tokens. BIGINT microdollar precision end-to-end.
Cost attributionBreak down spend by customer, team, feature, environment, or any tag. Drill into daily trends, export CSV for finance.
TagsAttach arbitrary key/value pairs to every request via X-NullSpend-Tags. Becomes the join key for attribution, budgets, and webhooks.
TracingW3C traceparent propagation and custom trace IDs for request correlation across services.
Request loggingOpt-in capture of full request/response bodies (including streaming) for debugging and audit (Pro / Scale / Enterprise).
Session replayGroup LLM calls by session ID, view the full chronological timeline, expand to inspect bodies.

Enforcement

BudgetsHard spending ceilings. The proxy returns 429 before the request reaches the provider.
Velocity limitsDetect runaway loops — block when spend rate exceeds a threshold within a time window.
Session limitsPer-conversation spend caps tied to a session ID.
Plan limitsPer-tier monthly governed-request cap — Free hard-blocks, Pro / Scale bill overage.
HITL approvalsHuman-in-the-loop approval workflow for high-cost or sensitive operations.
OrganizationsTeam collaboration with roles (owner, admin, member, viewer), per-org billing, invitation management.

Margin and billing

Stripe margin syncPull customer revenue from Stripe, join against NullSpend cost data, surface per-customer margin in the dashboard.
Customer health tiersAutomatic classification of every customer as Healthy / At-Risk / Burning based on margin trend, spend velocity, and revenue ratio.
Webhooks20 event types with HMAC-SHA256 signing — cost events, budget exceeded, velocity alerts, threshold crossings, loop detection, plan-limit denials, margin alerts.
Multi-providerOpenAI, Anthropic, and Google Gemini in a single dashboard with provider breakdown.

Trust Model

Neither the proxy nor the SDK modifies your requests or responses. Your provider API keys stay with you — they pass through to the upstream provider and are never stored. By default, NullSpend sees only the token counts in the response to calculate cost; prompt content is not logged. Pro, Scale, and Enterprise plans can opt in to request/response body logging for debugging and audit purposes; bodies are stored encrypted in R2 with per-org lifecycle policies. The full stack is Apache-2.0 licensed and self-hostable — every line of code that touches your traffic is auditable.

Pricing

FreeProScaleEnterprise
Price$0/mo$49/mo$199/moCustom
Governed requests / mo100,000500,0002,000,000Unlimited
OverageHard block$0.010 / request$0.005 / requestCustom
Budgets3UnlimitedUnlimitedUnlimited
API keys10UnlimitedUnlimitedUnlimited
Team membersUnlimitedUnlimitedUnlimitedUnlimited
Webhooks2 endpointsUnlimitedUnlimitedUnlimited
Data retention7 days60 days180 daysCustom
Request logging--Full request/response bodiesFull request/response bodiesFull request/response bodies
Enforcement (velocity, session, mandates, tag-budgets, multi-org)IncludedIncludedIncludedIncluded
Margin intelligence + Stripe sync--IncludedIncludedIncluded
SSO / SAML / SCIM, EU residency------Included

Full plan comparison and FAQ live on the pricing page.

Get Started

Pick the integration surface that matches your stack. Setup is under 2 minutes for any of them.

SDK — recommended for new projects:

Proxy — recommended when you can't modify the call site:

Agent + MCP integrations:

Migrations and tooling:

For AI agents: fetch /llms.txt for the complete machine-readable API reference.

API Reference

Build programmatic integrations with the NullSpend API:

  • API Overview — authentication, pagination, errors, ID formats
  • Cost Events — ingest and query cost data
  • API Keys — key management and identity introspection
  • Budgets — spending limits and budget status
  • Webhooks — endpoint management and delivery history
  • Actions — human-in-the-loop approval workflows

SDKs and adapters

Client libraries and adapters for integrating NullSpend into your stack:

  • JavaScript SDK@nullspend/sdk — TypeScript/JavaScript client for the NullSpend API
  • Python SDKnullspend — Python client for the NullSpend API
  • Claude Agent Adapter@nullspend/claude-agent — routes Claude Agent SDK calls through the proxy
  • MCP Server@nullspend/mcp-server — exposes approval tools to any MCP client
  • MCP Proxy@nullspend/mcp-proxy — gates upstream MCP tool calls through approval and budget enforcement

On this page