ecocost 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.
- ecocost-0.1.0/LICENSE +201 -0
- ecocost-0.1.0/NOTICE +88 -0
- ecocost-0.1.0/PKG-INFO +174 -0
- ecocost-0.1.0/README.md +142 -0
- ecocost-0.1.0/ecocost/__init__.py +108 -0
- ecocost-0.1.0/ecocost/calc.py +308 -0
- ecocost-0.1.0/ecocost/data/hardware.yaml +145 -0
- ecocost-0.1.0/ecocost/data/models.yaml +1541 -0
- ecocost-0.1.0/ecocost/data/providers.yaml +378 -0
- ecocost-0.1.0/ecocost/data/regions.yaml +1051 -0
- ecocost-0.1.0/ecocost/data/sources.yaml +182 -0
- ecocost-0.1.0/ecocost/display.py +37 -0
- ecocost-0.1.0/ecocost/errors.py +60 -0
- ecocost-0.1.0/ecocost/loader.py +292 -0
- ecocost-0.1.0/ecocost/py.typed +0 -0
- ecocost-0.1.0/ecocost/result.py +107 -0
- ecocost-0.1.0/ecocost/schema.py +332 -0
- ecocost-0.1.0/pyproject.toml +39 -0
ecocost-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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 License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
ecocost-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
ecocost
|
|
2
|
+
Copyright 2026 Gooey.AI
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
The knowledge base in ecocost/data/ contains figures taken or derived from the
|
|
7
|
+
third-party sources below. Their licences apply to those figures; the Apache
|
|
8
|
+
License covers only this project's own code and compilation. Every value names
|
|
9
|
+
its source in the YAML, and ecocost/data/sources.yaml records each source's
|
|
10
|
+
licence and terms.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Grid carbon intensity and generation mix (regions.yaml, countries)
|
|
14
|
+
------------------------------------------------------------------
|
|
15
|
+
Ember, Yearly Electricity Data, 2025.
|
|
16
|
+
https://ember-energy.org/data/yearly-electricity-data/
|
|
17
|
+
Licence: CC BY 4.0, https://creativecommons.org/licenses/by/4.0/
|
|
18
|
+
Our World in Data, "Carbon intensity of electricity generation" and "Share of
|
|
19
|
+
electricity production by source", based on Ember and the Energy Institute.
|
|
20
|
+
https://ourworldindata.org/grapher/carbon-intensity-electricity
|
|
21
|
+
https://ourworldindata.org/grapher/share-elec-by-source
|
|
22
|
+
Licence: CC BY 4.0
|
|
23
|
+
Changes: values transcribed per country; intensity used as a lifecycle factor
|
|
24
|
+
with a tier-based range added.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Grid carbon intensity and generation mix (regions.yaml, US subregions)
|
|
28
|
+
----------------------------------------------------------------------
|
|
29
|
+
U.S. Environmental Protection Agency, eGRID2023 Summary Tables (rev. 2).
|
|
30
|
+
https://www.epa.gov/egrid
|
|
31
|
+
A work of the U.S. Government, not subject to copyright in the United States.
|
|
32
|
+
Changes: direct emission rates multiplied by 1.124 (the 2023 Ember/eGRID
|
|
33
|
+
national ratio) to put them on a lifecycle basis.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
Water consumed in electricity generation (regions.yaml)
|
|
37
|
+
-------------------------------------------------------
|
|
38
|
+
Reig, P., Luo, T., Christensen, E. and Sinistore, J. 2020. "Guidance for
|
|
39
|
+
Calculating Water Use Embedded in Purchased Electricity." World Resources
|
|
40
|
+
Institute. Appendices 1 and 2.
|
|
41
|
+
https://www.wri.org/research/guidance-calculating-water-use-embedded-purchased-electricity
|
|
42
|
+
Licence: the report is CC BY 4.0. Its appendix tables are based on data from
|
|
43
|
+
thinkstep AG (now Sphera), which the report makes available under separate,
|
|
44
|
+
more restrictive terms. ecocost uses a small number of aggregate national and
|
|
45
|
+
subregional factors (17 values) to support and explain its own calculated
|
|
46
|
+
results.
|
|
47
|
+
Changes: converted from gal/kWh to L/kWh; ranges added.
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
Primary energy factors (regions.yaml); closed-model size estimates (models.yaml)
|
|
51
|
+
------------------------------------------------------------------------------
|
|
52
|
+
EcoLogits, GenAI Impact. electricity_mixes.json and models.json.
|
|
53
|
+
https://github.com/genai-impact/ecologits
|
|
54
|
+
Licence: Mozilla Public License 2.0, https://mozilla.org/MPL/2.0/
|
|
55
|
+
Primary energy factors in electricity_mixes.json originate from ADEME Base
|
|
56
|
+
Empreinte, https://base-empreinte.ademe.fr/
|
|
57
|
+
ecocost does not include EcoLogits source code or its data files; individual
|
|
58
|
+
values were transcribed, and for primary energy divided by 3.6 (MJ/kWh to
|
|
59
|
+
MJ/MJ).
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
Measured inference energy (models.yaml, hardware.yaml)
|
|
63
|
+
------------------------------------------------------
|
|
64
|
+
The ML.ENERGY Leaderboard, University of Michigan.
|
|
65
|
+
https://ml.energy/leaderboard/
|
|
66
|
+
https://github.com/ml-energy/leaderboard
|
|
67
|
+
Chung, J.-W. et al. "The ML.ENERGY Benchmark: Toward Automated Inference
|
|
68
|
+
Energy Measurement and Optimization." 2025. https://arxiv.org/abs/2505.06371
|
|
69
|
+
Changes: per-model Wh per 1k output tokens on H100, and paired H100/B200
|
|
70
|
+
runs used to derive chip energy ratios.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
Hardware embodied carbon (hardware.yaml)
|
|
74
|
+
----------------------------------------
|
|
75
|
+
NVIDIA, HGX H100 Product Carbon Footprint Summary.
|
|
76
|
+
ADEME / Lees-Perasso et al., GPU life-cycle assessment.
|
|
77
|
+
Boavizta, BoaviztAPI server impact model, https://github.com/Boavizta/boaviztapi
|
|
78
|
+
EcoLogits, LLM inference methodology, https://ecologits.ai/
|
|
79
|
+
Figures cited, no code or data files included.
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
Other factual figures
|
|
83
|
+
---------------------
|
|
84
|
+
Model parameter counts come from each model's published model card. Chip
|
|
85
|
+
specifications come from vendor data sheets. PUE, WUE and site figures come
|
|
86
|
+
from the operators' own sustainability reports and documentation. Epoch AI
|
|
87
|
+
data is used under CC BY 4.0 (https://epoch.ai). Each value's source is linked
|
|
88
|
+
in the YAML.
|
ecocost-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ecocost
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Per-run carbon, energy and water estimates for AI inference, with computed confidence and sourced inputs
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
License-File: NOTICE
|
|
8
|
+
Keywords: carbon,energy,water,llm,inference,sustainability,sci
|
|
9
|
+
Author: Gooey.AI
|
|
10
|
+
Author-email: devs@dara.network
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
|
|
25
|
+
Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
|
|
26
|
+
Project-URL: Bug Tracker, https://github.com/GooeyAI/ecocost/issues
|
|
27
|
+
Project-URL: Documentation, https://github.com/GooeyAI/ecocost/blob/main/API.md
|
|
28
|
+
Project-URL: Homepage, https://github.com/GooeyAI/ecocost
|
|
29
|
+
Project-URL: Repository, https://github.com/GooeyAI/ecocost
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# ecocost
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install ecocost
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Per-request carbon, energy and water estimates for AI inference, each with a
|
|
39
|
+
likely range and a confidence label computed from the evidence behind it.
|
|
40
|
+
Every input is sourced and tiered, and the knowledge base in `ecocost/data/`
|
|
41
|
+
is open to pull requests from providers, hardware makers and researchers.
|
|
42
|
+
|
|
43
|
+
Maintained by [Gooey.AI](https://gooey.ai). Pure Python; the only dependency
|
|
44
|
+
is PyYAML.
|
|
45
|
+
|
|
46
|
+
## Quick start
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from ecocost import estimate
|
|
50
|
+
|
|
51
|
+
r = estimate(
|
|
52
|
+
"gpt-oss-120b",
|
|
53
|
+
provider="nscale",
|
|
54
|
+
input_tokens=800,
|
|
55
|
+
output_tokens=300,
|
|
56
|
+
)
|
|
57
|
+
r["carbon"] # {"unit": "gCO2e", "value": 0.0018, "min": ..., "max": ..., "worst_case": {...}}
|
|
58
|
+
r["confidence"] # {"level": "low", "ratio": 16.6, "reasons": ["wue_assumed", ...]}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Model ids are matched through aliases, so provider-specific ids such as
|
|
62
|
+
`accounts/fireworks/models/gpt-oss-120b` resolve to the same record. A model
|
|
63
|
+
that isn't in the knowledge base raises `UnknownModelError`, which suggests
|
|
64
|
+
close matches and links to [adding it](CONTRIBUTING.md#adding-a-model). Ids
|
|
65
|
+
are matched ignoring case.
|
|
66
|
+
|
|
67
|
+
## Provider ids
|
|
68
|
+
|
|
69
|
+
Who serves the request is taken, in order, from:
|
|
70
|
+
|
|
71
|
+
1. `provider`: one of these ids. An unrecognised id raises
|
|
72
|
+
`UnknownProviderError`, so a typo can't silently estimate the wrong site.
|
|
73
|
+
2. `base_url` (optional): the API endpoint you called. Its host is matched
|
|
74
|
+
against the hosts below; an unlisted host is ignored.
|
|
75
|
+
3. For a closed model, its vendor's own API (`claude-*` → `anthropic`,
|
|
76
|
+
`gpt-*` → `openai`, …), flagged `provider_inferred_from_model`.
|
|
77
|
+
4. Otherwise wide US defaults, flagged `provider_unknown_fallback`.
|
|
78
|
+
|
|
79
|
+
| id | provider | API hosts |
|
|
80
|
+
|---|---|---|
|
|
81
|
+
| `fireworks` | Fireworks AI | `api.fireworks.ai` |
|
|
82
|
+
| `nscale` | nScale | `inference.api.nscale.com` |
|
|
83
|
+
| `openai` | OpenAI (direct API) | `api.openai.com` |
|
|
84
|
+
| `anthropic` | Anthropic (direct API) | `api.anthropic.com` |
|
|
85
|
+
| `google-vertex` | Google Vertex AI (us-central1) | `aiplatform.googleapis.com` |
|
|
86
|
+
| `vercel-gateway` | Vercel AI Gateway | `ai-gateway.vercel.sh` |
|
|
87
|
+
| `mistral` | Mistral AI (La Plateforme) | `api.mistral.ai` |
|
|
88
|
+
| `alibaba-sg` | Alibaba Cloud Model Studio (Singapore) | `.ap-southeast-1.maas.aliyuncs.com` |
|
|
89
|
+
| `modal` | Modal | `.modal.run` |
|
|
90
|
+
| `zai` | Z.ai (Zhipu) | `api.z.ai` |
|
|
91
|
+
| `sarvam` | Sarvam AI (Yotta NM1, Navi Mumbai) | `api.sarvam.ai` |
|
|
92
|
+
| `fal` | fal.ai | — |
|
|
93
|
+
| `novita` | Novita AI | `api.novita.ai` |
|
|
94
|
+
| `meta` | Meta AI API | `api.meta.ai` |
|
|
95
|
+
| `dhenu` | KissanAI Dhenu | `apibeta.dhenu.ai` |
|
|
96
|
+
| `sea-lion` | AI Singapore SEA-LION API | `api.sea-lion.ai` |
|
|
97
|
+
| `unknown-us` | Unknown provider (US default) | — |
|
|
98
|
+
|
|
99
|
+
To add a provider, see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
100
|
+
|
|
101
|
+
## API
|
|
102
|
+
|
|
103
|
+
One function:
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
estimate(model, *, provider=None, base_url=None, input_tokens=0, output_tokens=0, cached_input_tokens=0, timestamp=None) -> EstimateResult
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Full parameters, every output field, reason codes, errors and fallbacks, and versioning:
|
|
110
|
+
**[API.md](API.md)**.
|
|
111
|
+
|
|
112
|
+
### Output
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
model, provider, tokens
|
|
116
|
+
carbon gCO2e: value, min, max, worst_case {min, max}
|
|
117
|
+
energy Wh at the meter, primary_energy_mj
|
|
118
|
+
water mL: total, on_site (cooling, WUE), generation (off-site)
|
|
119
|
+
confidence level, ratio (max/min), reasons (every assumed input)
|
|
120
|
+
electricity region, country, gco2e_per_kwh (+ range), mix, dataset_year
|
|
121
|
+
breakdown h100_seconds, usage (operational) and embodied gCO2e
|
|
122
|
+
assumptions active params, chips, chip energy ratio, PUE, utilization, overhead, method_version
|
|
123
|
+
provenance trust, status, generated_by, stale for model, provider, region, hardware
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`min`/`max` is the likely range; `worst_case` puts every input at its extreme
|
|
127
|
+
at once. Cache results against `assumptions.method_version`.
|
|
128
|
+
|
|
129
|
+
## How it works
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
tokens ─▶ FLOPs ─▶ H100-seconds ─▶ Wh at the meter ─▶ gCO2e operational + gCO2e embodied
|
|
133
|
+
─▶ mL water on-site + off-site
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Location-based, lifecycle grid intensity, embodied carbon included, usage
|
|
137
|
+
only. See [METHODOLOGY.md](METHODOLOGY.md) for the pipeline, the sources behind
|
|
138
|
+
every default, how ranges and confidence are computed, calibration against
|
|
139
|
+
published measurements, and the known gaps.
|
|
140
|
+
|
|
141
|
+
## Confidence
|
|
142
|
+
|
|
143
|
+
Every input carries an evidence tier: 1 published by the primary source, 2
|
|
144
|
+
derived or proxy, 3 assumed. The confidence label is computed from the width of
|
|
145
|
+
the likely carbon range (under 2x high, under 5x medium, otherwise low), never
|
|
146
|
+
typed in. `reasons` lists each assumed input, so it doubles as the list of
|
|
147
|
+
figures a provider could publish to tighten its estimates.
|
|
148
|
+
|
|
149
|
+
## Data
|
|
150
|
+
|
|
151
|
+
| File | What |
|
|
152
|
+
|---|---|
|
|
153
|
+
| `ecocost/data/models.yaml` | active and total parameters, measured energy, aliases |
|
|
154
|
+
| `ecocost/data/providers.yaml` | serving regions and chips (with candidates), PUE, WUE, utilization, overhead |
|
|
155
|
+
| `ecocost/data/regions.yaml` | grid intensity (lifecycle), mix, generation water, primary energy |
|
|
156
|
+
| `ecocost/data/hardware.yaml` | TDP, peak FLOPS, energy ratio vs H100, embodied carbon |
|
|
157
|
+
| `ecocost/data/sources.yaml` | every cited source, with its licence and terms of use |
|
|
158
|
+
|
|
159
|
+
Every value has a `source`, a `tier` and an [OKF v0.2](https://github.com/GoogleCloudPlatform/open-knowledge-format/blob/main/SPEC.md)
|
|
160
|
+
provenance block. To correct or add a figure, see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
161
|
+
|
|
162
|
+
## Development
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
poetry install
|
|
166
|
+
poetry run pytest -q
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## License
|
|
170
|
+
|
|
171
|
+
Code: Apache-2.0. The data draws on Ember and Our World in Data (CC BY 4.0),
|
|
172
|
+
EPA eGRID, WRI, EcoLogits (MPL-2.0) and ML.ENERGY, among others; see
|
|
173
|
+
[NOTICE](NOTICE) for attribution and each source's terms.
|
|
174
|
+
|
ecocost-0.1.0/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# ecocost
|
|
2
|
+
|
|
3
|
+
```bash
|
|
4
|
+
pip install ecocost
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Per-request carbon, energy and water estimates for AI inference, each with a
|
|
8
|
+
likely range and a confidence label computed from the evidence behind it.
|
|
9
|
+
Every input is sourced and tiered, and the knowledge base in `ecocost/data/`
|
|
10
|
+
is open to pull requests from providers, hardware makers and researchers.
|
|
11
|
+
|
|
12
|
+
Maintained by [Gooey.AI](https://gooey.ai). Pure Python; the only dependency
|
|
13
|
+
is PyYAML.
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from ecocost import estimate
|
|
19
|
+
|
|
20
|
+
r = estimate(
|
|
21
|
+
"gpt-oss-120b",
|
|
22
|
+
provider="nscale",
|
|
23
|
+
input_tokens=800,
|
|
24
|
+
output_tokens=300,
|
|
25
|
+
)
|
|
26
|
+
r["carbon"] # {"unit": "gCO2e", "value": 0.0018, "min": ..., "max": ..., "worst_case": {...}}
|
|
27
|
+
r["confidence"] # {"level": "low", "ratio": 16.6, "reasons": ["wue_assumed", ...]}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Model ids are matched through aliases, so provider-specific ids such as
|
|
31
|
+
`accounts/fireworks/models/gpt-oss-120b` resolve to the same record. A model
|
|
32
|
+
that isn't in the knowledge base raises `UnknownModelError`, which suggests
|
|
33
|
+
close matches and links to [adding it](CONTRIBUTING.md#adding-a-model). Ids
|
|
34
|
+
are matched ignoring case.
|
|
35
|
+
|
|
36
|
+
## Provider ids
|
|
37
|
+
|
|
38
|
+
Who serves the request is taken, in order, from:
|
|
39
|
+
|
|
40
|
+
1. `provider`: one of these ids. An unrecognised id raises
|
|
41
|
+
`UnknownProviderError`, so a typo can't silently estimate the wrong site.
|
|
42
|
+
2. `base_url` (optional): the API endpoint you called. Its host is matched
|
|
43
|
+
against the hosts below; an unlisted host is ignored.
|
|
44
|
+
3. For a closed model, its vendor's own API (`claude-*` → `anthropic`,
|
|
45
|
+
`gpt-*` → `openai`, …), flagged `provider_inferred_from_model`.
|
|
46
|
+
4. Otherwise wide US defaults, flagged `provider_unknown_fallback`.
|
|
47
|
+
|
|
48
|
+
| id | provider | API hosts |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| `fireworks` | Fireworks AI | `api.fireworks.ai` |
|
|
51
|
+
| `nscale` | nScale | `inference.api.nscale.com` |
|
|
52
|
+
| `openai` | OpenAI (direct API) | `api.openai.com` |
|
|
53
|
+
| `anthropic` | Anthropic (direct API) | `api.anthropic.com` |
|
|
54
|
+
| `google-vertex` | Google Vertex AI (us-central1) | `aiplatform.googleapis.com` |
|
|
55
|
+
| `vercel-gateway` | Vercel AI Gateway | `ai-gateway.vercel.sh` |
|
|
56
|
+
| `mistral` | Mistral AI (La Plateforme) | `api.mistral.ai` |
|
|
57
|
+
| `alibaba-sg` | Alibaba Cloud Model Studio (Singapore) | `.ap-southeast-1.maas.aliyuncs.com` |
|
|
58
|
+
| `modal` | Modal | `.modal.run` |
|
|
59
|
+
| `zai` | Z.ai (Zhipu) | `api.z.ai` |
|
|
60
|
+
| `sarvam` | Sarvam AI (Yotta NM1, Navi Mumbai) | `api.sarvam.ai` |
|
|
61
|
+
| `fal` | fal.ai | — |
|
|
62
|
+
| `novita` | Novita AI | `api.novita.ai` |
|
|
63
|
+
| `meta` | Meta AI API | `api.meta.ai` |
|
|
64
|
+
| `dhenu` | KissanAI Dhenu | `apibeta.dhenu.ai` |
|
|
65
|
+
| `sea-lion` | AI Singapore SEA-LION API | `api.sea-lion.ai` |
|
|
66
|
+
| `unknown-us` | Unknown provider (US default) | — |
|
|
67
|
+
|
|
68
|
+
To add a provider, see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
69
|
+
|
|
70
|
+
## API
|
|
71
|
+
|
|
72
|
+
One function:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
estimate(model, *, provider=None, base_url=None, input_tokens=0, output_tokens=0, cached_input_tokens=0, timestamp=None) -> EstimateResult
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Full parameters, every output field, reason codes, errors and fallbacks, and versioning:
|
|
79
|
+
**[API.md](API.md)**.
|
|
80
|
+
|
|
81
|
+
### Output
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
model, provider, tokens
|
|
85
|
+
carbon gCO2e: value, min, max, worst_case {min, max}
|
|
86
|
+
energy Wh at the meter, primary_energy_mj
|
|
87
|
+
water mL: total, on_site (cooling, WUE), generation (off-site)
|
|
88
|
+
confidence level, ratio (max/min), reasons (every assumed input)
|
|
89
|
+
electricity region, country, gco2e_per_kwh (+ range), mix, dataset_year
|
|
90
|
+
breakdown h100_seconds, usage (operational) and embodied gCO2e
|
|
91
|
+
assumptions active params, chips, chip energy ratio, PUE, utilization, overhead, method_version
|
|
92
|
+
provenance trust, status, generated_by, stale for model, provider, region, hardware
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`min`/`max` is the likely range; `worst_case` puts every input at its extreme
|
|
96
|
+
at once. Cache results against `assumptions.method_version`.
|
|
97
|
+
|
|
98
|
+
## How it works
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
tokens ─▶ FLOPs ─▶ H100-seconds ─▶ Wh at the meter ─▶ gCO2e operational + gCO2e embodied
|
|
102
|
+
─▶ mL water on-site + off-site
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Location-based, lifecycle grid intensity, embodied carbon included, usage
|
|
106
|
+
only. See [METHODOLOGY.md](METHODOLOGY.md) for the pipeline, the sources behind
|
|
107
|
+
every default, how ranges and confidence are computed, calibration against
|
|
108
|
+
published measurements, and the known gaps.
|
|
109
|
+
|
|
110
|
+
## Confidence
|
|
111
|
+
|
|
112
|
+
Every input carries an evidence tier: 1 published by the primary source, 2
|
|
113
|
+
derived or proxy, 3 assumed. The confidence label is computed from the width of
|
|
114
|
+
the likely carbon range (under 2x high, under 5x medium, otherwise low), never
|
|
115
|
+
typed in. `reasons` lists each assumed input, so it doubles as the list of
|
|
116
|
+
figures a provider could publish to tighten its estimates.
|
|
117
|
+
|
|
118
|
+
## Data
|
|
119
|
+
|
|
120
|
+
| File | What |
|
|
121
|
+
|---|---|
|
|
122
|
+
| `ecocost/data/models.yaml` | active and total parameters, measured energy, aliases |
|
|
123
|
+
| `ecocost/data/providers.yaml` | serving regions and chips (with candidates), PUE, WUE, utilization, overhead |
|
|
124
|
+
| `ecocost/data/regions.yaml` | grid intensity (lifecycle), mix, generation water, primary energy |
|
|
125
|
+
| `ecocost/data/hardware.yaml` | TDP, peak FLOPS, energy ratio vs H100, embodied carbon |
|
|
126
|
+
| `ecocost/data/sources.yaml` | every cited source, with its licence and terms of use |
|
|
127
|
+
|
|
128
|
+
Every value has a `source`, a `tier` and an [OKF v0.2](https://github.com/GoogleCloudPlatform/open-knowledge-format/blob/main/SPEC.md)
|
|
129
|
+
provenance block. To correct or add a figure, see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
130
|
+
|
|
131
|
+
## Development
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
poetry install
|
|
135
|
+
poetry run pytest -q
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
|
|
140
|
+
Code: Apache-2.0. The data draws on Ember and Our World in Data (CC BY 4.0),
|
|
141
|
+
EPA eGRID, WRI, EcoLogits (MPL-2.0) and ML.ENERGY, among others; see
|
|
142
|
+
[NOTICE](NOTICE) for attribution and each source's terms.
|