cusage

Rounding errors in the invoices on this page: 0.000000000000000000

Usage pricing, compiled.

Describe your pricing in one .usage file: credits, tiers, seats, minimums and limits. Every invoice comes out exact, and every customer can see what they pay and why.

pricing.usage
unit token, credit, seatcurrency USD​/** One LLM call: the event your service sends. */struct llm_call {    tokens: int<token>    user_id: string}​meter calls = count() from llm_callmeter credits: credit =    sum(tokens * 0.005 credit/token) from llm_callmeter seats: seat =    count_distinct(user_id) from llm_call​plan starter "Starter" {    charge credits "AI credits" { price 0.002 USD/credit }    charge seats "Seats" { price 8 USD/seat }    limit credits 200000 credit per month}​plan team "Team" {    fee "Team plan" 49 USD    charge credits "AI credits" {        included 50000 credit        price 0.0015 USD/credit    }    charge seats "Seats" { price 5 USD/seat }}​test "acme" {    plan starter    events {        llm_call { tokens: 15000, user_id: "ana" } x 400    }}​test "globex" {    plan team    events {        llm_call { tokens: 40000, user_id: "ben" } x 1500        llm_call { tokens: 2000, user_id: "cy" } x 3000    }}

Every customer, this month

CustomerPlanLLM callsInvoice
AcmeStarter400$68.00
GlobexTeam4,500$479.00
Revenue this month$547.00

The product team sees every customer. Pick one to see only what they see.

Building this page:

  • Schemas compiled: 5
  • Tests passed: 13 of 13
  • Invoices priced: 33
  • Decimal places: 18
  • Floats used: 0
  • Servers called: 0

Your pricing, as one file the whole company can read. Product writes the plans, engineering sends the usage, finance gets invoices that add up, and customers see exactly what they pay for.

Read the language

Price usage the way you sell it. Every result below is the engine's, from the example schemas.

Graduated tiers, included credits, a fee. Priced to the cent.

plan pro "Pro" {
    fee "Pro subscription" 49 USD
    charge credits "AI credits" {
        included 50000 credit
        tiered graduated {
            up to 500000 credit at 0.0015 USD/credit
            above at 0.001 USD/credit
        }
    }
    charge requests "API requests" {
        included 100000 request
        package 1000 request at 0.25 USD
    }
    charge active_users "Seats" {
        price 8 USD/seat
    }
    minimum 99 USD
    limit credits 2000000 credit per month
    limit requests 6000 request per minute
    limit workspaces 20 workspace
}

AI platform · “pro: a heavy month reaches the second credit tier” on Pro

Pro subscription
$49.00
AI credits724000 credits used · 50000 included · 500000 × 0.0015 + 174000 × 0.001
$924.00
API requests251000 requests used · 100000 included · 151 × 1000 requests at 0.25
$37.75
Seats3 seats used · 3 × 8
$24.00
Total
$1,034.75

Volume tiers and committed spend. One rate for every unit, set by the month's total.

plan committed "Committed" {
    fee "Committed spend" 2000 USD
    charge credits "Compute credits" {
        included 2500000 credit
        tiered volume {
            up to 10000000 credit at 0.0008 USD/credit
            above at 0.0006 USD/credit
        }
    }
    limit gpus_running 64 gpu
}

GPU cloud · “committed: the same month costs less” on Committed

Committed spend
$2,000.00
Compute credits4638050 credits used · 2500000 included · 2138050 × 0.0008
$1,710.44
Total
$3,710.44

Seats from who actually used it. Four editors this month are four seats.

meter editors: seat = count_distinct(user_id) from activity where role == "editor"

plan team "Team" {
    charge editors "Editor seats" {
        price 15 USD/seat
    }
    charge extra_ai_credits "AI credits" {
        price 0.01 USD/credit
    }
    limit files 10000 file
}

Design tool · “team: four editors and a lot of AI” on Team

Editor seats4 seats used · 4 × 15
$60.00
AI credits1200 credits used · 1200 × 0.01
$12.00
Total
$72.00

Rate cards by country, model or GPU. Add a country and every table has to price it.

table sms_rate[Country]: credit/segment {
    "PL": 3
    "DE": 6
    "GB": 4
    "US": 1
}

meter sms_credits: credit = sum(segments * sms_rate[country]) from message_sent where channel == "sms" by country

Messaging API · “payg: a month of password checks in Poland” on Pay as you go

  • SMS credits30,000 credits
  • Messages10,000 messages
  • Checks9,000 checks
  • Credits75,000 credits
Total€750.00

A minimum spend. Small accounts are topped up to it, on its own line.

plan business "Business" {
    charge editors "Editor seats" {
        tiered volume {
            up to 50 seat at 25 USD/seat
            up to 200 seat at 20 USD/seat
            above at 16 USD/seat
        }
    }
    charge extra_ai_credits "AI credits" {
        price 0.008 USD/credit
    }
    charge storage "Storage" {
        included 1000 GB
        price 0.02 USD/GB
    }
    minimum 500 USD
}

Design tool · “business: a small team pays the minimum” on Business

Editor seats2 seats used · 2 × 25
$50.00
AI credits0 credits used
$0.00
Storage1200 GB used · 1000 included · 200 × 0.02
$4.00
Minimum spend top-upbrings the invoice up to the plan minimum
$446.00
Total
$500.00

Limits that hold. Spend caps, rate limits and caps on seats or workspaces, checked before the work.

plan starter "Starter" {
    charge credits "AI credits" {
        included 5000 credit
        price 0.002 USD/credit
    }
    charge requests "API requests" {
        included 10000 request
        package 1000 request at 0.40 USD
    }
    // Limits are enforced when a service reserves before the work (exact) or takes
    // a lease (fast). `per` makes a limit start over each minute, hour, day or month.
    /** Hard stop on the self-serve tier. */
    limit credits 200000 credit per month
    /** Rate limit for the public API. */
    limit requests 600 request per minute
    limit workspaces 3 workspace
}

AI platform · “starter: a busy month” on Starter

  • Credits25,805 of 200,000 credits a month
  • Requestsat most 600 requests a minute
  • Workspaces0 of 3 workspaces

For your customers

A bill that explains itself. Every charge, and the usage behind it.

The engine that bills a customer also tells them why: how many credits each model used, what was included, which tier a unit fell in. A calculator built from the same schema shows what next month will cost before it happens.

Invoice · Starter · “starter: a busy month”

AI credits25805 credits used · 5000 included · 20805 × 0.002
$41.61
API requests42000 requests used · 10000 included · 32 × 1000 requests at 0.40
$12.80
Total
$54.41

The usage behind it

  • LLM credits24,600 credits
  • Image credits1,080 credits
    • 10241,000
    • 204880
  • Requests42,000 requests
  • Total events43,662
  • Active users3 seats
  • Storage12.5 GB
  • Storage credits125 credits
  • Credits25,805 credits

A wrong price doesn't compile. Mistakes are caught before the first invoice goes out.

Units that can't be mixed up. Credits plus seats is a compile error, not a wrong invoice.

unit token, credit, seat

struct llm_call {
    tokens: int<token>
    user_id: string
}

meter credits: credit = sum(tokens * 2 credit/token) from llm_call
meter seats: seat = count_distinct(user_id) from llm_call
metric total: credit = credits + seats
error: cannot add `credit` and `seat`
  --> pricing.usage:10:24
   |
10 | metric total: credit = credits + seats
   |                        ^^^^^^^^^^^^^^^
   = hint: both sides need the same unit; convert one with a rate, e.g. `tokens * 0.001 credit/token`
Open it in the playground and fix it

Rate tables that price every value. Add a model to the type and every table has to price it.

unit token, credit

type Model = "gpt-4o" | "claude-sonnet" | "small"

table input_rate[Model]: credit/token {
    "gpt-4o": 0.0025
    "claude-sonnet": 0.003
}
error: table `input_rate` has no rate for "small"
 --> pricing.usage:5:7
  |
5 | table input_rate[Model]: credit/token {
  |       ^^^^^^^^^^
  = hint: every Model needs a rate: add it, or a default
Open it in the playground and fix it

Prices in the right unit. A charge on credits is priced per credit, or it doesn't compile.

unit credit
currency USD

struct call {
    n: int
}

meter credits: credit = sum(n * 1 credit) from call

plan starter "Starter" {
    charge credits "AI credits" {
        price 0.002 USD
    }
}
error: price of `credits` must be in `USD/credit`, got `USD`
  --> pricing.usage:12:15
   |
12 |         price 0.002 USD
   |               ^^^^^^^^^
   = hint: e.g. 0.002 USD/credit
Open it in the playground and fix it

Hints, like a good compiler's. A typo comes back with what you probably meant.

unit seat

struct activity {
    user_id: string
}

meter seats: seat = count_distinct(user_idd) from activity
error: unknown field `user_idd` on `activity`
 --> pricing.usage:7:36
  |
7 | meter seats: seat = count_distinct(user_idd) from activity
  |                                    ^^^^^^^^
  = hint: did you mean `user_id`?
Open it in the playground and fix it

Change prices without surprises. Tests pin the numbers down.

A test is a month of made-up usage and what it must cost. Change a rate or a tier and the tests say which invoices moved. Every server runs them at startup and refuses to start if one fails.

test "a busy team" {
    plan team
    events {
        llm_call { model: "claude-sonnet", input_tokens: 40000, output_tokens: 8000, user_id: "ana" } x 1500
        llm_call { model: "claude-sonnet", input_tokens: 40000, output_tokens: 8000, user_id: "ben", cached: true } x 500
        llm_call { model: "small", input_tokens: 2000, output_tokens: 500, user_id: "cy" } x 3000
    }
    expect credits == 374400 credit
    expect charge credits == 486.60 USD
    expect total == 550.60 USD
}

$ cusage test pricing.usage

✓ credits == 374400 credit

✓ charge credits == 486.60 USD

✓ total == 550.60 USD

The playground

Write a schema. See the invoice.

  • Errors and hints as you type
  • Every test run on each change
  • Each test priced on every plan, with the invoice behind each number
  • A calculator for whatever you wrote

Usage is money. Count it exactly.

$ cusage test pricing.usageRun it here