LLM API Pricing Calculator - Calculate the cost of using an LLM

2 min read Original article ↗

The prices are per million tokens. The prices are rounded to the nearest 4 decimal places. We are not affiliated with any of the providers and the prices are not guaranteed to be accurate. These provider might update the pricing at any time without notice. I will try to keep the prices updated as much as possible.

I have pulled the data directly from the providers' websites. OpenAI, Anthropic, Google Gemini, Groq, Grok.

How am I calculating the tokens and cost?

Tokens are the basic units of text that LLMs process. They can be as short as one character or as long as one word. For example:

  • "Hello" = 1 token
  • "Hello world" = 2 tokens
  • "Hello, world!" = 3 tokens (including punctuation)

The cost calculation is straightforward:

  • Input Cost = (Input Tokens ÷ 1,000,000) × Input Price per Million Tokens
  • Output Cost = (Output Tokens ÷ 1,000,000) × Output Price per Million Tokens
  • Total Cost = Input Cost + Output Cost

For example, if you're using GPT-4 with 1,000 input tokens and 500 output tokens:

  • Input Cost = (1,000 ÷ 1,000,000) × $30 = $0.03
  • Output Cost = (500 ÷ 1,000,000) × $60 = $0.03
  • Total Cost = $0.06

For more detailed information about tokens, you can refer to OpenAI's token guide.

If you find any discrepancies, please DM me on X or Telegram.