Skip to content
Start here

Billing

Get credit balance
GET/accounts/{account_id}/ai-gateway/billing/credit-balance
Get usage history
GET/accounts/{account_id}/ai-gateway/billing/usage-history
Get invoice history
GET/accounts/{account_id}/ai-gateway/billing/invoice-history
Get invoice preview
GET/accounts/{account_id}/ai-gateway/billing/invoice-preview
ModelsExpand Collapse
BillingCreditBalanceResponse object { balance, has_default_payment_method, payment_method, 2 more }
balance: number
has_default_payment_method: boolean
payment_method: object { brand, last4 }
brand: optional string
last4: optional string
topup_config: object { amount, disabledReason, error, 2 more }
amount: number
disabledReason: string
error: string
lastFailedAt: number
threshold: number
first_topup_success: optional boolean
BillingUsageHistoryResponse object { history }
history: array of object { id, aggregated_value, end_time, start_time }
id: string
aggregated_value: number
end_time: number
start_time: number
BillingInvoiceHistoryResponse object { invoices, pagination }
invoices: array of object { amount_due, amount_paid, amount_remaining, 11 more }
amount_due: number
amount_paid: number
amount_remaining: number
currency: string
id: optional string
attempt_count: optional number
attempted: optional boolean
auto_advance: optional boolean
created: optional number
created_by: optional string
description: optional string
invoice_origin: optional string
invoice_pdf: optional string
status: optional string
BillingInvoicePreviewResponse object { id, amount_due, amount_paid, 6 more }
id: string
amount_due: number
amount_paid: number
amount_remaining: number
currency: string
invoice_lines: array of object { amount, currency, description, 4 more }
amount: number
currency: string
description: string
period: object { end, start }
end: number
start: number
pricing: object { unit_amount_decimal }
unit_amount_decimal: string
quantity: number
pretax_credit_amounts: optional array of object { amount, type, credit_balance_transaction, discount }
amount: number
type: string
credit_balance_transaction: optional string
discount: optional string
period_end: number
period_start: number
status: "draft" or "open" or "paid" or 2 more
One of the following:
"draft"
"open"
"paid"
"uncollectible"
"void"

BillingTopup

Create a top-up
POST/accounts/{account_id}/ai-gateway/billing/topup
Check top-up status
POST/accounts/{account_id}/ai-gateway/billing/topup/status
ModelsExpand Collapse
TopupCreateResponse object { client_secret, onboarding, payment_intent_id, 2 more }
client_secret: string

Stripe PaymentIntent client secret.

onboarding: boolean

Whether the user was already onboarded.

payment_intent_id: string

Stripe invoice ID.

brand: optional string

Card brand (visa, mastercard, etc.).

last4: optional string

Last 4 digits of card.

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

BillingTopupConfig

Get auto top-up configuration
GET/accounts/{account_id}/ai-gateway/billing/topup/config
Set auto top-up configuration
POST/accounts/{account_id}/ai-gateway/billing/topup/config
Delete auto top-up configuration
DELETE/accounts/{account_id}/ai-gateway/billing/topup/config
ModelsExpand Collapse
ConfigGetResponse object { amount, disabledReason, error, 2 more }
amount: number
disabledReason: string
error: string
lastFailedAt: number
threshold: number
ConfigCreateResponse object { amount, threshold }
amount: number
threshold: number
ConfigDeleteResponse = unknown

BillingSpending Limit

Get spending limit
GET/accounts/{account_id}/ai-gateway/billing/spending-limit
Set spending limit
POST/accounts/{account_id}/ai-gateway/billing/spending-limit
Delete spending limit
DELETE/accounts/{account_id}/ai-gateway/billing/spending-limit
ModelsExpand Collapse
SpendingLimitGetResponse object { config, enabled }
config: object { amount, duration, strategy }
amount: number
duration: string
strategy: string
enabled: boolean
SpendingLimitCreateResponse = unknown
SpendingLimitDeleteResponse = unknown