Skip to main content
Use @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.
Rotate the key if you believe it was exposed.

First runtime call

Use access.check for a read-only shadow check:
Use usage.consume when known usage must be authorized before paid work runs:
For variable provider usage, start a budgeted run before work and settle actual usage after it completes. Read Choose the runtime call before you connect a production path.

Response format

Every method returns one of these shapes:
Check error before you use result. The error includes a documentation link and request ID.

Client options

Base URL

Use baseUrl 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

Use cache 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. Set disableTelemetry to disable this telemetry.