@usequota/types
v2.1.0
Published
Shared TypeScript types for the Quota AI credit billing SDK
Downloads
366
Readme
@usequota/types
Shared TypeScript types for the Quota AI credit billing SDK.
Billing Model
All monetary values are stored in micro-dollars (1 unit = $0.000001, stored as BIGINT).
To convert to USD: amount / 1_000_000.
Installation
npm install @usequota/typesUsage
import type { QuotaUser, CreditPackage } from "@usequota/types";Balance semantics
The balance field on QuotaUser (and the /oauth/userinfo balance claim)
can be number, null, or temporarily negative:
null— the user is signed in via the Quota IdP but has not linked a credits wallet to this app. Surface a "Link wallet" affordance; do not display0.- Negative — a streaming completion's actual cost exceeded its pre-reservation. The pre-reservation still rejects new requests when balance is below the estimate, so a new request cannot start from a negative balance. The window is bounded by a single in-flight stream that under-estimated.
Types
QuotaUser— authenticated user with balance (micro-dollars)CreditPackage— purchasable credit package (micro-dollars)QuotaSession— user session information for OAuth flowsQuotaErrorResponse— standardized API error response-body shape (the classQuotaErrorlives in@usequota/core)ToolCall— tool/function call informationChatMessage— chat message in OpenAI-compatible formatTool— tool/function definition for function callingChatCompletionRequest— chat completion request (multi-provider)QuotaMetadata— billing metadata in API responses (micro-dollars)ChatCompletionResponse— chat completion response with billing info
Contributing
Any change under src/ (except tests) requires a version bump in
package.json. See agent/WORKFLOWS.md → SDK Versioning
for semver guidance and the bump+publish sequence. A CI check fails any
PR that touches src without bumping.
License
MIT
