Billing
Brainstormer uses a credit-based billing system. All external provider costs (AI completions, embeddings, vector operations, voice, storage) are converted to credits and deducted from the organization’s wallet.All API requests require a valid JWT token in the
Authorization: Bearer <token> header. The API Gateway decodes the JWT and forwards auth context (user-id, organization-id, user-email, x-platform-role, x-org-role) as headers to downstream services.Pricing Model
For each billable operation:
charged_usd = raw_cost_usd * margin_multipliercredits_burned = charged_usd / credit_value_usd- Organization wallet is debited by
credits_burned
Platform Billing Summary (Superadmin)
Get platform-wide billing summary with cost vs. revenue analysis.Query Parameters
string
Start of reporting period (ISO 8601 datetime). Optional.
string
End of reporting period (ISO 8601 datetime). Optional.
string
Filter to a specific organization UUID. Optional.
Response (200)
object
Aggregate totals for the period.
object[]
Day-by-day breakdown for charting.
object[]
Breakdown by provider (OpenRouter, Pinecone, ElevenLabs, etc.).
object[]
Breakdown by organization.
object[]
Distribution of organizations across billing plans.
Billable Operations
The following operations are currently billed:Data Model
Core Tables
Atomic Billing Function
All billing writes happen through therecord_external_cost_event() PostgreSQL function, which performs the entire flow in a single transaction:
- Load billing defaults
- Ensure org billing account exists
- Lock wallet row
- Calculate charged USD and credits burned
- Update wallet balance
- Insert cost event record
- Insert ledger entry
- Return billing result
List Public Billing Plans
Returns the active billing plan catalog shown on the signup page. No authentication required.Response (200)
boolean
object[]
Array of active plans.
List Admin Billing Plans
Returns all billing plans for superadmin management. Requires superadmin access.Response (200)
object[]
Array of all plans.
Update a Billing Plan
Updates a billing plan. Requires superadmin access. The plan name is read-only.Body
number
Monthly credit allocation.
number
Monthly price in USD.
number | null
Maximum agents allowed. Pass
null for unlimited.number | null
Maximum knowledge bases allowed. Pass
null for unlimited.string
Plan description shown on signup cards.
Response (200)
boolean

