Get Started

Billing

Usage metering, cost tracking, and per-user billing data. Theazo tracks everything — compute, model calls, storage — so AgentCo can bill their users.

What gets metered

Theazo meters four categories of usage. All metering happens automatically regardless of which mode you operate in.

  • Compute minutes — always metered. Every second an agent sandbox is running counts toward compute.
  • Model tokens — metered in managed loop mode. Input and output tokens for every model call the orchestrator makes.
  • Storage — snapshots, knowledge base embeddings, and agent file storage.
  • Orchestration events — workflow runs, fleet items dispatched, approval lifecycle events, and scheduled executions.

Three pricing modes

What you pay depends on which parts of Theazo you use. BYOI customers pay their provider directly and only pay Theazo for orchestration.

Mode
Compute
Orchestration
Who pays provider
Infra-only
$0.005/min
--
Theazo (managed)
BYOI Primitives
--
$0.01/wf run, $0.001/fleet item
You (BYOI)
Full Platform
$0.005/min
$0.01/wf run, $0.001/fleet item
Theazo (managed)

Per-user usage

Every session tracks its own usage. Call session.usage() to get current consumption — useful for building usage meters in your product UI or for passing costs through to your users.

usage.ts
const session = await theazo.sessions.forUser(class="cb-str">'user_123')

const usage = await session.usage()

console.log(usage.cost)            class="cb-cmt">// { amount: 234, currency: 'usd' }
console.log(usage.computeMinutes)  class="cb-cmt">// 47
console.log(usage.activeAgents)    class="cb-cmt">// 2
console.log(usage.modelCalls)      class="cb-cmt">// 38

Cost controls

Set per-session limits when creating a session. Theazo enforces limits atomically using Redis INCRBY — there is no race window where an agent can exceed its budget. When a limit is breached, all running agents in the session are paused and a session.limit_reached webhook fires.

cost-controls.ts
const session = await theazo.sessions.forUser(class="cb-str">'user_123', {
  limits: {
    maxCost: { amount: class="cb-num">500, currency: class="cb-str">'usd', period: class="cb-str">'day' },   class="cb-cmt">// $5.00/day
    maxAgents: class="cb-num">3,                                                 class="cb-cmt">// max 3 concurrent
    maxComputeMinutes: class="cb-num">60,                                        class="cb-cmt">// 1 hour compute
  },
})

// When exceeded:
// 1. All running agents are paused (not terminated)
// 2. session.limit_reached webhook fires
// 3. Agents can resume after limits are updated:
await session.updateLimits({
  maxCost: { amount: class="cb-num">2000, currency: class="cb-str">'usd', period: class="cb-str">'day' },
})
await session.resume()

Usage export

Export usage data for re-billing your users. Theazo supports three export formats: Stripe-compatible line items, CSV for spreadsheets, and raw JSON.

export.ts
// Stripe-compatible export — ready for invoice line items
const stripe = await theazo.usage.export({
  format: class="cb-str">'stripe',
  period: { start: class="cb-str">'2025-05-01', end: class="cb-str">'2025-05-31' },
})

// CSV export — per-session rows with cost breakdown
const csv = await theazo.usage.export({
  format: class="cb-str">'csv',
  period: { start: class="cb-str">'2025-05-01', end: class="cb-str">'2025-05-31' },
})

// JSON export — full usage records with metadata
const json = await theazo.usage.export({
  format: class="cb-str">'json',
  period: { start: class="cb-str">'2025-05-01', end: class="cb-str">'2025-05-31' },
  groupBy: class="cb-str">'session',   class="cb-cmt">// or 'user', 'provider', 'day'
})
Costs use { amount: number, currency: string } where amount is integer cents. Never strings. 500 means $5.00.

Method reference

session.usage()Promise<UsageSnapshot>Current consumption: cost, computeMinutes, activeAgents, modelCalls.
session.limits()Promise<LimitsSnapshot>Configured limits alongside current usage for each dimension.
session.updateLimits(limits)Promise<void>Update limits on a live session. Partial updates supported.
theazo.usage.export(opts)Promise<ExportResult>Export usage data as Stripe line items, CSV, or JSON.
theazo.usage.daily(opts)Promise<DailyUsage[]>Daily aggregated usage for charts and dashboards.
theazo.usage.byProvider(opts)Promise<ProviderUsage[]>Usage broken down by compute provider (E2B, Docker, Fly).
Was this page helpful?
Ask anything...⌘I