Class JsonLLMPricingRegistry

java.lang.Object
com.tnsai.llm.observability.JsonLLMPricingRegistry
All Implemented Interfaces:
LLMPricingRegistry

public final class JsonLLMPricingRegistry extends Object implements LLMPricingRegistry
LLMPricingRegistry that loads rates from a classpath JSON file (issue #79).

Default rate card ships at /pricing/2026-05.json bundled in this module. Consumers wanting enterprise-negotiated rates can ship their own JSON and call fromClasspath(String) with their resource path. The JSON shape is:


 {
   "version": "2026-05",
   "providers": {
     "openai": {
       "gpt-4o": {
         "prompt_per_1k": 0.0025,
         "cached_per_1k": 0.00125,
         "completion_per_1k": 0.01,
         "reasoning_per_1k": null
       },
       ...
     },
     "ollama": { "*": { ... } }
   }
 }
 

The "*" model key acts as a catch-all for that provider — useful for self-hosted providers (Ollama, vLLM) where every model has the same operational cost (zero, in the local case).

Internally delegates to InMemoryLLMPricingRegistry: the JSON loader is a thin parser that wires rates into the in-memory adapter.

Since:
0.9.0 (issue #79)