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 'https://www.costoftoken.com/api/v1/prices?provider=anthropic&sort=input'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`)
}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.
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
| Endpoint | Returns |
|---|---|
| /api/v1/prices | Current prices for every model |
| /api/v1/prices/:model_id | One model with its latest price |
| /api/v1/history/:model_id | Historical price points, newest first |
| /api/v1/providers | Providers with active model counts |
Query parameters for /prices
| Parameter | Values |
|---|---|
| provider | Slug, repeatable or comma-separated: openai,anthropic |
| modality | text · vision · audio · video · image — unreliable, see below |
| tag | flagship · fast · reasoning · coding · vision |
| q | Substring match on model id or display name |
| min_input, max_input | Bounds on input price per 1M tokens |
| min_context | Minimum context window in tokens |
| sort | provider · model · input · cached_input · output · context · updated |
| order | asc (default) · desc |
| limit, offset | 1–500 (default 100), offset ≥ 0 |
Fields worth knowing
- All prices are USD per 1,000,000 tokens on the standard tier. Batch, Flex and Priority tiers are excluded — they are not comparable across vendors.
0means genuinely free.nullmeans the provider publishes no such tier. They are different.source_kindisscrapefor a vendor's own page orapifor the OpenRouter catalogue — a reseller whose price can differ. Check it before treating a figure as authoritative.descriptionis prose captured from whoever published it, ornullwhen no source stated one. It is never generated here, so an absent description means nobody wrote one — not that the model is uninteresting.modalityis currently unreliable — most values were inferred from model names rather than declared by the vendor, so nothing on this site displays them. It is still served so the field does not vanish from under existing callers, but do not trust it.long_inputandlong_context_thresholddescribe the higher rate some models charge above a prompt-size threshold.
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.