@unprice/api in your server request path. 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:
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.