Userecordtells Unprice what happened.consumedecides whether known usage may happen now.runshold a budget before a workload starts, for cost that is not known yet.access.checkasks without changing state.
eventSlug for the broad event your app observed, such as completions. Use featureSlug for
the specific product feature you are checking or consuming, such as ai-messages,
ai-generations, or ai-tools.
Decision table
access.check: ask without changing state
Use access.check when you want to know whether a customer can use a feature, but you do not want
to consume usage or reserve credits.
result.allowed beside your current logic.
usage.consume: decide and apply now
Use usage.consume when the request path needs a synchronous commercial decision and the usage
amount is known before the work runs.
usage.consume is the enforcing path for a known-cost action. Retry the same logical request
with the same idempotencyKey.
usage.record: report for evidence
Use usage.record when the request should not wait for Unprice to decide. It queues the usage event
for metering, analytics, and invoice evidence.
usage.record never blocks over-budget work. Do not use it as a spend gate. One async event can
carry several measured properties; meters decide which property applies to each feature.
runs: hold a budget envelope
Use budgeted runs when a paid action unfolds over multiple steps and can spend more than expected.
The run labels the workload and holds a budget before it starts.
For the single-call case — one LLM request whose cost you only learn from the response — the
reservations helper wraps the same operations in three
lines. The operations below are for when you need the steps apart.
runs.consume as the workload spends and runs.end when it finishes. Unprice does not own the
workload executor; it owns the budget reservation, spend decision, and evidence trail.
When actual usage is only known after work
The example above authorizes a known amount before a step runs. For variable provider usage, reserve withruns.start, run the workload, then use runs.settle
to account for actual usage. Keep settlement retryable if the response is lost. Do not release the
reservation in finally while incurred usage is still unaccounted for.
Shortcut
Simple request path
Use
usage.consume when one request maps to a known usage amount.Multi-step workload
Use
runs.start when the workload needs a budget before it begins.