View Source LlmComposer.Cost.Fetchers.ModelsDev (llm_composer v0.19.2)

models.dev-specific pricing fetcher for OpenAI, Google, and Bedrock providers.

Fetches pricing information from the models.dev API dataset for OpenAI, Google, and Amazon Bedrock models. Uses 24-hour caching to minimize API calls and improve performance.

Supported Providers

  • :open_ai - OpenAI models (GPT series)
  • :open_ai_responses - OpenAI Responses API models (same pricing family as :open_ai)
  • :google - Google Gemini models
  • :bedrock - Amazon Bedrock models (indexed under "amazon-bedrock")

Implementation Notes

models.dev provides a single consolidated dataset (api.json) containing pricing for multiple providers. The entire dataset is cached to avoid repeated downloads.

For Bedrock, model lookup uses the following fallback chain:

  1. Exact model name (some region-prefixed variants are indexed, e.g. "eu.anthropic.claude-sonnet-4-6")
  2. Region prefix stripped (e.g. "eu.amazon.nova-lite-v1:0""amazon.nova-lite-v1:0")
  3. Date suffix stripped (e.g. "amazon.nova-lite-v1:0-2026-01-01""amazon.nova-lite-v1:0")

Summary

Functions

Link to this function

fetch_pricing(provider, model)

View Source
@spec fetch_pricing(atom(), String.t()) :: map() | nil