Skip to content

BillingRecord ​

Usage and pricing snapshot for one provider request.

Description ​

Granularity is a single request: every completion or tool-calling round that reaches the provider appends at most one BillingRecord to the run's ledger. model, preset_name and rate are stored alongside the counts, so a record stays self-describing after presets or prices change.

Records are collected in a run-scoped SessionUsageProxy while the run is in flight, then copied into MemoryModel.billing at the end of the run. That list is the default persistence path; a BillingBackend is only needed to mirror the same data elsewhere.

AmritaCore does not compute currency amounts. Consumers derive money from rate and the token counts.

Fields ​

FieldTypeDefaultDescription
modelstr | NoneNoneModel name used for the request
preset_namestr | NoneNonePreset name the request was issued with
rateRateConfig | NoneNonePricing snapshot captured at request time
prompt_tokensint0Prompt tokens reported, cache included
completion_tokensint0Completion tokens reported
total_tokensint0Total tokens reported
cache_hitint | NoneNoneTokens read from cache
cache_creationint | NoneNoneTokens spent creating cache entries
session_idstr""Owning session id
stream_idstr""Owning run id
request_idstr | NoneNoneProvider request id
tsfloattime.time()Record timestamp

Reading Records ​

python
records = chat.data.billing
total = sum(r.total_tokens for r in records)
by_preset = {r.preset_name for r in records}

Next ​

RateConfig - the pricing snapshot, or BillingBackend - forwarding records to an external store.

Apache 2.0 License