POST /v1/billing/deduct to deduct from a customer’s available wallet balance in a single request.
This is the right choice for fixed-price image generation, fixed-cost API calls, and other one-time operations where cost is known upfront. It is one of the billing primitives you use for work you price yourself.
Model calls you route through the Velobase AI gateway (
POST /v1/chat/completions, POST /v1/messages) bill the customer wallet automatically at real token cost. You do not need to call deduct for those. Use direct deduction for your own priced work. See the gateway quickstart for routing model calls.Minimal Example
Parameters
The unique identifier for this customer. The customer must already exist and have enough available balance in their wallet.
Unique ID for this charge transaction. Also serves as the idempotency key: repeating a request with the same
transaction_id returns the original result without double-charging.Amount to deduct, in US dollars. Must be greater than 0. You can instead pass
amount_cents or amount_credits, where 1 USD = 100 cents = 1,000,000 credits. A bare amount is legacy and is interpreted as cents.Restrict deduction to these wallet categories only. If omitted, the system may draw from any active credits. If provided and the selected categories have insufficient credits, the request fails.
Transaction category for reporting. Examples:
TASK, ORDER, TOKEN_USAGE.A human-readable note for this transaction.
Response
The unique transaction ID passed in the request.
Total amount actually deducted, in credits (1,000,000 credits = 1 USD).
Deduction breakdown. Funds may be consumed from multiple wallet categories when the amount spans more than one source.
ISO 8601 timestamp when the deduction completed.
true when the response was returned from a previous request with the same transaction_id.Deduction Rules and Wallet Categories
- The system automatically deducts from all available balance across the customer’s wallets.
- If
credit_typesis provided, deduction is limited to those wallet categories only. - Callers do not choose which wallet category to consume from.
- Funds that expire sooner are consumed first. If expiry is the same, older sources are consumed first.
- Only funds that are currently active are eligible for deduction. Sources that have not started yet or have already expired are ignored.
- Use
GET /v1/customers/{id}to inspect the remaining balance per wallet and per source.
Insufficient Balance
Returns400 if the customer doesn’t have enough available balance:
credit_types is provided, the error message becomes insufficient balance in selected credit_types when the selected wallet categories do not have enough credits.
Failed requests do not produce a partial deduction and do not leave behind a half-completed state.
Idempotency
Sametransaction_id returns the same result, with is_idempotent_replay: true and no double charge.
Verify the Result
GET /v1/customers/{id} returns the customer with a wallets map. Each wallet reports total, used, frozen, and available, plus a sources array broken down by funding source:
- whether the wallet’s
availabledecreased (values are in credits, where 1,000,000 credits = 1 USD) - which
sources[]entries were consumed - whether each
sources[].availablevalue changed as expected
Error Format
All API errors return an HTTP error status and a structurederror object:
Human-readable description of the error.
High-level error category.
Stable machine-readable error code for programmatic handling.