model-prices
Per-token LLM prices, today's or as they were at any point in time. Pricing past usage at today's rates misstates it whenever a price changed: GPT-5.6 Sol cost $5/$30 per million input/output tokens until August 21, 2026, and $4/$20 for the three months after. This package answers "what did this request cost at per-token prices when it ran?" For usage billed per token, that is what it cost; for usage under a subscription, it is what the same tokens would have cost per token, to compare with the plan's monthly price, which plan() gives.
Status: work in progress. Versions before 0.1 may change the data format and API without notice.
import model_prices
model_prices.cost(
"gpt-5.6-sol",
input_tokens=12_000, # uncached input only
cache_read_tokens=180_000,
output_tokens=900,
at="2026-08-20T14:00:00Z",
)
model_prices.rates("claude-opus-5-5") # current rates, per million tokens
model-prices rate gpt-5.6-sol --at 2026-08-20
model-prices rate "Gemini 3.5 Flash (High)" --json
The model-prices website lists every model's current price, its dated price history with sources, whether it matches the provider's own pricing page, and a calculator that gives the same result as model_prices.cost() to the last digit.
Install
Requires Python 3.11 or newer.
uv add model-prices
Keeping prices current
Each release bundles the price data from when it was built. Price data is also published on its own, so new prices reach an installed release without upgrading it:
status = model_prices.refresh() # downloads when the cached copy is over a day old
status.basis # the pricing basis now in use
status.published_at # when that data was last confirmed current
Prices change only when refresh() is called; until then, the bundled data applies. refresh(max_age=...) sets how old a downloaded copy may get before it downloads again, and refresh(max_age=None) never downloads and uses the newest copy already downloaded or bundled. When a download fails, refresh() keeps the newest local copy, sets status.error, and warns, so a caller can keep working and decide how stale is too stale from published_at. model-prices refresh downloads from the command line, and model-prices rate uses the newest local copy. Downloads are cached in ~/.cache/model-prices, %LOCALAPPDATA%\model-prices on Windows, or the directory in MODEL_PRICES_CACHE.
Published data is a single file, the snapshot, holding every model's final price timeline plus the aliases, schedules, and plans. It is served from the repository's data branch: v2/latest.json names the current snapshot by its SHA-256 hash, and v2/<sha256>.json keeps every snapshot ever published, so the data behind any recorded basis can be fetched again. refresh() checks each download's hash and schema version before using it. The v2 is the schema version. A release ignores rate fields it does not know, so a later snapshot of its schema can add prices, such as for cache modes or modalities, and the release keeps pricing everything else as before. Releases up to 0.0.5 read schema 1, which raises on an unknown field, so v1/ keeps being published with the same prices and only the fields those releases know.
Where the prices come from
Prices come from the git history of models.dev, an open catalog of model metadata that records each model's price in one TOML file per provider. Every commit on its main branch that changed a tracked model's price becomes an entry effective from that commit's time. Model files in models.dev's schema 2, which every tracked provider has used since 2026-10-21, are read through the same translation models.dev applies to publish them in schema 1, so their prices continue the earlier history; a file in a schema model-prices does not know stops the build instead of being skipped. The tracked providers are the labs that sell their own models through an API: AI21 Labs, Alibaba, Amazon Nova (its free developer API and its paid models on Amazon Bedrock, under ids such as us.amazon.nova-pro-v1:0), Ant Group's Bailing, Anthropic, Arcee, ByteDance's Volcengine, Cohere, DeepSeek, Google, Inception, Meituan's LongCat, Meta, MiniMax, Mistral, Moonshot AI, OpenAI, Perplexity, Poolside, Sakana AI, SenseTime's SenseNova, StepFun, Tencent, Thinking Machines, Upstage, Xiaomi, xAI, and Z.ai. Where models.dev lists a lab's China and global endpoints separately, the global one is tracked. Some models.dev entries list a price of zero, such as free previews; only providers with an official price check have those prices confirmed. Thinking Machines' Inkling is priced at its Tinker sampling price, which models.dev records.
Models that models.dev does not list are read from their provider's own pricing pages: Cursor's Composer models, from Cursor's model docs, with their fast variants as the fast mode, and Cognition's SWE models, from the price list on Devin's models page, under the model ids Devin reports, such as swe-2-medium. Cognition's prices are the Enterprise plan's, which pays per token; self-serve plans include some of these models at no charge for a period. Devin listed SWE-1.7 at no charge until its 2026-09-12 price list, so earlier SWE-1.7 usage costs nothing. ByteDance's Seed models on BytePlus ModelArk, ByteDance's international platform, are priced in US dollars from its standard online inference table, under ids such as seed-2-0-pro-260328, with their long-context tiers; models.dev lists only Volcengine, ByteDance's China platform, whose yuan prices it converts to dollars. BytePlus's Seed 1.6, Seed 1.6 Flash, and Seed 1.8 histories start at the first archived copy of its price table, on 2026-01-16, which names them by display name, such as ByteDance-Seed-1.8; its Seed 2.0 models start at the 2026-04-26 copy. The pricing pages that model-prices check reads are observed the same way for each provider's own models that models.dev lacks, such as Alibaba's dated Qwen snapshots, OpenAI's legacy GPT-3.5 and GPT-4 models, and StepFun's audio models. Alibaba's own models take their cache prices from the rules on its context cache page: a cache read costs 20% of input on models that list implicit caching, which needs no setup, and 10% on models that list only explicit caching, and a cache write costs 125% of input on models that list explicit caching. A model with both kinds of caching gives the 10% explicit hit price as cache_read_explicit. Corrections apply the same rules from 2026-10-09 to the Qwen models that models.dev lists without them, such as qwen-plus, qwen3-max, and qwen-flash. Models a page resells from other labs, such as Alibaba's DeepSeek, GLM, and Kimi models, are left out. Google's pricing page names each section's API ids under its heading, and prices tokens by modality; as in models.dev, a model's price is its text price, except that an image or video generation model's output price is that of the images or video it generates, and a section without a text price, such as a speech model's audio output or a transcription model's audio input, gives its one price. Gemini 2.5 Flash Image's output is priced per image only, so it is not compared. Each modality's own prices are compared as well, as the prices by modality section describes. A daily run records a new entry in data/observed.json whenever a page's price differs from the last one recorded, dated by the run that first saw it, and fails when a page's layout changes. Once models.dev lists an observed model, its history takes over from its first entry. The histories of models read from checked pricing pages start at the earliest archived copy of the page that shows the same prices, back to 2026-01-16 for most of Alibaba's, 2026-04-01 for OpenAI's legacy models, and 2026-06-09 for MiniMax-M2.1-highspeed; Claude Mythos 5.1's starts at its 2026-09-01 launch. Models whose pages have no readable archived copy, such as StepFun's, Z.ai's, and Inception's, start at their first daily run. mistral-medium-3 named Mistral Medium 3 at $0.4/$2 until Mistral retired that model on 2026-08-31, and has named Mistral Medium 3.5 since. Composer 2.5's history starts at the first archived copy of its rate table, on 2026-08-23, and Cognition's at the first archived copy of Devin's price list, on 2026-07-30.
The inputs live in data/: prices.json holds the models.dev history, and the TOML files beside it adjust it. model-prices compile combines them into the snapshot that the package reads, applying every rule in this section once, so a client only looks prices up by time.
models.dev sometimes records a change days after the provider made it, or lists a wrong price for a while. corrections.toml overrides those periods, and every correction cites its source. research_corrections.toml adds corrections generated from agent research into every recorded change, each verified against quotes from its sources (see research/README.md); hand corrections take precedence. A correction gives standard rates, and a mode keeps its models.dev ratio to them unless the correction states that mode's prices under modes. A correction without an end date names the models.dev values it replaces and stops applying as soon as models.dev records anything else, so it cannot outlive a later fix or price change.
Rates.valid_from_basis says how a start date was found: models.dev commit dates usually lag the provider's real change by days, documented dates come from a correction's cited source, first observed dates are when model-prices first read the price on the provider's page, at most a day after a change, and scheduled dates are changes a provider announced ahead, which models.dev records as a multiplier from a date, such as Gemini 4 Argon's prices doubling on 2026-12-01. A scheduled change takes effect at 00:00 UTC on its date, and enters the history only if models.dev's file still announces it at its last commit before that date, so a change models.dev drops or moves first never applies. The history can therefore hold prices that start in the future, which rates() applies from their date; code that reads a snapshot directly should look prices up by time rather than take a timeline's last entry. model-prices check compares Google's announced prices, such as "$4.00 starting December 1, 2026", with the scheduled entries before they take effect.
Usage from before a model's first recorded price is priced at that first price, because models.dev often adds a model after its launch. Rates.valid_from is then later than the requested time, which a caller can check to reject implausible times, such as a zero timestamp. Usage after data_as_of(), the date of the models.dev commit the data was built from, assumes no price changed since.
Pass the time the provider billed the request as at. Providers do not document whether a request that spans a peak boundary bills at its start or its end; agent harnesses usually report completion times, which is a reasonable choice.
Each entry keeps input, output, cache read, and cache write rates, long-context tiers, and alternate modes such as fast mode. Every service tier models.dev prices is a mode named after the tier, the name the provider's API takes: flex and priority at OpenAI, Google, Amazon Bedrock, xAI, and MiniMax, and ultrafast at OpenAI, with long-prompt prices scaled like the others. A mode a model declares for a tier under another name keeps that name too, so OpenAI's fast and priority give the same prices. model-prices check compares OpenAI's Flex, Fast, and Ultrafast tables and Google's Flex and Priority sections with these modes. A tier a provider lists but models.dev does not price, such as Google's flex and priority tiers for its image models, has no mode. The thinking mode prices a request made with thinking on: Alibaba bills the output of its hybrid Qwen models at a separate thinking price, often above the non-thinking one, such as $4 against $1.2 per million output tokens for qwen-plus. Other models bill thinking as output, so mode="thinking" gives their standard rates. cache_write_tokens are five-minute cache writes; pass one-hour cache writes as cache_write_1h_tokens. cache_writes.toml records the longer-lived write price as a multiple of input, which model-prices check compares with each provider's pricing page: twice the input price for one-hour writes at Anthropic and Moonshot AI, and 2.5 times for OpenAI's 12-hour writes, which cache_write_1h_tokens also carries. OpenAI's 30-minute writes are its cache writes. Other providers' longer-lived writes are priced as cache writes. model-prices check also compares these multiples with the cache write prices by lifetime that models.dev records, such as write = { "5m" = 6.25, "1h" = 10 } for Claude Opus 4.8. Alibaba bills a cache hit at 20% of input when it cached the prefix implicitly, which needs no setup, and at 10% when the request marked the prefix for caching (context cache), so Rates.cache_read_explicit gives the explicit hit price where it differs from cache_read, such as $0.04 against $0.08 for qwen-plus. Pass those hits as cache_read_explicit_tokens; a caller can tell them apart, since it placed the markers and only explicit caching reports cache_creation_input_tokens. Without an explicit price, explicit hits cost cache_read. A tier applies when one request's whole prompt, meaning uncached input plus cache reads and writes, exceeds the tier size; explicit cache hits count toward it too. A missing cache price falls back to the input price.
Prices by modality
Some models price audio, image, or video tokens apart from text, such as gpt-realtime-1.5, which charges $32 per million audio input tokens against $4 for text, and Gemini 3.1 Flash Image, which charges $3 for text and thinking output and $60 for the images it generates. For those models Rates.modalities lists every modality the provider prices, text included, as ModalityRates with the input, output, and cached input prices the provider states, and Rates.modality(name) finds one. The plain input, output, and cache_read prices stay the price of a token given without a modality: models.dev's text price, which for an image or video generation model's output is the price of what it generates, so callers that do not split tokens by modality keep the costs they had.
Pass modality_tokens to cost() or breakdown() to price each modality's tokens at its own price:
model_prices.cost(
"gpt-realtime-1.5",
modality_tokens={"text": {"input": 800, "cache_read": 100, "output": 200},
"audio": {"input": 2500, "cache_read": 1000, "output": 2500}},
)
It takes every input, cached input, and output token of the request, by modality, in place of input_tokens, cache_read_tokens, and output_tokens; passing both raises ValueError, as does an unknown modality or a negative count. Each token is counted once, so a modality's input excludes its cached tokens. Cache writes and explicit cache hits, which no provider prices by modality, are passed beside it. A price a modality does not state is, for cached tokens, that modality's input price when it states one, and otherwise the price of a token without a modality; document, which Gemini reports for PDF pages, costs the image price, as Google bills it. Modality tokens count toward long-context tiers. The providers' usage reports map as follows:
- Gemini's
usageMetadata: a modality's input is itspromptTokensDetailscount plus itstoolUsePromptTokensDetailscount minus itscacheTokensDetailscount, its cache read is itscacheTokensDetailscount, and its output is itscandidatesTokensDetailscount;thoughtsTokenCountadds to text output. - OpenAI Realtime: a modality's input is
input_token_details.<modality>_tokensminusinput_token_details.cached_tokens_details.<modality>_tokens, its cache read is the latter, and its output isoutput_token_details.<modality>_tokens. - OpenAI Chat Completions: audio and image input are
prompt_tokens_details.audio_tokensandimage_tokens; text cache read iscached_tokens, which has no modality; cache writes arecache_write_tokens, passed ascache_write_tokens; text input isprompt_tokensminus the audio, image, cached, and cache-write counts. Audio output iscompletion_tokens_details.audio_tokens, and text output iscompletion_tokensminus it, which keeps reasoning tokens in text. - OpenAI's Images API and the Responses API's image generation tool: input is
input_tokens_details.text_tokensandimage_tokens, less their cached counts where reported, and output isoutput_tokens_details.image_tokensandtext_tokens, or all ofoutput_tokensas image when the details are absent. Other Responses usage has no modality split, so it is priced with plain counts.
The prices come from models.dev's audio, image, and video costs, and before models.dev's schema 2 from its input_audio and output_audio fields. That older format had no cached audio price, so the first cached audio price a file gives applies back to its earlier records while the audio input price is unchanged. model-prices check compares each modality price on Google's and OpenAI's pricing pages with the price cost() charges it, and corrections give the text output prices of Google's image and video models and the modality prices models.dev omits. A model that has long-context tiers as well as modality prices is priced without its modality prices, and the check reports it until both can be priced together. Prices per image, per second, or per minute, such as Alibaba's image models and gpt-4o-mini-tts, whose speech endpoint reports no token usage, are not priced.
Tool fees
Web search is billed per call beside tokens. Rates.tools gives each tool's price per 1,000 billable calls, and cost() and breakdown() take tool_calls, such as {"web_search": 3}, whose cost CostBreakdown.tools reports and total includes; a call that passes no tool calls costs what it did. A tool name names one billing unit, so a count means the same on every model: web_search is a search or a search tool call, web_search_prompt a Google grounded prompt, web_search_preview an OpenAI preview search call, and web_search_fast a Perplexity fast search. A count for a tool the model does not price raises ValueError, and a zero count is ignored, so a caller can pass every count its usage report gives. No mode, batch discount, schedule, or region scales a tool fee, and account-wide free allowances, such as Google's 5,000 searches a month, are not applied.
| Provider | Tool | Price per 1,000 | Count from the usage report |
|---|---|---|---|
| OpenAI | web_search |
$10 | web_search_call output items |
| OpenAI | web_search_preview |
$10 on reasoning models, $25 on others | web_search_call output items; the preview's search content tokens are free on non-reasoning models |
| Anthropic | web_search |
$10 | usage.server_tool_use.web_search_requests |
| Google Gemini 3 and later | web_search |
$14 | groundingMetadata.webSearchQueries, one per query |
| Google Gemini 2.5 | web_search_prompt |
$35 | one per response with grounding metadata |
| xAI | web_search |
$5 | server_side_tool_usage web and image search, not the free image viewing |
| Alibaba (Singapore) | web_search |
$10 | usage.x_tools.search.count, which also counts searches that returned nothing, so it can exceed the billed count |
| Perplexity | web_search, web_search_fast |
$2.50, $1.00 | usage.tool_calls_details.search_web.invocation, which does not say which kind ran; an effort level may set fast search |
The fees come from models.dev's web search price, from corrections where it is wrong, such as Perplexity's Agent API fee and Gemini 2.5's per-prompt unit, and from data/tools.toml for fees models.dev lacks, such as OpenAI's preview search and Perplexity's fast search. A model's first recorded fee also prices its earlier usage, since models.dev had no field for tool fees before its schema 2 files. model-prices check compares each fee with OpenAI's tools table, Anthropic's and xAI's pricing pages, Google's grounding rows, and Perplexity's and Alibaba's web search pages, and lists fees no page states, such as Xiaomi's, as unchecked.
Prices by region
Some providers charge more for a request served in a chosen region: Anthropic charges 1.1 times for US-only inference on Claude 4.6 and later, and xAI 1.1 times on its US regional endpoint (Anthropic, xAI). Rates.regions lists each region a model prices with its factor on every token price, as models.dev records them, such as (("us", 1.1),). Pass region to rates() or cost() to price a request served there: a region the model lists multiplies every token price by its factor, after any time-of-day rule and with any mode or batch discount, and sets Rates.region; a region the model does not list leaves the prices as they are. models.dev records these factors from its schema 2 files, so a model's regional prices start on 2026-10-19 or later, when its file first gave them.
OpenAI charges a 10% uplift on its regional processing endpoints, such as eu.api.openai.com, for models released on or after 2026-03-05, which models.dev does not record. model-prices reads it from OpenAI's own pages, so no list needs keeping: the factor and the cutoff from the pricing page's statement of the rule; the regions that process each model from the data residency table in the Your data guide, where only us, eu, and ae process requests and some models are processed in fewer; and each model's side of the cutoff from a dated snapshot id, its model page stating the uplift, its first release in the API changelog, or a knowledge cutoff after the cutoff. A model with none of that evidence has no uplift. model-prices observe records the factors in data/observed_regions.json, each change dated by the first run that read it, and model-prices check compares them with OpenAI's pages and fails when a model's evidence points both ways.
Time-of-day pricing
The batch mode prices a request sent through a provider's Batch API. batch.toml records each provider's batch discount as a multiple of its standard prices, from the date it began, for the models it covers: half price at Anthropic, OpenAI, and Google, and 20% off seven Grok models at xAI. Google charges cache reads in a batch at the standard price for its Gemini 2.5, Gemini 3 Flash, and Gemini 3.1 Pro models, and halves them for newer ones. model-prices check compares the resulting prices with the batch tables on Anthropic's, OpenAI's, and Google's pricing pages, which show some prices rounded to the cent, such as $0.13 for $0.125. Mistral also halves batch prices, but its page shows which models qualify only in the browser, so Mistral has no batch mode. rates(model, mode="batch") returns None for a model or time without a batch discount.
Some providers price by time of day. schedules.toml records each version of a provider's rules with the dates it applied: either peak windows that multiply the recorded rate, or off-peak windows that discount it for listed models. Rates.period says which applied: "peak" or "off_peak", "standard" outside a discount window, or None when no time-of-day rule applies.
Holiday calendars record the last date they cover, and model-prices check fails 45 days before that date so the next year's holidays are added in time. DeepSeek is the one lab with such pricing for its own API so far. From 16:30 UTC on February 26, 2025 until 16:00 UTC on September 5, 2025, it took 50% off DeepSeek-V3 (deepseek-chat) and 75% off DeepSeek-R1 (deepseek-reasoner) from 16:30 to 00:30 UTC daily. Since 16:00 UTC on August 16, 2026, its peak hours have been 01:00-04:00 and 06:00-10:00 UTC on weekdays other than Chinese public holidays, at twice the off-peak rate. The pricing page added the weekday and holiday exceptions in late August and mid-September without an announcement; model-prices applies the current rule from the start of peak pricing. DeepSeek pricing history records the evidence for each 2026 date. DeepSeek decides the period by when a request completes, so pass the completion time as at where it is known. Alibaba also follows such a rule for DeepSeek models it resells: since 2026-08-17 00:00 Beijing time, it has sold DeepSeek-V4-Flash-0731 at half price outside its busy hours of 00:00-14:00 UTC, every day, and it prices DeepSeek-V4-Pro-0813, DeepSeek-V4.1-Flash-1017, and deepseek-v4.1-flash the same way.
model-prices check compares the schedule in effect with the time-of-day multipliers models.dev records, which data/prices.json keeps under rules as models.dev's current files give them, and fails when a model's windows, days, holidays, or factor differ, or when either side has a rule the other lacks. schedules.toml stays the source, since it keeps the dates of earlier rules and an exact holiday calendar, which models.dev keeps only in its git history.
Official price checks
model-prices check fetches each supported provider's official pricing page, reads it with a parser written for that page's table layout, and compares every price with the rate model-prices uses today. It covers AI21 Labs, Alibaba, Amazon Bedrock's Nova models, Anthropic, Arcee, Cohere, DeepSeek, Google, Inception, LongCat, Meta, MiniMax, Mistral, Moonshot AI, OpenAI, Perplexity, Sakana AI, StepFun, Tencent, Thinking Machines, Upstage, Volcengine, xAI, Xiaomi, and Z.ai. LongCat's pages give a limited-time discount, which is checked as the price charged, and Upstage's page dates each promotional price window, which the check applies on its dates. Bedrock's pricing page fills its tables from AWS's published price data; its US East (N. Virginia) prices are checked for the unprefixed and us. ids under geographic cross-region and in-region inference, and for the global. ids under global cross-region inference, which costs less for Nova 2 Lite. Mistral's prices are read from its API pricing page, which names models for display, and each model's id from its docs page, which lists every API name of the model; a sale price is checked as the price charged. Alibaba's page is read for its Singapore (international) deployment, which models.dev's Alibaba prices describe. Its cache prices come from the rules on its context cache page, applied to the models that page lists for each caching mode: 20% of input for implicit hits, 10% for explicit hits, and 125% for explicit cache writes, except for the models the page names as exceptions. Those rules are compared only for Alibaba's own Qwen models, because for the models it resells Alibaba's pages disagree with them, such as Qwen Cloud's $0.26 cache read for glm-5.1, 18.57% of input. A price labeled as a limited-time discount, such as qwen3.7-plus's 20% off since its 2026-06-01 release, is checked as the discounted price, so the check fails when the discount ends; Alibaba's night and daytime discounts, which its Global and China deployments offer, are not compared. Tencent's TokenHub and ByteDance's Volcengine price in yuan, which models.dev converts to dollars. Their yuan prices are compared at the rate models.dev uses for each, 6.737012 yuan to the dollar for Volcengine and $0.834 for 6 yuan for Tencent, within 1%, so a changed official price fails the check and models.dev's rounding does not. Volcengine's page names model families, such as doubao-seed-2.0-pro, which reach models.dev's dated ids, such as doubao-seed-2-0-pro-260215; Tencent's Guangzhou (China) prices are compared, which models.dev converts. Each price is reported as:
ok: models.dev and the official page agree.corrected: models.dev differs, but a correction incorrections.tomlorresearch_corrections.tomlsupplies the official price.mismatch: model-prices differs from the official page. The command exits with status 1.untracked: the page lists a model that models.dev does not price.error: the page could not be fetched or no longer matches its parser. The other providers are still checked, and the command exits with status 1.
Page model names must match models.dev ids exactly, with no suffix removal, so a dated model is never compared with a different undated one. A page is compared only for its own provider's models: Alibaba's page also lists the prices it resells DeepSeek and Kimi models at, which are not DeepSeek's or Moonshot AI's prices. For DeepSeek, peak and off-peak prices are checked at the next hours the schedule classifies as each, and the peak-hour rule on both the English and Chinese pricing pages must match the wording recorded in schedules.toml, so a change to the hours, multiplier, or exceptions fails the check. Google's dated future prices are read for the check date. A page that yields no prices fails the check, because its format has changed.
model-prices check --genai-prices also scores Pydantic's genai-prices against the same official prices, reading its data.json from GitHub, or from a file or checkout given as --genai-prices PATH. It lists each price genai-prices gets wrong and ends with how many official prices each source lists correctly, wrongly, or not at all. Its disagreements never change the exit status. genai-prices is read by exact model id only: it also matches names by prefix, which would give a model it lacks, such as Claude Opus 5.5, an older model's prices. Z.ai is not compared, because genai-prices' Zhipu entry is the mainland China API. On 2026-10-01, models.dev listed 342 official prices correctly and 7 wrongly; genai-prices listed 173 correctly and 40 wrongly, almost all from missing price cuts such as GPT-5.6's.
Not modeled
model-prices prices standard synchronous requests, batch requests through the batch mode, and service tiers through modes. It does not model storage charges for cached context, or tool fees other than web search. Modes listed by models.dev, such as fast mode, are available through mode. While a correction applies, a mode's price is the corrected price scaled by the mode's ratio to models.dev's standard price at that time, since corrections record standard prices only.
Perplexity ended Sonar Chat Completions on 2026-09-27, whose models added a per-request fee that depended on search context size, and Sonar Deep Research also billed citation tokens, reasoning tokens, and search queries; model-prices prices their input and output tokens. Sonar is now priced from Perplexity's Agent API, whose web search fee the tool fees section describes; its other tool fees are not modeled.
Where a model has no cache-write price, cache writes are priced as input. That matches providers whose caching is automatic and bills the first, cache-filling request as normal input, such as Google's implicit caching, DeepSeek, xAI, and Z.ai. Providers that charge more for writing a cache list a cache-write price in models.dev.
Long-context tiers apply when a request's prompt exceeds the tier size. Providers word the boundary differently, such as Google's "> 200k" and xAI's "≥ 200k", so a prompt of exactly the tier size may price one tier off.
Rates.breakdown() returns a request's cost by token type and the tier it reached, for callers that report either.
Model names
resolve() maps the names that logs and agent harnesses use to models.dev ids. It matches ids regardless of case, such as minimax-m2.7 for MiniMax-M2.7, and normalizes display names such as Gemini 3.5 Flash (High) and dotted Claude versions such as claude-sonnet-4.5. It reads a provider/ prefix or the provider argument as a hint, and when the full name is unknown it removes context markers such as [1m], the -build suffix that xAI's subscription endpoint adds to Grok versions such as grok-4.6-build, effort suffixes such as -high, and date suffixes such as -20251001 or -2026-04-23. Rates.removed_suffix records any text removed this way, and resolve_details() returns it, so a caller can tell when a price belongs to a related name: -max is both an effort level and part of some model names, such as qwen3.8-max. A model is looked up at its own lab before other labs that also serve it. A lab model name resolves to the first-party API id that serves it, using models.dev's base_model links and preferring ids that are not deprecated: DeepSeek serves deepseek-v4.1-flash as deepseek-flash, so that name gets deepseek-flash's price. aliases.toml holds the few names that need an explicit mapping. Unknown models return None rather than a guessed price.
Aliases are part of the published data, while the normalization rules above are code. A name that resolves wrongly or not at all is fixed with an alias where possible, so the fix reaches every installed release on its next refresh(). A normalization change covers a whole class of names, such as the -build suffix, and reaches only new releases; older releases keep resolving names as before, so a name they could not resolve still returns None.
Current prices for past requests
rates() and cost() take prices_at to price a request from a different date's price list. The time-of-day rule in force at at, the time the request ran, still applies: a request made in a 2025 DeepSeek discount hour keeps its discount on today's prices. Pricing every past request with prices_at set to today compares usage across weeks without price changes appearing as usage changes.
Prices over a span
rates_between(model, start, end) returns each distinct rate in effect over a span with the time it begins. Use it for usage known only to fall within a span, such as a run with a start and finish but no per-request times: a single entry means one price covered the whole span. It finds changes from price history, corrections, and time-of-day schedules exactly, including peak windows and holidays. Rates.price_key() compares prices without provenance, so a correction and the models.dev entry that later records the same prices compare equal.
Subscription plans
plan(provider, plan_id, at=None) returns a subscription plan's monthly price from plans.toml, keyed by the plan name each lab's usage tools report, such as max_20x for Claude or lite for the GLM Coding Plan. A plan sold in several price tiers gets one entry per tier, with the price in its id and name, such as ultra_200 for Google AI Ultra $200 or pro_500 for ChatGPT Pro $500. When a usage tool reports only the untiered name, that name has no entry, except that ChatGPT's pro keeps its original $200 price.
Some models are sold with no per-token price: Meta includes Muse Wonder Full only in its Muse Code subscriptions, which count usage in prompts. rates() and cost() return None for them. To compare such usage with other models at per-token prices, pass estimate=True, which prices the model at the rates of a stand-in that data/estimates.toml names, with its reason and sources, and sets Rates.estimated_from to the stand-in, such as meta/muse-wonder-1.0, so a caller can label the figure as an estimate. The table is part of the snapshot, so a change to it changes pricing_basis(). model-prices rate MODEL --estimate does the same from the command line.
Recording what was used
pricing_basis() returns an identifier such as model-prices-0.0.1+models.dev@e2bf2e470a1b+synced@2026-09-30+data@3f1c09a2b7de, naming the package version, the models.dev commit its data came from and that commit's date, and the start of the SHA-256 hash of the snapshot in use, so any change to prices, corrections, schedules, or aliases changes it. Store it next to computed costs.
Updating prices
A daily workflow records observed prices with model-prices observe, which goes straight to main because the page is the source, then clones models.dev and rebuilds data/prices.json with model-prices update, which also compiles the snapshot. Each provider whose history changed then runs its official price check. A provider that passes goes straight to main. A provider without an official page to check against, such as Poolside, or Ant Group, whose yuan price list no longer includes the Ling-1T and Ring-1T models models.dev prices, publishes models.dev's prices as they are. A provider that fails its check is held at its current history and goes to the update-prices pull request instead, and the workflow fails. Fix a failure with a correction, or with a models.dev pull request when models.dev is wrong. Before merging the pull request, check each changed model's effective date against the provider's announcement and add a correction when models.dev recorded the change late. The workflow publishes the snapshot to the data branch after every run and after every push that changes the data, such as a merged correction. deploy-site.yml then rebuilds the website with tools/build_site.py, which writes its pages from the bundled snapshot and the official-page check, and Zola, and publishes it as a Cloudflare Worker serving model-prices.com, configured in wrangler.jsonc. The site's calculator, site/static/model-prices.js, reproduces the package's pricing with the same floating-point operations in the same order, and tests/test_site.py checks that it gives identical results on 5,000 requests. Between daily runs, tools/watch_models_dev.py starts the workflow when models.dev changes a tracked provider: run every minute from a timer, it reads the head of models.dev's default branch with git ls-remote, and when the head has moved it compares the tree hashes of the tracked providers' folders, one GitHub API request. models.dev merges catalog syncs for other providers many times an hour, which start nothing. It also reports each failed workflow run once, through Panetone, to the agent session named model-prices, with the run's link and its failed check lines; a failure whose only errors are fetch timeouts is reported only when the run before it also failed.
Prices that go straight to main are dated by their models.dev commit. A correction for a late date arrives in a later snapshot; costs already computed keep the basis that priced them.
To rebuild locally, from the repository root:
git clone https://github.com/sst/models.dev.git /tmp/models.dev
uv run --locked model-prices update /tmp/models.dev
After editing a file in data/, run uv run --locked model-prices compile. A test fails when the bundled snapshot does not match its inputs.
Development
uv run --locked python -m unittest discover -s tests
License
The code and the corrections are MIT licensed. data/prices.json and the snapshot compiled from it are derived from models.dev, whose MIT license is in data/LICENSE.models.dev. The test fixture tests/fixtures/genai-prices.json is an excerpt of genai-prices, whose MIT license is in tests/fixtures/LICENSE.genai-prices.
Metadata
Release files for model-prices 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| model_prices-0.0.9.tar.gz | 231.6 kB | Without provenance | Details for model_prices-0.0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| model_prices-0.0.9-py3-none-any.whl | Python 3 | none | any | Details for model_prices-0.0.9-py3-none-any.whl |
Total release size: 359.7 kB
Release files / model_prices-0.0.9.tar.gz
| Download URL | model_prices-0.0.9.tar.gz |
|---|---|
| Size | 231.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b3dee9eedce467ca384395f1af5052054d632d7ed32cf3c9787d698119f94c77
|
|
BLAKE2b-256 checksum How to use checksums |
36c9c40ff46f8993140d0a1cf2dd5e5c5e38b13a000b2955635aad1628336695
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / model_prices-0.0.9-py3-none-any.whl
| Download URL | model_prices-0.0.9-py3-none-any.whl |
|---|---|
| Size | 128.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
698e61efd1796a4c7bbede15446f2c99eb2df5f8761bd9102bf0ec12fe0ad9cf
|
|
BLAKE2b-256 checksum How to use checksums |
a5fe0249d86c08ce99eaf9c34a80053588967df4ed238a086c1c6b78b6d9533a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for model-prices 0.0.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.