Billing Overview
How billing works in SoxAI — pre-consumption, settlement, and refunds
Billing
SoxAI uses a prepaid credit model with atomic pre-consumption billing. You add funds to your balance, and usage is deducted as requests are processed.
How It Works
1. Add credits to your balance (Top Up)
2. Make API requests
3. SoxAI pre-consumes an estimated cost before sending to the upstream provider
4. After the response, SoxAI settles based on actual token usage
5. Underage is refunded; overage is charged
6. Errors result in a full refundThis approach prevents overspending while ensuring billing accuracy.
Pre-Consumption
Before forwarding your request to the upstream AI provider, SoxAI estimates the token cost and holds that amount from your balance. This requires your balance to be positive before making requests.
If your balance is insufficient to cover the estimated cost:
- The request is rejected with a
402 Insufficient Balanceerror - No tokens are consumed
- You are redirected to top up
Settlement
When the upstream response is complete, SoxAI compares the actual token usage against the pre-consumed estimate:
| Actual vs. Estimate | Action |
|---|---|
| Actual < Pre-consumed | Difference is refunded to balance |
| Actual = Pre-consumed | No adjustment |
| Actual > Pre-consumed | Additional amount is deducted |
All settlement operations are atomic PostgreSQL transactions — there is no risk of double-charging or lost refunds.
Error Handling
If a request fails (network error, 5xx from upstream, timeout):
- The pre-consumed amount is fully refunded
- No charges apply for failed requests
- The error is logged for diagnostics
Viewing Balance and Usage
Console: Billing → Overview
The billing overview shows:
- Current balance
- Month-to-date spending
- Spending breakdown by model and team
- Recent transactions