How to calculate AI API cost for GPT, Claude, and Gemini

Enter input and output token counts to see per-request pricing — before you spend a cent on API calls.

OpenAI, Anthropic, and Google price their APIs per million tokens — and input tokens cost less than output tokens. The AI API Cost Calculator multiplies your token counts by the published rate for each model and shows input cost, output cost, and total.

Try it — enter tokens or count from text

How it works

  1. Select a model — GPT-4o, GPT-4o mini, Claude Sonnet, Gemini Pro, and others are pre-loaded with current per-million pricing.
  2. Enter token counts — type input and output tokens directly, or paste text and click "Count from text" to estimate input tokens.
  3. See the breakdown — input cost, output cost, and total update instantly. No submit button.

The math

Every model has two rates: price per million input tokens and price per million output tokens. The formula is:

total = (inputTokens / 1,000,000 × inputRate) + (outputTokens / 1,000,000 × outputRate)

Output is almost always more expensive because generating text requires more compute than reading it. GPT-4o's output rate is 4× its input rate; Claude Sonnet's is 5×.

Example

A request with 2,000 input tokens and 500 output tokens on GPT-4o mini costs roughly $0.0006 — less than a tenth of a cent. The same request on GPT-4o costs about $0.01. Scale that to 10,000 requests per day and the model choice matters.

Pricing changes

Provider rates shift. The calculator reflects published prices as of mid-2026. Always cross-check on the official pricing page before setting a budget.