Skip to content
Start here

Billing

Get credit balance
client.aiGateway.billing.creditBalance(BillingCreditBalanceParams { account_id } params, RequestOptionsoptions?): BillingCreditBalanceResponse { balance, has_default_payment_method, payment_method, 2 more }
GET/accounts/{account_id}/ai-gateway/billing/credit-balance
Get usage history
client.aiGateway.billing.usageHistory(BillingUsageHistoryParams { account_id, value_grouping_window, end_time, start_time } params, RequestOptionsoptions?): BillingUsageHistoryResponse { history }
GET/accounts/{account_id}/ai-gateway/billing/usage-history
Get invoice history
client.aiGateway.billing.invoiceHistory(BillingInvoiceHistoryParams { account_id, type } params, RequestOptionsoptions?): BillingInvoiceHistoryResponse { invoices, pagination }
GET/accounts/{account_id}/ai-gateway/billing/invoice-history
Get invoice preview
client.aiGateway.billing.invoicePreview(BillingInvoicePreviewParams { account_id } params, RequestOptionsoptions?): BillingInvoicePreviewResponse { id, amount_due, amount_paid, 6 more }
GET/accounts/{account_id}/ai-gateway/billing/invoice-preview
ModelsExpand Collapse
BillingCreditBalanceResponse { balance, has_default_payment_method, payment_method, 2 more }
balance: number
has_default_payment_method: boolean
payment_method: PaymentMethod | null
brand?: string
last4?: string
topup_config: TopupConfig { amount, disabledReason, error, 2 more }
amount: number | null
disabledReason: string | null
error: string | null
lastFailedAt: number | null
threshold: number | null
first_topup_success?: boolean
BillingUsageHistoryResponse { history }
history: Array<History>
id: string
aggregated_value: number
end_time: number
start_time: number
BillingInvoiceHistoryResponse { invoices, pagination }
invoices: Array<Invoice>
amount_due: number
amount_paid: number
amount_remaining: number
currency: string
id?: string | null
attempt_count?: number
attempted?: boolean
auto_advance?: boolean | null
created?: number
created_by?: string
description?: string | null
invoice_origin?: string
invoice_pdf?: string | null
status?: string | null
BillingInvoicePreviewResponse { id, amount_due, amount_paid, 6 more }
id: string
amount_due: number
amount_paid: number
amount_remaining: number
currency: string
invoice_lines: Array<InvoiceLine>
amount: number
currency: string
description: string | null
period: Period { end, start }
end: number
start: number
pricing: Pricing { unit_amount_decimal }
unit_amount_decimal: string | null
quantity: number
pretax_credit_amounts?: Array<PretaxCreditAmount>
amount: number
type: string
credit_balance_transaction?: string | null
discount?: string | null
period_end: number
period_start: number
status: "draft" | "open" | "paid" | 2 more
One of the following:
"draft"
"open"
"paid"
"uncollectible"
"void"

BillingTopup

Create a top-up
client.aiGateway.billing.topup.create(TopupCreateParams { account_id, amount } params, RequestOptionsoptions?): TopupCreateResponse { client_secret, onboarding, payment_intent_id, 2 more }
POST/accounts/{account_id}/ai-gateway/billing/topup
Check top-up status
client.aiGateway.billing.topup.status(TopupStatusParams { account_id, payment_intent_id } params, RequestOptionsoptions?): TopupStatusResponse { payment_intent_id, status }
POST/accounts/{account_id}/ai-gateway/billing/topup/status
ModelsExpand Collapse
TopupCreateResponse { client_secret, onboarding, payment_intent_id, 2 more }
client_secret: string | null

Stripe PaymentIntent client secret.

onboarding: boolean

Whether the user was already onboarded.

payment_intent_id: string

Stripe invoice ID.

brand?: string

Card brand (visa, mastercard, etc.).

last4?: string

Last 4 digits of card.

TopupStatusResponse { payment_intent_id, status }
payment_intent_id: string
status: "completed" | "pending"
One of the following:
"completed"
"pending"

BillingTopupConfig

Get auto top-up configuration
client.aiGateway.billing.topup.config.get(ConfigGetParams { account_id } params, RequestOptionsoptions?): ConfigGetResponse { amount, disabledReason, error, 2 more }
GET/accounts/{account_id}/ai-gateway/billing/topup/config
Set auto top-up configuration
client.aiGateway.billing.topup.config.create(ConfigCreateParams { account_id, amount, threshold } params, RequestOptionsoptions?): ConfigCreateResponse { amount, threshold }
POST/accounts/{account_id}/ai-gateway/billing/topup/config
Delete auto top-up configuration
client.aiGateway.billing.topup.config.delete(ConfigDeleteParams { account_id } params, RequestOptionsoptions?): ConfigDeleteResponse
DELETE/accounts/{account_id}/ai-gateway/billing/topup/config
ModelsExpand Collapse
ConfigGetResponse { amount, disabledReason, error, 2 more }
amount: number | null
disabledReason: string | null
error: string | null
lastFailedAt: number | null
threshold: number | null
ConfigCreateResponse { amount, threshold }
amount: number
threshold: number
ConfigDeleteResponse = unknown

BillingSpending Limit

Get spending limit
client.aiGateway.billing.spendingLimit.get(SpendingLimitGetParams { account_id } params, RequestOptionsoptions?): SpendingLimitGetResponse { config, enabled }
GET/accounts/{account_id}/ai-gateway/billing/spending-limit
Set spending limit
client.aiGateway.billing.spendingLimit.create(SpendingLimitCreateParams { account_id, amount, duration, strategy } params, RequestOptionsoptions?): SpendingLimitCreateResponse
POST/accounts/{account_id}/ai-gateway/billing/spending-limit
Delete spending limit
client.aiGateway.billing.spendingLimit.delete(SpendingLimitDeleteParams { account_id } params, RequestOptionsoptions?): SpendingLimitDeleteResponse
DELETE/accounts/{account_id}/ai-gateway/billing/spending-limit
ModelsExpand Collapse
SpendingLimitGetResponse { config, enabled }
config: Config { amount, duration, strategy }
amount: number | null
duration: string | null
strategy: string | null
enabled: boolean
SpendingLimitCreateResponse = unknown
SpendingLimitDeleteResponse = unknown