api docs

Calculate from provider response

Convert LLM token usage into USD

Design philosophy

This API expects to receive the JSON (or JSONL) that you received from your call to the LLM. It will examine that and then reply with the cost in USD.

There are various JSON shapes used by various providers and models to report usage. This API does not require you to "normalize" them. That's our job. Just forward whatever you received. We'll figure it out.

It currently works with Anthropic, Google and OpenAI.

Some models have multiple snapshots or aliases. They are all charged at the same rates, so we collapse each family into a single model ID.

Example : gpt-4o-2024-11-20 gpt-4o-2024-08-06 gpt-4o-2024-05-13 are all collapsed to gpt-4o.

Input

Send us the JSON (or JSONL) that you received from your call

Alternatively you can craft your own JSON with the same structure as a response from an LLM API call, and send that to us.

Request example

Endpoint: POST https://api.tokenstodollars.io/calculate/from-provider-response/v1

Headers: X-API-KEY: your_api_key

Request body

{
  "provider": "openai",
  "model": "gpt-5.6-terra",
  "usage": {
    "prompt_tokens": 2620,
    "completion_tokens": 220,
    "total_tokens": 2840,
    "prompt_tokens_details": {
      "cached_tokens": 1792,
      "audio_tokens": 0
    }
  }
}

Response example

{
  "success": true,
  "cost_usd": 0.58424,
  "provenance": {
    "url": "https://developers.openai.com/api/docs/pricing.md",
    "last_scraped_at": "2026-07-31 12:54:59 UTC",
    "pricing_object_extracted_at": "2026-07-31 13:19:32 UTC"
  },
  "calculations_usd": [
    "233256 prompt tokens at $2.5/million = USD 0.58314.",
    "110 completion tokens at $10/million = USD 0.00110.",
    "Total all tokens = USD 0.58424."
  ]
}

Detailed notes per provider

These are collections of obscure notes about edge cases and things we've decided not to support.

If you are trying to do something with this service and it's not working, the reason may be buried in here.

OpenAI edge cases

Anthropic edge cases

Google edge cases

xAI edge cases