api.services.ai.pricing

Model price catalog for the AI settings page, in USD per million tokens: Anthropic from the list prices used for cost estimates, OpenRouter from its public models endpoint (no key needed, cached).

Attributes

Functions

anthropic_models() → list[dict[str, Any]]

openrouter_models([get, now]) → list[dict[str, Any]]

Models with a known per-token price; the last good list on failure.

catalog() → dict[str, list[dict[str, Any]]]

Module Contents

api.services.ai.pricing.logger
api.services.ai.pricing.OPENROUTER_MODELS_URL = 'https://openrouter.ai/api/v1/models'
api.services.ai.pricing.CACHE_SECONDS = 21600
api.services.ai.pricing.RETRY_SECONDS = 600
api.services.ai.pricing.anthropic_models() → list[dict[str, Any]]
api.services.ai.pricing.openrouter_models(get: collections.abc.Callable[..., Any] = requests.get, now: collections.abc.Callable[[], float] = time.time) → list[dict[str, Any]]

Models with a known per-token price; the last good list on failure.

api.services.ai.pricing.catalog() → dict[str, list[dict[str, Any]]]