Skip to main content
The @velobaseai/billing package wraps the Velobase control-plane: customer deposits, balances, ledgers, and the freeze / consume / deduct primitives. It ships ESM and CommonJS builds with full TypeScript types.
The SDK is for the billing control-plane. To make model calls, point the OpenAI SDK at the gateway, see OpenAI-Compatible Gateway.

Install

Initialize

Deposit credits to a customer

State the amount with an explicit unit. amountUsd is the least error-prone.
Pass idempotencyKey so a retry never double-credits (use your payment event id in production):
amount (cents) is still accepted for backward compatibility, but prefer the explicit amountUsd / amountCents / amountCredits so the unit is clear.

Read a balance

get() returns the customer with their wallets, each broken down by source:

Read the ledger

Billing primitives

For metering work you price yourself (not model calls, which bill automatically), use freeze → consume for unknown-cost work, or deduct for fixed-cost work.

Errors

All failures throw a VelobaseError (check with isVelobaseError(err)), carrying the HTTP status, error type, and server request_id. See Errors.