Overview
Thebudgets sub-client manages per-grant spending budgets. Allocate a budget when issuing a grant, debit against it as your agent consumes resources, check remaining balances, and review transaction history.
budgets.allocate()
Allocate a spending budget for a grant. The budget is denominated in your chosen unit (e.g., cents, tokens, credits). Threshold alerts are automatically triggered at 50% and 80% consumption.Parameters
string
required
The grant ID to allocate a budget for.
number
required
The initial budget amount. Must be a positive number.
Response: BudgetAllocation
string
Unique budget allocation identifier.
string
The associated grant ID.
number
The original allocated budget amount.
number
The current remaining budget amount.
string
ISO 8601 timestamp when the allocation was created.
budgets.debit()
Debit an amount from a grant’s budget. Uses atomic operations (WHERE remaining >= amount) to prevent overdraft. Returns a 402 INSUFFICIENT_BUDGET error if the remaining balance is insufficient.
Parameters
string
required
The grant ID to debit from.
number
required
The amount to debit. Must be a positive number.
string
Optional description for the transaction (e.g.,
'GPT-4 API call').Response: DebitResponse
number
The remaining budget after the debit.
string
Unique identifier for the debit transaction.
budgets.balance()
Check the current budget balance for a grant.Parameters
string
required
The grant ID to check the balance for.
Response: BudgetAllocation
Returns the same BudgetAllocation shape as allocate() — see above for field descriptions.
budgets.transactions()
List all transactions for a grant’s budget. Supports pagination.Parameters
string
required
The grant ID to list transactions for.
number
Page number for pagination (default: 1).
number
Number of results per page (default: 20, max: 100).
Response: TransactionsResponse
BudgetTransaction[]
Array of transaction records.
number
Total number of transactions for this grant.
BudgetTransaction contains:
string
Unique transaction identifier.
number
The debited amount.
string | null
Optional description of the transaction.
string
ISO 8601 timestamp when the transaction was created.
number
The remaining budget after this transaction.