mizanbench 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,191 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this
152
+ License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2026 LL TECHNOLOGIES L.L.C
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
@@ -0,0 +1,124 @@
1
+ Metadata-Version: 2.4
2
+ Name: mizanbench
3
+ Version: 0.1.0
4
+ Summary: Open LLM cost simulator: model mix, cascade routing, and savings estimates from real workload numbers.
5
+ Author: LL TECHNOLOGIES L.L.C
6
+ License: Apache-2.0
7
+ Keywords: llm,cost,simulator,benchmark,routing,cascade
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: pyyaml>=6.0
12
+ Provides-Extra: dev
13
+ Requires-Dist: pytest>=8.0; extra == "dev"
14
+ Dynamic: license-file
15
+
16
+ # MizanBench — open LLM cost simulator
17
+
18
+ Estimate what your LLM workload actually costs — and what smarter routing
19
+ would save — before you spend a dollar. MizanBench models three strategies
20
+ over your real traffic numbers:
21
+
22
+ - **Single model** — everything to one model (your baseline)
23
+ - **Mix** — static traffic split across models
24
+ - **Cascade** — cheap model tries first, unresolved requests escalate
25
+
26
+ MizanBench's cascade accounting is deliberately **honest**: a request that
27
+ escalates past a cheap tier still *pays* for that tier's attempt, exactly
28
+ as real routers bill. The savings it reports are conservative, not
29
+ marketing numbers.
30
+
31
+ ## Quickstart
32
+
33
+ ```bash
34
+ pip install pyyaml
35
+ PYTHONPATH=src python -m mizanbench.cli simulate examples/workload.yaml
36
+ # (after `pip install -e .`: just `mizanbench simulate examples/workload.yaml`)
37
+ ```
38
+
39
+ Output for the bundled example (a 20k-requests/day support assistant):
40
+
41
+ ```
42
+ scenario monthly per-request vs baseline
43
+ -----------------------------------------------------------------------------
44
+ all frontier (GPT-5.6 Sol) $9,900.00 $0.02 baseline
45
+ all mid-tier (Claude Sonnet 5) $3,540.00 $0.005900 -64.2%
46
+ 70/30 mix (Flash + Sonnet 5) $1,580.70 $0.002635 -84.0%
47
+ cascade nano -> small -> frontier $1,285.35 $0.002142 -87.0%
48
+ ```
49
+
50
+ List the pricing catalog:
51
+
52
+ ```bash
53
+ PYTHONPATH=src python -m mizanbench.cli models
54
+ ```
55
+
56
+ ## Describe your own workload
57
+
58
+ Copy `examples/workload.yaml` and edit:
59
+
60
+ ```yaml
61
+ workload:
62
+ requests_per_day: 20000
63
+ avg_input_tokens: 1200
64
+ avg_output_tokens: 350
65
+ days: 30
66
+
67
+ scenarios:
68
+ - name: "baseline"
69
+ type: single
70
+ model: gpt-5.6-sol
71
+ baseline: true
72
+
73
+ - name: "cascade"
74
+ type: cascade
75
+ tiers:
76
+ - { model: gpt-5.4-nano, resolve_rate: 0.65 } # fraction resolved here
77
+ - { model: gemini-2.5-flash, resolve_rate: 0.80 } # of what escalated
78
+ - { model: claude-opus-4.8 } # final tier takes the rest
79
+ ```
80
+
81
+ `resolve_rate` is the honest knob: it is the fraction of requests the tier
82
+ *successfully terminates*. Measure it from your own eval data — an
83
+ optimistic guess here produces optimistic savings.
84
+
85
+ ## Pricing catalog
86
+
87
+ `src/mizanbench/data/pricing.yaml` ships with prices **as of 2026-07-27** (USD
88
+ per 1M tokens) for OpenAI, Anthropic, Google, DeepSeek, Groq, and Together
89
+ models. Prices change often:
90
+
91
+ - override with your own file: `mizanbench -p my-pricing.yaml simulate ...`
92
+ - or better, **send a PR updating the catalog** — it's the easiest first
93
+ contribution to this project, and the `as_of` field keeps us honest.
94
+
95
+ ## Use as a library
96
+
97
+ ```python
98
+ from mizanbench import PricingCatalog, Workload, simulate_cascade
99
+
100
+ catalog = PricingCatalog.load()
101
+ w = Workload(requests_per_day=20000, avg_input_tokens=1200, avg_output_tokens=350)
102
+ result = simulate_cascade(catalog, w, [
103
+ {"model": "gpt-5.4-nano", "resolve_rate": 0.65},
104
+ {"model": "claude-sonnet-5"},
105
+ ])
106
+ print(result.monthly_cost, result.per_request_cost)
107
+ ```
108
+
109
+ ## Tests
110
+
111
+ ```bash
112
+ PYTHONPATH=src python -m unittest discover -s tests # stdlib, no deps
113
+ # or: pytest
114
+ ```
115
+
116
+ ## Roadmap
117
+
118
+ - Benchmark harness: measured (not assumed) resolve rates per model/task.
119
+ - Latency modeling alongside cost.
120
+ - Web calculator UI.
121
+
122
+ ## License
123
+
124
+ Apache-2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,109 @@
1
+ # MizanBench — open LLM cost simulator
2
+
3
+ Estimate what your LLM workload actually costs — and what smarter routing
4
+ would save — before you spend a dollar. MizanBench models three strategies
5
+ over your real traffic numbers:
6
+
7
+ - **Single model** — everything to one model (your baseline)
8
+ - **Mix** — static traffic split across models
9
+ - **Cascade** — cheap model tries first, unresolved requests escalate
10
+
11
+ MizanBench's cascade accounting is deliberately **honest**: a request that
12
+ escalates past a cheap tier still *pays* for that tier's attempt, exactly
13
+ as real routers bill. The savings it reports are conservative, not
14
+ marketing numbers.
15
+
16
+ ## Quickstart
17
+
18
+ ```bash
19
+ pip install pyyaml
20
+ PYTHONPATH=src python -m mizanbench.cli simulate examples/workload.yaml
21
+ # (after `pip install -e .`: just `mizanbench simulate examples/workload.yaml`)
22
+ ```
23
+
24
+ Output for the bundled example (a 20k-requests/day support assistant):
25
+
26
+ ```
27
+ scenario monthly per-request vs baseline
28
+ -----------------------------------------------------------------------------
29
+ all frontier (GPT-5.6 Sol) $9,900.00 $0.02 baseline
30
+ all mid-tier (Claude Sonnet 5) $3,540.00 $0.005900 -64.2%
31
+ 70/30 mix (Flash + Sonnet 5) $1,580.70 $0.002635 -84.0%
32
+ cascade nano -> small -> frontier $1,285.35 $0.002142 -87.0%
33
+ ```
34
+
35
+ List the pricing catalog:
36
+
37
+ ```bash
38
+ PYTHONPATH=src python -m mizanbench.cli models
39
+ ```
40
+
41
+ ## Describe your own workload
42
+
43
+ Copy `examples/workload.yaml` and edit:
44
+
45
+ ```yaml
46
+ workload:
47
+ requests_per_day: 20000
48
+ avg_input_tokens: 1200
49
+ avg_output_tokens: 350
50
+ days: 30
51
+
52
+ scenarios:
53
+ - name: "baseline"
54
+ type: single
55
+ model: gpt-5.6-sol
56
+ baseline: true
57
+
58
+ - name: "cascade"
59
+ type: cascade
60
+ tiers:
61
+ - { model: gpt-5.4-nano, resolve_rate: 0.65 } # fraction resolved here
62
+ - { model: gemini-2.5-flash, resolve_rate: 0.80 } # of what escalated
63
+ - { model: claude-opus-4.8 } # final tier takes the rest
64
+ ```
65
+
66
+ `resolve_rate` is the honest knob: it is the fraction of requests the tier
67
+ *successfully terminates*. Measure it from your own eval data — an
68
+ optimistic guess here produces optimistic savings.
69
+
70
+ ## Pricing catalog
71
+
72
+ `src/mizanbench/data/pricing.yaml` ships with prices **as of 2026-07-27** (USD
73
+ per 1M tokens) for OpenAI, Anthropic, Google, DeepSeek, Groq, and Together
74
+ models. Prices change often:
75
+
76
+ - override with your own file: `mizanbench -p my-pricing.yaml simulate ...`
77
+ - or better, **send a PR updating the catalog** — it's the easiest first
78
+ contribution to this project, and the `as_of` field keeps us honest.
79
+
80
+ ## Use as a library
81
+
82
+ ```python
83
+ from mizanbench import PricingCatalog, Workload, simulate_cascade
84
+
85
+ catalog = PricingCatalog.load()
86
+ w = Workload(requests_per_day=20000, avg_input_tokens=1200, avg_output_tokens=350)
87
+ result = simulate_cascade(catalog, w, [
88
+ {"model": "gpt-5.4-nano", "resolve_rate": 0.65},
89
+ {"model": "claude-sonnet-5"},
90
+ ])
91
+ print(result.monthly_cost, result.per_request_cost)
92
+ ```
93
+
94
+ ## Tests
95
+
96
+ ```bash
97
+ PYTHONPATH=src python -m unittest discover -s tests # stdlib, no deps
98
+ # or: pytest
99
+ ```
100
+
101
+ ## Roadmap
102
+
103
+ - Benchmark harness: measured (not assumed) resolve rates per model/task.
104
+ - Latency modeling alongside cost.
105
+ - Web calculator UI.
106
+
107
+ ## License
108
+
109
+ Apache-2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "mizanbench"
7
+ version = "0.1.0"
8
+ description = "Open LLM cost simulator: model mix, cascade routing, and savings estimates from real workload numbers."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "Apache-2.0" }
12
+ authors = [{ name = "LL TECHNOLOGIES L.L.C" }]
13
+ keywords = ["llm", "cost", "simulator", "benchmark", "routing", "cascade"]
14
+ dependencies = ["pyyaml>=6.0"]
15
+
16
+ [project.optional-dependencies]
17
+ dev = ["pytest>=8.0"]
18
+
19
+ [project.scripts]
20
+ mizanbench = "mizanbench.cli:main"
21
+
22
+ [tool.setuptools.packages.find]
23
+ where = ["src"]
24
+
25
+ [tool.setuptools.package-data]
26
+ mizanbench = ["data/*.yaml"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,14 @@
1
+ """MizanBench — open LLM cost simulator.
2
+
3
+ Estimate what an LLM workload costs across single-model, traffic-mix, and
4
+ cascade-routing strategies, using a transparent, PR-updatable pricing catalog.
5
+ """
6
+ __version__ = "0.1.0"
7
+
8
+ from .pricing import ModelPrice, PricingCatalog
9
+ from .simulator import SimResult, TierResult, Workload, simulate_cascade, simulate_mix, simulate_single
10
+
11
+ __all__ = [
12
+ "ModelPrice", "PricingCatalog", "Workload", "SimResult", "TierResult",
13
+ "simulate_single", "simulate_mix", "simulate_cascade",
14
+ ]
@@ -0,0 +1,99 @@
1
+ """Command-line interface.
2
+
3
+ mizanbench models list the pricing catalog
4
+ mizanbench simulate examples/workload.yaml run scenarios from a workload file
5
+ """
6
+ from __future__ import annotations
7
+
8
+ import argparse
9
+ import sys
10
+ from pathlib import Path
11
+
12
+ import yaml
13
+
14
+ from .pricing import PricingCatalog
15
+ from .simulator import Workload, simulate_cascade, simulate_mix, simulate_single
16
+
17
+ def _fmt_usd(x: float) -> str:
18
+ return f"${x:,.2f}" if x >= 0.01 else f"${x:.6f}"
19
+
20
+
21
+ def cmd_models(catalog: PricingCatalog) -> None:
22
+ print(f"MizanBench pricing catalog (as of {catalog.as_of}, USD per 1M tokens)\n")
23
+ rows = sorted(catalog.models.values(), key=lambda m: (m.provider, m.input_per_1m))
24
+ print(f"{'model':<24} {'provider':<10} {'tier':<9} {'input':>8} {'output':>8}")
25
+ print("-" * 64)
26
+ for m in rows:
27
+ print(f"{m.name:<24} {m.provider:<10} {m.tier:<9} {m.input_per_1m:>8.3f} {m.output_per_1m:>8.2f}")
28
+
29
+
30
+ def cmd_simulate(catalog: PricingCatalog, workload_path: Path) -> None:
31
+ doc = yaml.safe_load(workload_path.read_text())
32
+ w = doc["workload"]
33
+ workload = Workload(
34
+ requests_per_day=float(w["requests_per_day"]),
35
+ avg_input_tokens=float(w["avg_input_tokens"]),
36
+ avg_output_tokens=float(w["avg_output_tokens"]),
37
+ days=float(w.get("days", 30)),
38
+ )
39
+ print(f"MizanBench cost simulation (pricing as of {catalog.as_of})")
40
+ print(f"workload: {workload.requests_per_day:,.0f} req/day x {workload.days:.0f} days, "
41
+ f"{workload.avg_input_tokens:,.0f} in / {workload.avg_output_tokens:,.0f} out tokens avg\n")
42
+
43
+ results = []
44
+ baseline = None
45
+ for scen in doc["scenarios"]:
46
+ kind = scen["type"]
47
+ if kind == "single":
48
+ res = simulate_single(catalog, workload, scen["model"])
49
+ name = scen.get("name", f"single: {scen['model']}")
50
+ elif kind == "mix":
51
+ res = simulate_mix(catalog, workload, scen["mix"])
52
+ name = scen.get("name", "mix")
53
+ elif kind == "cascade":
54
+ res = simulate_cascade(catalog, workload, scen["tiers"])
55
+ name = scen.get("name", "cascade")
56
+ else:
57
+ raise ValueError(f"Unknown scenario type: {kind}")
58
+ results.append((name, res, scen.get("baseline", False)))
59
+ if scen.get("baseline"):
60
+ baseline = res
61
+
62
+ if baseline is None:
63
+ baseline = results[0][1]
64
+
65
+ width = max(len(n) for n, _, _ in results) + 2
66
+ print(f"{'scenario':<{width}} {'monthly':>12} {'per-request':>12} {'vs baseline':>14}")
67
+ print("-" * (width + 42))
68
+ for name, res, is_base in results:
69
+ saved, frac = res.savings_vs(baseline)
70
+ tag = "baseline" if res is baseline else f"-{frac:.1%}" if saved > 0 else f"+{-frac:.1%}"
71
+ print(f"{name:<{width}} {_fmt_usd(res.monthly_cost):>12} {_fmt_usd(res.per_request_cost):>12} {tag:>14}")
72
+
73
+ print("\nDetail (cascade/mix tiers):")
74
+ for name, res, _ in results:
75
+ if len(res.tiers) > 1:
76
+ print(f" {name}:")
77
+ for t in res.tiers:
78
+ print(f" {t.model:<24} reached {t.requests:>12,.0f} resolved {t.resolved:>12,.0f} cost {_fmt_usd(t.cost)}")
79
+
80
+
81
+ def main(argv: list[str] | None = None) -> int:
82
+ p = argparse.ArgumentParser(prog="mizanbench", description="MizanBench: open LLM cost simulator")
83
+ p.add_argument("-p", "--pricing", type=Path, default=None, help="custom pricing YAML (default: bundled catalog)")
84
+ sub = p.add_subparsers(dest="cmd", required=True)
85
+ sub.add_parser("models", help="list the pricing catalog")
86
+ sp = sub.add_parser("simulate", help="run cost scenarios from a workload YAML")
87
+ sp.add_argument("workload", type=Path, help="workload + scenarios YAML file")
88
+ args = p.parse_args(argv)
89
+
90
+ catalog = PricingCatalog.load(args.pricing)
91
+ if args.cmd == "models":
92
+ cmd_models(catalog)
93
+ elif args.cmd == "simulate":
94
+ cmd_simulate(catalog, args.workload)
95
+ return 0
96
+
97
+
98
+ if __name__ == "__main__":
99
+ sys.exit(main())
@@ -0,0 +1,56 @@
1
+ # =============================================================================
2
+ # Model pricing catalog — USD per 1 MILLION tokens.
3
+ #
4
+ # as_of: 2026-08-13 (verified against provider primary sources, see NOTES)
5
+ # PRICES CHANGE OFTEN. Verify against provider pages before publishing numbers,
6
+ # and PRs updating this file are the easiest first contribution to this repo.
7
+ # Users can override with their own file: mizanbench simulate -p my-pricing.yaml
8
+ #
9
+ # VERIFICATION NOTES (2026-08-13)
10
+ # Anthropic — platform.claude.com/docs/en/about-claude/pricing
11
+ # OpenAI — openai.com GPT-5.6 launch post + published price page
12
+ # Google — ai.google.dev/gemini-api/docs/pricing
13
+ # DeepSeek / Groq / Together — NOT re-verified this round; carried forward
14
+ # from the 2026-07-27 catalog. Treat as indicative.
15
+ #
16
+ # Corrected this round (were wrong, not merely stale):
17
+ # gpt-5.6-terra was 2.50 / 15.00 -> 2.00 / 12.00
18
+ # gpt-5.6-luna was 1.00 / 6.00 -> 0.20 / 1.20 (output was 5x high)
19
+ #
20
+ # Known modelling limit: gemini-2.5-pro is priced in two bands by prompt
21
+ # size (<=200k vs >200k input tokens: 1.25/10.00 vs 2.50/15.00). This flat
22
+ # catalog cannot express that; the <=200k band is used. Long-context Pro
23
+ # workloads will be UNDER-estimated here.
24
+ # =============================================================================
25
+ as_of: "2026-08-13"
26
+ currency: USD
27
+ unit: per_1M_tokens
28
+
29
+ models:
30
+ # ---- OpenAI ----
31
+ gpt-5.6-sol: { provider: openai, input: 5.00, output: 30.00, tier: frontier }
32
+ gpt-5.6-terra: { provider: openai, input: 2.00, output: 12.00, tier: mid }
33
+ gpt-5.6-luna: { provider: openai, input: 0.20, output: 1.20, tier: nano }
34
+ gpt-5.4: { provider: openai, input: 2.50, output: 15.00, tier: mid }
35
+ gpt-5.4-mini: { provider: openai, input: 0.75, output: 4.50, tier: small }
36
+ gpt-5.4-nano: { provider: openai, input: 0.20, output: 1.25, tier: nano }
37
+
38
+ # ---- Anthropic ----
39
+ claude-fable-5: { provider: anthropic, input: 10.00, output: 50.00, tier: frontier }
40
+ claude-mythos-5: { provider: anthropic, input: 10.00, output: 50.00, tier: frontier }
41
+ claude-opus-5: { provider: anthropic, input: 5.00, output: 25.00, tier: frontier }
42
+ claude-opus-4.8: { provider: anthropic, input: 5.00, output: 25.00, tier: frontier }
43
+ claude-sonnet-5: { provider: anthropic, input: 2.00, output: 10.00, tier: mid }
44
+ claude-sonnet-4.6: { provider: anthropic, input: 3.00, output: 15.00, tier: mid }
45
+ claude-haiku-4.5: { provider: anthropic, input: 1.00, output: 5.00, tier: small }
46
+
47
+ # ---- Google ----
48
+ gemini-2.5-pro: { provider: google, input: 1.25, output: 10.00, tier: mid }
49
+ gemini-2.5-flash: { provider: google, input: 0.30, output: 2.50, tier: small }
50
+ gemini-2.5-flash-lite: { provider: google, input: 0.10, output: 0.40, tier: nano }
51
+
52
+ # ---- Open-weight / budget hosts (not re-verified 2026-08-13) ----
53
+ deepseek-v4-pro: { provider: deepseek, input: 0.435, output: 0.87, tier: small }
54
+ deepseek-v4-flash: { provider: deepseek, input: 0.14, output: 0.28, tier: nano }
55
+ llama-3.1-8b-groq: { provider: groq, input: 0.05, output: 0.08, tier: nano }
56
+ lfm2-24b-together: { provider: together, input: 0.03, output: 0.12, tier: nano }
@@ -0,0 +1,53 @@
1
+ """Model pricing catalog: load, validate, and query per-token prices."""
2
+ from __future__ import annotations
3
+
4
+ from dataclasses import dataclass
5
+ from importlib import resources
6
+ from pathlib import Path
7
+
8
+ import yaml
9
+
10
+
11
+ @dataclass(frozen=True)
12
+ class ModelPrice:
13
+ name: str
14
+ provider: str
15
+ input_per_1m: float # USD per 1M input tokens
16
+ output_per_1m: float # USD per 1M output tokens
17
+ tier: str = "unknown"
18
+
19
+ def cost(self, input_tokens: float, output_tokens: float) -> float:
20
+ """Cost in USD for the given token counts."""
21
+ return (input_tokens * self.input_per_1m + output_tokens * self.output_per_1m) / 1_000_000
22
+
23
+
24
+ class PricingCatalog:
25
+ def __init__(self, models: dict[str, ModelPrice], as_of: str = "unknown"):
26
+ self.models = models
27
+ self.as_of = as_of
28
+
29
+ @classmethod
30
+ def load(cls, path: str | Path | None = None) -> "PricingCatalog":
31
+ """Load pricing from a YAML file, or the bundled default catalog."""
32
+ if path is None:
33
+ raw = resources.files("mizanbench").joinpath("data/pricing.yaml").read_text()
34
+ else:
35
+ raw = Path(path).read_text()
36
+ doc = yaml.safe_load(raw)
37
+ models = {}
38
+ for name, spec in doc["models"].items():
39
+ models[name] = ModelPrice(
40
+ name=name,
41
+ provider=spec.get("provider", "unknown"),
42
+ input_per_1m=float(spec["input"]),
43
+ output_per_1m=float(spec["output"]),
44
+ tier=spec.get("tier", "unknown"),
45
+ )
46
+ return cls(models, as_of=str(doc.get("as_of", "unknown")))
47
+
48
+ def get(self, name: str) -> ModelPrice:
49
+ try:
50
+ return self.models[name]
51
+ except KeyError:
52
+ known = ", ".join(sorted(self.models))
53
+ raise KeyError(f"Unknown model '{name}'. Known models: {known}") from None
@@ -0,0 +1,102 @@
1
+ """Cost simulation engines: single model, traffic mix, and cascade routing.
2
+
3
+ The cascade model is deliberately honest: a request that escalates past a
4
+ cheap tier still PAYS for the cheap tier's attempt (that's how real routers
5
+ bill), so cascade savings here are conservative, not marketing numbers.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ from dataclasses import dataclass, field
10
+
11
+ from .pricing import PricingCatalog
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class Workload:
16
+ """A monthly LLM workload described by averages."""
17
+ requests_per_day: float
18
+ avg_input_tokens: float
19
+ avg_output_tokens: float
20
+ days: float = 30.0
21
+
22
+ @property
23
+ def monthly_requests(self) -> float:
24
+ return self.requests_per_day * self.days
25
+
26
+
27
+ @dataclass(frozen=True)
28
+ class TierResult:
29
+ model: str
30
+ requests: float # requests that REACHED this tier
31
+ resolved: float # requests resolved (terminated) at this tier
32
+ cost: float # USD paid to this tier (all requests that reached it)
33
+
34
+
35
+ @dataclass(frozen=True)
36
+ class SimResult:
37
+ label: str
38
+ monthly_cost: float
39
+ per_request_cost: float
40
+ tiers: list[TierResult] = field(default_factory=list)
41
+
42
+ def savings_vs(self, baseline: "SimResult") -> tuple[float, float]:
43
+ """(absolute USD saved per month, fraction saved) vs a baseline result."""
44
+ saved = baseline.monthly_cost - self.monthly_cost
45
+ frac = saved / baseline.monthly_cost if baseline.monthly_cost else 0.0
46
+ return saved, frac
47
+
48
+
49
+ def simulate_single(catalog: PricingCatalog, workload: Workload, model: str) -> SimResult:
50
+ """Everything goes to one model."""
51
+ price = catalog.get(model)
52
+ per_req = price.cost(workload.avg_input_tokens, workload.avg_output_tokens)
53
+ monthly = per_req * workload.monthly_requests
54
+ tiers = [TierResult(model, workload.monthly_requests, workload.monthly_requests, monthly)]
55
+ return SimResult(label=f"single:{model}", monthly_cost=monthly, per_request_cost=per_req, tiers=tiers)
56
+
57
+
58
+ def simulate_mix(catalog: PricingCatalog, workload: Workload, mix: dict[str, float]) -> SimResult:
59
+ """Traffic split across models. `mix` maps model -> share; shares must sum to 1.0."""
60
+ total_share = sum(mix.values())
61
+ if abs(total_share - 1.0) > 1e-6:
62
+ raise ValueError(f"Mix shares must sum to 1.0 (got {total_share})")
63
+ monthly = 0.0
64
+ tiers = []
65
+ for model, share in mix.items():
66
+ price = catalog.get(model)
67
+ reqs = workload.monthly_requests * share
68
+ cost = price.cost(workload.avg_input_tokens, workload.avg_output_tokens) * reqs
69
+ tiers.append(TierResult(model, reqs, reqs, cost))
70
+ monthly += cost
71
+ per_req = monthly / workload.monthly_requests if workload.monthly_requests else 0.0
72
+ return SimResult(label="mix", monthly_cost=monthly, per_request_cost=per_req, tiers=tiers)
73
+
74
+
75
+ def simulate_cascade(
76
+ catalog: PricingCatalog,
77
+ workload: Workload,
78
+ tiers: list[dict],
79
+ ) -> SimResult:
80
+ """Cascade routing: each tier is {model, resolve_rate}. Requests hit tier 1;
81
+ a `resolve_rate` fraction terminates there, the rest escalate to the next
82
+ tier (and still pay the current tier's cost). The final tier resolves all
83
+ remaining traffic regardless of its stated rate.
84
+ """
85
+ if not tiers:
86
+ raise ValueError("Cascade needs at least one tier")
87
+ remaining = workload.monthly_requests
88
+ monthly = 0.0
89
+ results = []
90
+ for i, tier in enumerate(tiers):
91
+ model = tier["model"]
92
+ price = catalog.get(model)
93
+ rate = 1.0 if i == len(tiers) - 1 else float(tier["resolve_rate"])
94
+ if not 0.0 <= rate <= 1.0:
95
+ raise ValueError(f"resolve_rate must be within [0,1] (tier {model}: {rate})")
96
+ cost = price.cost(workload.avg_input_tokens, workload.avg_output_tokens) * remaining
97
+ resolved = remaining * rate
98
+ results.append(TierResult(model, remaining, resolved, cost))
99
+ monthly += cost
100
+ remaining -= resolved
101
+ per_req = monthly / workload.monthly_requests if workload.monthly_requests else 0.0
102
+ return SimResult(label="cascade", monthly_cost=monthly, per_request_cost=per_req, tiers=results)
@@ -0,0 +1,124 @@
1
+ Metadata-Version: 2.4
2
+ Name: mizanbench
3
+ Version: 0.1.0
4
+ Summary: Open LLM cost simulator: model mix, cascade routing, and savings estimates from real workload numbers.
5
+ Author: LL TECHNOLOGIES L.L.C
6
+ License: Apache-2.0
7
+ Keywords: llm,cost,simulator,benchmark,routing,cascade
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: pyyaml>=6.0
12
+ Provides-Extra: dev
13
+ Requires-Dist: pytest>=8.0; extra == "dev"
14
+ Dynamic: license-file
15
+
16
+ # MizanBench — open LLM cost simulator
17
+
18
+ Estimate what your LLM workload actually costs — and what smarter routing
19
+ would save — before you spend a dollar. MizanBench models three strategies
20
+ over your real traffic numbers:
21
+
22
+ - **Single model** — everything to one model (your baseline)
23
+ - **Mix** — static traffic split across models
24
+ - **Cascade** — cheap model tries first, unresolved requests escalate
25
+
26
+ MizanBench's cascade accounting is deliberately **honest**: a request that
27
+ escalates past a cheap tier still *pays* for that tier's attempt, exactly
28
+ as real routers bill. The savings it reports are conservative, not
29
+ marketing numbers.
30
+
31
+ ## Quickstart
32
+
33
+ ```bash
34
+ pip install pyyaml
35
+ PYTHONPATH=src python -m mizanbench.cli simulate examples/workload.yaml
36
+ # (after `pip install -e .`: just `mizanbench simulate examples/workload.yaml`)
37
+ ```
38
+
39
+ Output for the bundled example (a 20k-requests/day support assistant):
40
+
41
+ ```
42
+ scenario monthly per-request vs baseline
43
+ -----------------------------------------------------------------------------
44
+ all frontier (GPT-5.6 Sol) $9,900.00 $0.02 baseline
45
+ all mid-tier (Claude Sonnet 5) $3,540.00 $0.005900 -64.2%
46
+ 70/30 mix (Flash + Sonnet 5) $1,580.70 $0.002635 -84.0%
47
+ cascade nano -> small -> frontier $1,285.35 $0.002142 -87.0%
48
+ ```
49
+
50
+ List the pricing catalog:
51
+
52
+ ```bash
53
+ PYTHONPATH=src python -m mizanbench.cli models
54
+ ```
55
+
56
+ ## Describe your own workload
57
+
58
+ Copy `examples/workload.yaml` and edit:
59
+
60
+ ```yaml
61
+ workload:
62
+ requests_per_day: 20000
63
+ avg_input_tokens: 1200
64
+ avg_output_tokens: 350
65
+ days: 30
66
+
67
+ scenarios:
68
+ - name: "baseline"
69
+ type: single
70
+ model: gpt-5.6-sol
71
+ baseline: true
72
+
73
+ - name: "cascade"
74
+ type: cascade
75
+ tiers:
76
+ - { model: gpt-5.4-nano, resolve_rate: 0.65 } # fraction resolved here
77
+ - { model: gemini-2.5-flash, resolve_rate: 0.80 } # of what escalated
78
+ - { model: claude-opus-4.8 } # final tier takes the rest
79
+ ```
80
+
81
+ `resolve_rate` is the honest knob: it is the fraction of requests the tier
82
+ *successfully terminates*. Measure it from your own eval data — an
83
+ optimistic guess here produces optimistic savings.
84
+
85
+ ## Pricing catalog
86
+
87
+ `src/mizanbench/data/pricing.yaml` ships with prices **as of 2026-07-27** (USD
88
+ per 1M tokens) for OpenAI, Anthropic, Google, DeepSeek, Groq, and Together
89
+ models. Prices change often:
90
+
91
+ - override with your own file: `mizanbench -p my-pricing.yaml simulate ...`
92
+ - or better, **send a PR updating the catalog** — it's the easiest first
93
+ contribution to this project, and the `as_of` field keeps us honest.
94
+
95
+ ## Use as a library
96
+
97
+ ```python
98
+ from mizanbench import PricingCatalog, Workload, simulate_cascade
99
+
100
+ catalog = PricingCatalog.load()
101
+ w = Workload(requests_per_day=20000, avg_input_tokens=1200, avg_output_tokens=350)
102
+ result = simulate_cascade(catalog, w, [
103
+ {"model": "gpt-5.4-nano", "resolve_rate": 0.65},
104
+ {"model": "claude-sonnet-5"},
105
+ ])
106
+ print(result.monthly_cost, result.per_request_cost)
107
+ ```
108
+
109
+ ## Tests
110
+
111
+ ```bash
112
+ PYTHONPATH=src python -m unittest discover -s tests # stdlib, no deps
113
+ # or: pytest
114
+ ```
115
+
116
+ ## Roadmap
117
+
118
+ - Benchmark harness: measured (not assumed) resolve rates per model/task.
119
+ - Latency modeling alongside cost.
120
+ - Web calculator UI.
121
+
122
+ ## License
123
+
124
+ Apache-2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,16 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/mizanbench/__init__.py
5
+ src/mizanbench/cli.py
6
+ src/mizanbench/pricing.py
7
+ src/mizanbench/simulator.py
8
+ src/mizanbench.egg-info/PKG-INFO
9
+ src/mizanbench.egg-info/SOURCES.txt
10
+ src/mizanbench.egg-info/dependency_links.txt
11
+ src/mizanbench.egg-info/entry_points.txt
12
+ src/mizanbench.egg-info/requires.txt
13
+ src/mizanbench.egg-info/top_level.txt
14
+ src/mizanbench/data/pricing.yaml
15
+ tests/test_simulator.py
16
+ tests/test_validate_pricing.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ mizanbench = mizanbench.cli:main
@@ -0,0 +1,4 @@
1
+ pyyaml>=6.0
2
+
3
+ [dev]
4
+ pytest>=8.0
@@ -0,0 +1 @@
1
+ mizanbench
@@ -0,0 +1,79 @@
1
+ """Runs with stdlib unittest (python -m unittest discover tests) and pytest alike."""
2
+ import unittest
3
+
4
+ from mizanbench.pricing import ModelPrice, PricingCatalog
5
+ from mizanbench.simulator import Workload, simulate_cascade, simulate_mix, simulate_single
6
+
7
+
8
+ def catalog() -> PricingCatalog:
9
+ return PricingCatalog({
10
+ "cheap": ModelPrice("cheap", "t", input_per_1m=0.10, output_per_1m=0.40),
11
+ "mid": ModelPrice("mid", "t", input_per_1m=1.00, output_per_1m=4.00),
12
+ "frontier": ModelPrice("frontier", "t", input_per_1m=10.00, output_per_1m=40.00),
13
+ }, as_of="test")
14
+
15
+
16
+ # 1000 req/day * 10 days = 10_000 requests; 1000 in + 500 out tokens each.
17
+ W = Workload(requests_per_day=1000, avg_input_tokens=1000, avg_output_tokens=500, days=10)
18
+
19
+
20
+ class TestSingle(unittest.TestCase):
21
+ def test_single_cost(self):
22
+ # per request: (1000*10 + 500*40)/1e6 = 0.03 USD; 10_000 req => 300 USD
23
+ res = simulate_single(catalog(), W, "frontier")
24
+ self.assertAlmostEqual(res.per_request_cost, 0.03)
25
+ self.assertAlmostEqual(res.monthly_cost, 300.0)
26
+
27
+ def test_unknown_model(self):
28
+ with self.assertRaises(KeyError):
29
+ simulate_single(catalog(), W, "nope")
30
+
31
+
32
+ class TestMix(unittest.TestCase):
33
+ def test_mix_weights(self):
34
+ res = simulate_mix(catalog(), W, {"cheap": 0.5, "frontier": 0.5})
35
+ # cheap per-req: (1000*0.1+500*0.4)/1e6 = 0.0003; frontier 0.03
36
+ expected = 5000 * 0.0003 + 5000 * 0.03
37
+ self.assertAlmostEqual(res.monthly_cost, expected)
38
+
39
+ def test_mix_must_sum_to_one(self):
40
+ with self.assertRaises(ValueError):
41
+ simulate_mix(catalog(), W, {"cheap": 0.5, "frontier": 0.4})
42
+
43
+
44
+ class TestCascade(unittest.TestCase):
45
+ def test_cascade_honest_accounting(self):
46
+ res = simulate_cascade(catalog(), W, [
47
+ {"model": "cheap", "resolve_rate": 0.8},
48
+ {"model": "frontier"},
49
+ ])
50
+ # all 10k pay cheap (0.0003) = 3.0 ; 2k escalate and pay frontier (0.03) = 60.0
51
+ self.assertAlmostEqual(res.monthly_cost, 63.0)
52
+ self.assertAlmostEqual(res.tiers[0].requests, 10_000)
53
+ self.assertAlmostEqual(res.tiers[1].requests, 2_000)
54
+ self.assertAlmostEqual(res.tiers[1].resolved, 2_000) # final tier resolves all
55
+
56
+ def test_cascade_beats_frontier_baseline(self):
57
+ base = simulate_single(catalog(), W, "frontier")
58
+ cas = simulate_cascade(catalog(), W, [
59
+ {"model": "cheap", "resolve_rate": 0.8},
60
+ {"model": "frontier"},
61
+ ])
62
+ saved, frac = cas.savings_vs(base)
63
+ self.assertGreater(saved, 0)
64
+ self.assertGreater(frac, 0.5)
65
+
66
+ def test_bad_resolve_rate(self):
67
+ with self.assertRaises(ValueError):
68
+ simulate_cascade(catalog(), W, [{"model": "cheap", "resolve_rate": 1.5}, {"model": "mid"}])
69
+
70
+
71
+ class TestBundledCatalog(unittest.TestCase):
72
+ def test_default_catalog_loads(self):
73
+ cat = PricingCatalog.load()
74
+ self.assertGreater(len(cat.models), 10)
75
+ self.assertIn("claude-sonnet-5", cat.models)
76
+
77
+
78
+ if __name__ == "__main__":
79
+ unittest.main()
@@ -0,0 +1,78 @@
1
+ """Tests for scripts/validate_pricing.py.
2
+
3
+ Adds the repo's scripts/ dir to sys.path directly since it isn't a package
4
+ under src/mizanbench — run with PYTHONPATH=src python -m unittest discover -s tests,
5
+ same as the rest of the suite.
6
+ """
7
+ import sys
8
+ import unittest
9
+ from pathlib import Path
10
+
11
+ sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
12
+
13
+ from validate_pricing import validate # noqa: E402
14
+
15
+
16
+ def good_doc() -> dict:
17
+ return {
18
+ "as_of": "2026-07-27",
19
+ "models": {
20
+ "cheap": {"provider": "acme", "input": 0.10, "output": 0.40},
21
+ "frontier": {"provider": "acme", "input": 5.00, "output": 30.00},
22
+ },
23
+ }
24
+
25
+
26
+ class TestValidatePricing(unittest.TestCase):
27
+ def test_good_doc_has_no_errors(self):
28
+ self.assertEqual(validate(good_doc()), [])
29
+
30
+ def test_bundled_catalog_is_valid(self):
31
+ import yaml
32
+ path = Path(__file__).resolve().parent.parent / "src/mizanbench/data/pricing.yaml"
33
+ doc = yaml.safe_load(path.read_text())
34
+ self.assertEqual(validate(doc), [])
35
+
36
+ def test_missing_as_of(self):
37
+ doc = good_doc()
38
+ del doc["as_of"]
39
+ errors = validate(doc)
40
+ self.assertTrue(any("as_of" in e for e in errors))
41
+
42
+ def test_bad_as_of_format(self):
43
+ doc = good_doc()
44
+ doc["as_of"] = "July 27 2026"
45
+ errors = validate(doc)
46
+ self.assertTrue(any("as_of" in e for e in errors))
47
+
48
+ def test_missing_provider(self):
49
+ doc = good_doc()
50
+ del doc["models"]["cheap"]["provider"]
51
+ errors = validate(doc)
52
+ self.assertTrue(any("cheap" in e and "provider" in e for e in errors))
53
+
54
+ def test_non_positive_price(self):
55
+ doc = good_doc()
56
+ doc["models"]["cheap"]["input"] = 0
57
+ errors = validate(doc)
58
+ self.assertTrue(any("cheap" in e and "input" in e for e in errors))
59
+
60
+ def test_negative_price(self):
61
+ doc = good_doc()
62
+ doc["models"]["cheap"]["output"] = -1.0
63
+ errors = validate(doc)
64
+ self.assertTrue(any("cheap" in e and "output" in e for e in errors))
65
+
66
+ def test_non_numeric_price(self):
67
+ doc = good_doc()
68
+ doc["models"]["cheap"]["input"] = "free"
69
+ errors = validate(doc)
70
+ self.assertTrue(any("cheap" in e and "input" in e for e in errors))
71
+
72
+ def test_no_models(self):
73
+ errors = validate({"as_of": "2026-07-27", "models": {}})
74
+ self.assertTrue(any("models" in e for e in errors))
75
+
76
+
77
+ if __name__ == "__main__":
78
+ unittest.main()