Skip to main content

llm-forecast

Forecast your LLM tokens and spend for the weeks ahead, even as models keep changing. See how the forecast compares with standard methods on your own history, which models and teams are rising or fading, and whether your pricing still makes money at that usage.

PyPI version Total downloads Monthly downloads Open in Colab

Example result card

Try it in 30 seconds

pip install llm-forecast
llm-forecast demo

The demo runs on a bundled synthetic usage log (no real company data) and writes reports, tables, a chart and shareable cards to results/. No install? Use the Colab button.

Four commands

Command What it does
llm-forecast demo See everything work on sample data
llm-forecast check my_usage.csv Show how your file was read: format, dates, models, accounts, totals
llm-forecast run my_usage.csv --next 8w Forecast tokens and spend, compare methods, show model stages and account segments
llm-forecast price-check Test whether your pricing keeps its margin at the usage you are forecasting
llm-forecast cite Print the citation (plain text and BibTeX)

--next takes any horizon: 30d, 8w, 3m.

Your data, as you already have it

The format is detected automatically:

Where your data comes from What to export
OpenAI Usage API response (JSON) or a CSV of it
Anthropic Usage report from the Admin API (JSON) or a CSV of it
OpenRouter Activity export (CSV) or the activity API
LiteLLM Spend logs (CSV or JSON)
AWS, Azure, Google Cloud and other FOCUS billing exports The FOCUS cost and usage file; token rows are picked out automatically
Anything else Any CSV, Excel, Parquet or JSON file with a date, a model and a token count

If a column is not recognised, name it in one line:

llm-forecast run usage.csv --map date=usage_day,model=engine,tokens=units,account=team

Request-level logs are rolled up to days, input and output tokens are added, and several files or a whole folder can be read at once. If your data has a team, project, workspace, API key or user column, account segments are added automatically.

What run shows you

1. The forecast. Expected tokens (and spend, when costs or prices are known) with a low to high range, by model and provider, split into recent level, replacement and expansion.

2. How it compares with other methods, on your own history. Every method forecasts from past dates using only the data available then, and is scored against what actually happened:

Method Error per model Error per provider Error on total MASE Bias p-value vs recent level
Replacement and Expansion (this tool)
Recent level (last full week)
28-day average
Holt-Winters with weekly seasonality
Linear trend
Gradient boosting (--with-ml, needs scikit-learn)

Error is WAPE (absolute error divided by actual volume). MASE compares against repeating the previous window. The p-value is a Diebold-Mariano test with the small-sample correction, as in the paper. The table ranks honestly: if another method wins on your data, it says so. On the bundled sample, Holt-Winters is best per model and this method is best per provider and on the total.

3. Model lifecycle stages (paper, Table 4): new, young, ramping, fading, sibling launched and mature, with what actually happened next to models in each stage on your history.

4. Account segments (paper, Table 3): steady heavy, steady mid-size, intermittent, declining and ramping, built from 28-day scale, activity, volatility, trend and peak-day share. The paper fitted clusters on these features; this tool uses fixed rules with the same five labels so results are stable on any data. It also tests the paper's finding that switching declining accounts to the recent level cuts their error.

Price check

llm-forecast price-check

Price check card

It asks a few questions (how you charge, price, allowance, overage, seats, target margin), takes usage and your cost per token from the forecast, and runs the alignment test:

  • Level test: at expected usage, does price cover cost?
  • Metric test: as usage rises to heavy, does revenue grow at least as fast as cost? If not, the price metric is not aligned with the cost driver, and margin leaks as customers use more.

The result is a decision, not just numbers: ALIGNED, WATCH, AT RISK, LEAK or UNDERPRICED. Options are worked out for your plan: bound the gap with an allowance and overage, redesign the metric, reprice, or hold and recheck when metered usage arrives. Everything can also be passed as options for scripts, e.g. --plan seat --price 30 --units 20000 --target-margin 0.3 --yes.

The test checks the price metric against the cost driver. It does not set value-based prices or measure customer value.

How the forecast works

LLM demand behaves like a product market with short generations: new models arrive every few weeks, take volume from their siblings and add demand of their own. The forecast is built in layers:

  1. Recent level. The last full week, scaled to the horizon.
  2. Provider level. The median of three simple rules on weekly totals.
  3. Replacement. Lifecycle stage multipliers learned from your history and rescaled inside each provider, so volume a fading model loses passes to its siblings.
  4. Expansion. Growth factor g times 1 + ρ(u − 1), where u is the net lift from a launch and ρ is the chance of one in the window. All three are estimated from your history when it is long enough; set them yourself with --growth, --launch-lift and --launch-prob (for example --launch-prob 1 when a release is announced).

Every learned quantity uses only forecast windows that had already closed. Under 14 days the recent level is used alone. The paper evaluated 7 to 56 days. Longer horizons run the same way, and the comparison table shows how each method does on your history at that horizon.

Outputs

File Contents
forecast_models.csv, forecast_providers.csv Expected, low and high tokens (and spend) by model and provider, with the recent level, replacement and expansion parts
method_comparison.csv Error measures for every method
model_stages.csv, account_segments.csv, accounts_now.csv Stage and segment tables, and each account's current segment
report.md, chart.png, card.png A readable report, a chart and a shareable card
summary.json, price_check.json Everything above in a fixed, machine-readable form for agents and scripts

Use with AI agents

summary.json gives agents auditable numbers to explain rather than numbers to compute. skills/llm-forecast/SKILL.md is a ready-made Agent Skill, and llms.txt summarises the project for coding assistants.

Limits

  • This is a simplified open version of the method. The paper's full evaluation is in its companion code (below).
  • Gains over the recent level are modest and depend on how fast models turn over in your data. On stable usage, simpler methods can do as well; the comparison table will show it.
  • The price check assumes usage per billed unit is spread around the expected level by the light and heavy multiples you choose (defaults 0.5x and 2x).

Cite

Please cite the method if you use this tool. Run llm-forecast cite for ready-to-paste text and BibTeX, or see CITATION.cff:

  • Chopra, A. (2026). Replacement and Expansion: Forecasting LLM Token Demand Under Rapid Model Turnover. IEEE Access (under review). Companion code: 10.5281/zenodo.24575344.
  • Chopra, A. (2026, February 17). Financial Planning for Agentic AI Systems: Managing Volatility in the Age of Autonomy. California Management Review Insights.

Privacy

The tool runs entirely on your machine. It sends nothing anywhere: no usage data, no telemetry, no run counts.

Contributing

Readers for more export formats are the most useful contribution: see the issues labelled adapter wanted and CONTRIBUTING.md. Results on public data are welcome too, including results where this method does not win.

License

MIT. Copyright (c) 2026 Ankit Chopra.

Metadata

Release files for llm-forecast 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-forecast 0.1.0
File Size Uploaded Provenance Actions
llm_forecast-0.1.0.tar.gz 742.1 kB Without provenance Details for llm_forecast-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llm-forecast 0.1.0
File Interpreter ABI Platform Actions
llm_forecast-0.1.0-py3-none-any.whl Python 3 none any Details for llm_forecast-0.1.0-py3-none-any.whl

Total release size: 1.5 MB

Release files / llm_forecast-0.1.0.tar.gz

Download URL llm_forecast-0.1.0.tar.gz
Size 742.1 kB
Tags Source
SHA-256 checksum
How to use checksums
17cab831244f5f9e498e8f7b3a705ea3e28718d0f0676621e1137f97422a8b6d
BLAKE2b-256 checksum
How to use checksums
5c8adfec02e9896b644f297559cccfe41ae1728b4f4187b2f13a09ecd2069d0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / llm_forecast-0.1.0-py3-none-any.whl

Download URL llm_forecast-0.1.0-py3-none-any.whl
Size 737.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5efdd2b18daf8aeffe7e7976a09d5d3f99488888f44c6287d1788b455aee9be8
BLAKE2b-256 checksum
How to use checksums
db29403d6280bbd38c5768e2dd9176af84a180935a8a0b8a6566d19d8549af76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for llm-forecast 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page