Package org.mockserver.llm.cost
Class LlmPricing
java.lang.Object
org.mockserver.llm.cost.LlmPricing
Estimated cost calculation for LLM API usage.
A pure lookup over a pricing table keyed on (provider, model) with
input/output rates in USD per million tokens. Returns null for an
unknown model so callers can distinguish "free/known-zero" from "unpriceable".
Kept in sync with the dashboard pricing table
mockserver-ui/src/lib/llmPricing.ts — the prefixes, ordering, and
rates here mirror that file. When refreshing rates, update both.
Pricing source / freshness: rates are public provider list prices captured 2025-Q4. They WILL drift — treat any total as an estimate, not an invoice. There is no automated drift check. Sources: Anthropic (anthropic.com/pricing), OpenAI (openai.com/api/pricing), Gemini (ai.google.dev/pricing).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classInput/output list price in USD per million tokens. -
Method Summary
Modifier and TypeMethodDescriptionstatic DoubleestimateCostUsd(Provider provider, String model, long inputTokens, long outputTokens) Estimate the cost in USD for a provider, model, and token counts.static LlmPricing.PricingEntrygetPricing(Provider provider, String model) Look up pricing for a provider and model, ornullif unrecognised.
-
Method Details
-
getPricing
Look up pricing for a provider and model, ornullif unrecognised. -
estimateCostUsd
public static Double estimateCostUsd(Provider provider, String model, long inputTokens, long outputTokens) Estimate the cost in USD for a provider, model, and token counts.- Returns:
- the estimated cost in USD, or
nullif the model is unknown. Returns0.0for zero tokens on a known (priced) model.
-