Skip to main content

Module pricing

Module pricing 

Source
Expand description

Automatic pricing lookup from providers that expose exact, public per-token prices.

Two sources are supported:

  • OpenRouter: GET /api/v1/models carries exact per-token prompt, completion, input_cache_read and input_cache_write prices with no authentication.
  • AWS Bedrock: the public AWS Price List offers AmazonBedrock (Nova, Llama, Mistral, …) and AmazonBedrockFoundationModels (Anthropic Claude, Cohere, …) publish exact per-model input/output/cache-read/ cache-write prices per region. Both are fetched at startup and mapped to the configured model id.

Other providers either expose no public price API (OpenAI, Groq, xAI, DeepSeek, Google) or expose prices that cannot be mapped to a model exactly without heuristics (Azure Retail Prices).

Structs§

ModelPricing
Exact per-1M-token prices for a model.
PricingOutcome
Outcome of an automatic pricing pass.

Functions§

apply_auto_pricing
Applies automatic pricing to every endpoint.
apply_pricing
Fills unset pricing fields on ec from fetched pricing; explicit values win.
fetch_openrouter_pricing
Fetches exact OpenRouter pricing for model.
parse_openrouter_models
Parses an OpenRouter /api/v1/models response for model.