Skip to main content

Overview

When using LLM APIs, tracking costs is essential for budgeting and optimization. Cost calculation is decoupled from usage tracking — you use a calculator to compute cost from usage and pricing data. This example demonstrates how to:
  1. Define pricing rates ($/1M tokens) with InferencePricing
  2. Calculate cost using FlatRateCostCalculator
  3. Compare costs across different models