Sozdai LogoDocs
Getting Started/Billing

Billing Rules

Sozdai uses micro-unit accounting and a 'freeze-settle' transactional billing process, ensuring accurate account balances and transaction safety under high concurrency.

#1. Accounting Units (Micro-Units)

To prevent floating-point calculation errors, Sozdai stores all account balances and costs as **BigInt (64-bit integers)** in micro-units.
- Conversions: `1 Credit = 1,000,000 micro-units`.
- For example, `0.0015` Credits is stored as `1,500` micro-units (0.0015 × 1,000,000).

#2. 'Freeze & Settle' Flow

When a user triggers an API request (e.g. Chat or Media), the billing system performs the following transactional steps:

  • Pre-Freeze: The system locks a pre-authorized deposit (usually 0.1 credits) from the user balance. If the user's available balance is too low, the request is immediately rejected with a `402 Insufficient Balance` error.
  • Execution: The request is sent to the designated upstream channel.
  • Final Settlement: When the response is complete, the system computes the exact price based on actual tokens or calls, unlocks the frozen deposit, and deducts the final cost from the user balance.

Stream Billing Security

Even if the user disconnects or cancels an ongoing SSE stream, the gateway captures the abort signal and bills for the actual tokens generated up to that moment.

#3. Pricing Classes

Depending on the model, Sozdai applies different pricing categories:

  • Token-based: Used for LLMs. Input, output, cache-write, and cache-read tokens can have independent rates (check the individual model pages).
  • Per Call: Used for images, music, and certain video models. Billed per successful generation task.
  • Per Second: Used for high-end video models where pricing depends on output video length in seconds.

#4. Failures & Refunds

Sozdai guarantees consumer safety:

  • If a request fails due to network, upstream outage, or content policy violations, **the frozen deposit is fully refunded and the final charge is 0**.
  • For async media tasks, costs are only deducted when the status becomes `succeeded`. If it ends up `failed`, the hold is automatically released.