Prepaid balance
Run on a provider key BrainstormRouter holds only for your tenant, paid from a balance you fund in advance. Off by default; your own key always wins.
Prepaid balance
BrainstormRouter never runs your work on a shared provider key. A request is served on a key that belongs to your tenant, or it is refused. There are two ways that key can exist:
| Way to fund execution | Whose key | What you pay BrainstormRouter |
|---|---|---|
| Your own key (BYOK) | One you registered with POST /v1/providers | Nothing. The provider bills you. |
| A prepaid balance | A _managed key_: an upstream credential BrainstormRouter created for you | The call's cost, from your balance. |
Managed keys are off by default. They exist only on a deployment whose operator has set BR_MANAGED_KEYS_ENABLED=1. GET /v1/balance tells you: managed_keys_enabled is false when they are off, and then only your own keys can serve requests.
What a managed key is
A managed key is a dedicated upstream credential — for OpenAI, a project and a service account in BrainstormRouter's organization that only your tenant's traffic uses. It is stored the same way your registered keys are (encrypted, tenant-scoped) and it is never shown, previewed, exported or rotated through any endpoint. You can see _that_ one exists and for which provider, nothing else:
"managed_credentials": [{ "provider": "openai", "status": "active" }]
It is created the first time your balance becomes positive, not at sign-up.
Providers. OpenAI only. Anthropic has no API for creating a key, and OpenRouter's terms do not allow reselling access without written permission, so neither has a managed key; use your own key for those.
Your own key always wins
If you have an active registered key for a provider, it serves every request for that provider and nothing is debited — even when you also have a balance and a managed key. The managed key is used only when you have no registered key for that provider. The two are never mixed or load-balanced against each other.
Read your balance
| REST | MCP tool | SDK |
|---|---|---|
GET /v1/balance | br_get_balance | client.balance.get |
Needs router.read, which every API key role and every OAuth scope includes.
curl https://api.brainstormrouter.com/v1/balance?limit=5 \
-H "Authorization: Bearer $BRAINSTORMROUTER_API_KEY"
{
"currency": "USD",
"balance_micros": 24871200,
"balance_usd": "24.871200",
"reserved_micros": 12000,
"reserved_usd": "0.012000",
"available_micros": 24859200,
"available_usd": "24.859200",
"updated_at": "2026-11-09T18:04:11.000Z",
"managed_keys_enabled": true,
"managed_credentials": [{ "provider": "openai", "status": "active" }],
"entries": [
{
"id": "0e0f…",
"kind": "debit",
"amount_micros": -7701,
"amount_usd": "-0.007701",
"balance_after_micros": 24871200,
"provider_cost_micros": 7001,
"markup_pct": "10.00",
"reference_type": "request",
"reference": "req_01a0…",
"provider": "openai",
"model": "openai/gpt-4.1-nano",
"note": null,
"created_at": "2026-11-09T18:04:11.000Z"
}
]
}
- Amounts are integer micro-USD (1 USD = 1,000,000). Every
*_micros
field has an exact decimal-string twin (*_usd). Do the arithmetic on the integers.
reservedis what is held for calls in flight right now.availableis
balance − reserved.
entriesare newest first:credit,debit,refund,adjustment. A
debit carries the provider's cost and the markup separately, and its reference is the request id — the same id GET /v1/explain takes.
const balance = await client.balance.get({ limit: 5 });
if (balance.available_micros <= 0) {
// top up, or register your own key
}
balance = client.balance.get(limit=5)
print(balance["available_usd"])
How a call is charged
- Before the provider is called, BrainstormRouter holds the call's
estimated cost against your balance. If available is not above zero the call is refused and the provider is never contacted.
- After the call, the hold is replaced by one debit for what the provider
actually charged, plus the deployment's markup if it has one. The debit is recorded once per provider call.
- If the call fails without the provider doing any work, the hold is
released and nothing is debited. A stream you stop reading part-way is charged for the prompt and the output produced up to that point.
This applies to chat completions (streaming and not), br_route_completion and every other tool that routes a completion, the media tools (br_generate_image, br_generate_speech, br_transcribe_audio), and agentic runs.
The REST media and embeddings endpoints (/v1/images/generations, /v1/audio/*, /v1/embeddings) run on a registered key only. They are not served by a managed key.
Running out
HTTP/1.1 402 Payment Required
{
"error": {
"type": "insufficient_balance",
"code": "insufficient_balance",
"provider": "openai",
"available_usd": "0.000000",
"message": "Prepaid balance exhausted for \"openai\" (available: $0.000000). Add funds to your BrainstormRouter balance (GET /v1/balance shows it), or register your own openai key: POST /v1/providers { provider, api_key }.",
"recovery": {
"action": "add_funds_or_register_key",
"recoverable": true,
"options": [
{ "action": "add_funds", "endpoint": "GET /v1/balance" },
{ "action": "register_provider_key", "endpoint": "POST /v1/providers" }
]
}
}
}
insufficient_balance is not byok_required. byok_required (403) means there is no key of any kind for that provider. insufficient_balance (402) means there is a managed key and nothing left to pay for it. Neither is fixed by retrying.
How far below zero a balance can go
A call is admitted while available is above zero, and each admitted call holds its estimate, so calls running at the same time see each other. The balance can end below zero by at most one call's estimated cost, plus any amount by which a call's real cost exceeds its estimate. For a completion that sets max_tokens the estimate is an upper bound; without max_tokens it assumes 4,096 output tokens. Agentic runs and media calls hold a flat amount (US$0.50 by default) because their cost is not known up front.
Adding funds
There is no self-serve payment yet. Credit is added by BrainstormRouter's operator; you cannot credit your own tenant with any API key or role.
For operators
Everything here is behind BR_MANAGED_KEYS_ENABLED=1. With it unset no managed key is selected, nothing is held or debited, and no upstream admin call is made.
| Setting | Meaning | Default |
|---|---|---|
BR_MANAGED_KEYS_ENABLED | Master switch. On only when exactly 1. | off |
OPENAI_ADMIN_KEY | OpenAI Admin API key used to create projects and service accounts. | — |
BR_MANAGED_MARKUP_PCT | Markup on every debit, e.g. 10 or 7.5. Recorded on each entry. | 0 |
BR_MANAGED_RESERVATION_TTL_SEC | How long an unsettled hold keeps counting. | 900 |
BR_MANAGED_RUN_RESERVE_MICROS | Flat hold for an agentic run or media call, in micro-USD. | 500000 |
Operator endpoints (platform operators only — BRAINSTORMROUTER_PLATFORM_ADMIN_IDS):
| Endpoint | SDK | Purpose |
|---|---|---|
GET /v1/admin/tenants/{id}/balance | client.admin.getTenantBalance | Balance plus credential records with upstream identifiers |
POST /v1/admin/tenants/{id}/balance/adjustments | client.admin.adjustTenantBalance | Grant or correct credit; idempotent on idempotency_key |
POST /v1/admin/tenants/{id}/managed-credentials/{provider} | client.admin.manageTenantCredential | provision, reactivate, sync_limit, suspend, revoke |
curl -X POST https://api.brainstormrouter.com/v1/admin/tenants/$TENANT_ID/balance/adjustments \
-H "Authorization: Bearer $OPERATOR_KEY" -H "Content-Type: application/json" \
-d '{ "amount_usd": "25.00", "idempotency_key": "grant-2026-11-09-acme", "note": "launch credit" }'
The ledger is the authority and the hard stop. The provider-side monthly spend limit that BrainstormRouter sets on each tenant's OpenAI project is a backstop only: it is enforced with a delay and resets each month.