pydantic/genai-prices

Calculate prices for calling LLM inference APIs.

What it solves

GenAI Prices provides a way to calculate the cost of calling LLM inference APIs. Because model providers often do not provide pricing information in a machine-readable format, it is difficult for developers to estimate or track the actual cost of their AI applications.

How it works

The project maintains a comprehensive database of pricing data for dozens of providers (such as OpenAI, Anthropic, and Google) and hundreds of models. It offers Python and JavaScript/TypeScript packages and CLIs to query this data and calculate costs based on model and provider IDs.

Who it’s for

Developers building AI applications who need to estimate, monitor, or compare the costs of using various LLM inference APIs.

Highlights

  • Broad Provider Support: Supports a wide range of providers including AWS Bedrock, Azure, Groq, and OpenRouter.
  • Complex Pricing Logic: Handles historic price changes, variable daily pricing (e.g., off-peak), and tiered pricing for large contexts (e.g., Gemini).
  • Flexible Access: Available as a Python package, a JS/TS package, and as downloadable JSON data files.
  • Accuracy Tools: Includes logic to maximize model matching and tools for identifying price discrepancies from other sources.