Skip to main content

Module pricing

Module pricing 

Source
Expand description

Cached LiteLLM pricing on the redb pricing_cache table.

One row holds the most-recent fetch: the raw json plus its fetched_at. The usage scan prices from this cache (empty until the first background fetch lands); the fetch refreshes it about once a day.

Re-exportsยง

use std::time::SystemTime; ๐Ÿ”’
use anyhow::Context; ๐Ÿ”’
use redb::TableDefinition; ๐Ÿ”’
use serde::Deserialize; ๐Ÿ”’
use serde::Deserialize; ๐Ÿ”’
use serde::Serialize; ๐Ÿ”’
use serde::Serialize; ๐Ÿ”’
use super::Db; ๐Ÿ”’

Structsยง

CachedPricing
A fetched LiteLLM pricing file plus the instant it landed.

Constantsยง

KEY ๐Ÿ”’
The single row key; there is only ever one cached pricing snapshot.
PRICING_CACHE ๐Ÿ”’

Functionsยง

load
The cached pricing snapshot, or None when nothing has been fetched yet (or the row fails to decode).
store
Overwrite the cached pricing snapshot with entry.