Package com.tnsai.llm.observability
Interface LLMPricingRegistry
- All Known Implementing Classes:
InMemoryLLMPricingRegistry,JsonLLMPricingRegistry
public interface LLMPricingRegistry
SPI for converting
TokenUsage into a USD CostEstimate
(issue #79).
Default implementation is InMemoryLLMPricingRegistry, which
holds rates programmatically and is suitable for tests and code-driven
configuration. A JSON-loader implementation that ships rates for the
11 framework providers is a focused follow-up — this PR ships only
the SPI + the in-memory adapter so consumers can plug in custom
pricing (enterprise-negotiated rates, internal model registries) today.
- Since:
- 0.5.0 (issue #79)
-
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
-
estimate
Compute 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 withtableVersion()so the caller still sees provenance. -
tableVersion
String tableVersion()Stable 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.
-