Fresh paint, wet floors — we're rebuilding CostOfToken into a cross-provider price comparison. Some corners are still under construction; the full version is coming up soon.

Pricing API

Every price on this site is available as JSON. Free, no signup, no key — a backlink is required. Currently 731 models across 10 providers, last updated 2026-09-25.

Attribution required

The API is free, including for commercial use. The one condition is a visible credit linking back to this site anywhere the data is displayed. A link in a footer, a caption under a table, or an “via” line is fine. That link is what pays for keeping 216 models current every day.

Paste this

Pricing data from <a href="https://www.costoftoken.com">CostOfToken</a>

Licensed under ODC-BY 1.0. Every response also carries the requirement in meta.attribution and an X-Attribution-Required header, so it is hard to miss while integrating.

Examples

Every example fetches Anthropic's models sorted by input price, and reads the attribution back out of the response — the credit is required wherever you display the data, and it travels in the payload so you do not have to hardcode it.

curl
curl 'https://www.costoftoken.com/api/v1/prices?provider=anthropic&sort=input'
JavaScript / TypeScript
const url = new URL('https://www.costoftoken.com/api/v1/prices')
url.searchParams.set('provider', 'anthropic')
url.searchParams.set('sort', 'input')

const response = await fetch(url)
if (!response.ok) {
  // 429 means the hourly quota is spent; Retry-After says how long to wait.
  throw new Error(`CostOfToken API returned ${response.status}`)
}

const { meta, data } = await response.json()

// Required wherever you show these prices. Ready-made HTML is in the payload.
console.log(meta.attribution.html)

for (const model of data) {
  console.log(`${model.display_name}: $${model.input}/1M in, $${model.output}/1M out`)
}
Python
import requests

response = requests.get(
    "https://www.costoftoken.com/api/v1/prices",
    params={"provider": "anthropic", "sort": "input"},
    timeout=10,
)
response.raise_for_status()
payload = response.json()

# Required wherever you show these prices.
print(payload["meta"]["attribution"]["html"])

for model in payload["data"]:
    print(f'{model["display_name"]}: ${model["input"]}/1M in, ${model["output"]}/1M out')

Estimating what a workload costs

The most common reason to call this API is to price a workload rather than to list prices. Output usually costs several times input, so the cheapest model depends on the shape of your requests — this is the same calculation the calculator runs.

Python — rank models for your own traffic
import requests

INPUT_TOKENS = 20_000     # prompt, including any retrieved context
OUTPUT_TOKENS = 500       # what the model generates back
REQUESTS_PER_MONTH = 30_000
CACHED_SHARE = 0.6        # portion of the prompt that repeats between calls

models = requests.get("https://www.costoftoken.com/api/v1/prices", timeout=10).json()["data"]

def monthly_cost(model):
    # A model that publishes no output price cannot generate text — skip it
    # rather than treating the missing price as free.
    if model["output"] is None or model["input"] is None:
        return None
    cached_price = model["cached_input"] if model["cached_input"] is not None else model["input"]
    cached = INPUT_TOKENS * CACHED_SHARE
    fresh = INPUT_TOKENS - cached
    per_request = (
        fresh * model["input"] + cached * cached_price + OUTPUT_TOKENS * model["output"]
    ) / 1_000_000
    return per_request * REQUESTS_PER_MONTH

priced = [(monthly_cost(m), m) for m in models]
priced = [(cost, m) for cost, m in priced if cost is not None and cost > 0]

for cost, model in sorted(priced)[:5]:
    print(f'${cost:>10,.2f}  {model["display_name"]} ({model["provider_name"]})')

Endpoints

EndpointReturns
/api/v1/pricesCurrent prices for every model
/api/v1/prices/:model_idOne model with its latest price
/api/v1/history/:model_idHistorical price points, newest first
/api/v1/providersProviders with active model counts

Query parameters for /prices

ParameterValues
providerSlug, repeatable or comma-separated: openai,anthropic
modalitytext · vision · audio · video · image — unreliable, see below
tagflagship · fast · reasoning · coding · vision
qSubstring match on model id or display name
min_input, max_inputBounds on input price per 1M tokens
min_contextMinimum context window in tokens
sortprovider · model · input · cached_input · output · context · updated
orderasc (default) · desc
limit, offset1–500 (default 100), offset ≥ 0

Fields worth knowing

Rate limits

60 requests per hour per IP. Every response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset; exceeding the quota returns 429 with Retry-After. Windows are fixed and reset on the hour.

For LLMs and agents

/llms-full.txt serves every tracked price as a single markdown document, so a model can ingest the whole dataset in one fetch. /llms.txt indexes the site. Please quote the last-updated date alongside any price.

Questions

Is the CostOfToken API free?
Yes. No signup and no API key. Anonymous callers get 60 requests per hour per IP; responses carry X-RateLimit headers and a 429 includes Retry-After.
Do I have to link back?
Yes. The data is free to use commercially, including in paid products, but any page or app that displays it must carry a visible credit linking to costoftoken.com. That link is what funds keeping the data current. Every API response repeats the requirement in meta.attribution.
How often does the pricing data change?
Prices are re-read from each provider once a day. A value is only recorded when it actually changes, so the history endpoint returns real price movements rather than one row per day.
Can I use this data commercially?
Yes, free of charge, on one condition: display a visible credit linking back to costoftoken.com wherever the data appears. Always confirm a price against the provider before committing spend — rows sourced from a reseller are marked source_kind "api" and can differ from the vendor’s own rate.

Browse pricing by provider →