@unprice/api in your server request path to authorize customer spend before paid work runs.
Create or map a customer, check access, consume usage, reserve a workload budget, and inspect usage
or wallet evidence.
The SDK returns typed results for expected API failures. Each call returns either result or
error.
Install
Configure the client
Create a project API key in the project settings. Keep the key in server-side configuration. Do not send it to a browser or commit it to a repository.First runtime call
Useaccess.check for a read-only shadow check:
usage.consume when known usage must be authorized before paid work runs:
reservations is a helper over the runs operations, not a separate API. Read
the reservations helper for what each call maps to, and use
runs.start / runs.consume / runs.settle / runs.end directly for multi-step workloads.
Read Choose the runtime call before you connect a production path.
The client also carries the budget client:
unprice.budgets and unprice.budget(key). It is
published on its own as @unprice/budgets. See Unprice Budgets.Response format
Every method returns one of these shapes:error before you use result. The error includes a documentation link and request ID.
Client options
Base URL
UsebaseUrl to send requests to your own Unprice deployment.
string
default:"https://api.unprice.dev"
Retries
The SDK retries network and server errors by default. Configure the retry count and backoff when your request path needs a different policy.Cache
Usecache to configure the standard fetch cache behavior for SDK requests.
string
Use a
RequestCache value such as default, no-store, or reload.Disable telemetry
By default, the SDK sends anonymous telemetry: runtime, platform, and SDK version. SetdisableTelemetry to disable this telemetry.