Package com.tnsai.llm.observability
Class InMemoryLLMPricingRegistry
java.lang.Object
com.tnsai.llm.observability.InMemoryLLMPricingRegistry
- All Implemented Interfaces:
LLMPricingRegistry
In-memory
LLMPricingRegistry populated programmatically via
InMemoryLLMPricingRegistry.Builder (issue #79). Default registry for tests and code-driven
configuration; a JSON-backed registry shipping vendor rate cards for
the 11 framework providers is a focused follow-up.
Rates are per-1K-tokens (the convention every major provider
publishes); the registry handles the × usage / 1000 math so
callers don't repeat it. Rounding: 6 decimal places via
RoundingMode.HALF_UP — sub-fractional-cent precision is the
minimum practical for sub-1K-token chats.
- Since:
- 0.5.0 (issue #79)
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionestimate(String provider, String model, TokenUsage usage) Compute a USD cost estimate for the givenusageunder the namedprovider+model.Stable version identifier of the pricing data — a date string, a content hash, whatever survives "what was the rate when this call was billed?"
-
Method Details
-
tableVersion
Description copied from interface:LLMPricingRegistryStable version identifier of the pricing data — a date string, a content hash, whatever survives "what was the rate when this call was billed?" audits. Embedded in everyCostEstimatethe registry produces so downstream cost-aggregation can detect rate-table drift.- Specified by:
tableVersionin interfaceLLMPricingRegistry
-
estimate
Description copied from interface:LLMPricingRegistryCompute a USD cost estimate for the givenusageunder the namedprovider+model. Implementations MUST return a non-nullCostEstimate; if the pair is unknown, return a zero estimate stamped withLLMPricingRegistry.tableVersion()so the caller still sees provenance.- Specified by:
estimatein interfaceLLMPricingRegistry
-
builder
-