One BillingRecord per call, full snapshot
Every AI call on ToRun produces exactly one BillingRecord that captures the price at the moment of execution. Provider rates change every few weeks; storing the rate inline means a charge from three months ago can still be checked today.
The core pricing units
Each way a capability is billed has its own canonical pricing unit. These are the core ones:
- PerInputToken (text input)
- PerOutputToken (text output)
- PerCachedInputToken (prompt cache hit)
- PerImage (image generation)
- PerSecondAudio (TTS / STT)
- PerSecondVideo (video generation)
- PerCharacterTts (legacy text-to-speech billing)
- PerSearchCall (web search tool)
- PerComputeSecond (sandbox execution)
- PerEmbedding (vector embedding)
- PerMinuteRealtime (realtime voice / video)
- PerRerankPair (reranking)
Why per-million instead of per-1k
All token-priced models now publish their rates per million tokens. We follow that convention so the math is honest at the scale modern users operate at. The legacy "Per1k" field was removed from AiModel and replaced by AiModelPricing rows that carry a PricingUnit enum.
What this means for you
You can audit every charge. You can switch providers without losing historical pricing context. That is the foundation we are building everything else on.