ecologits.estimations
¶
text_impacts(model_name, input_tokens, output_tokens, *, provider=None, cache_read_tokens=None, cache_write_tokens=None, datacenter_location=None, datacenter_pue=None, datacenter_wue=None, request_latency=None)
¶
Estimate the environmental impacts of a text generation request.
Uses the same model repository and calculations as the provider integrations, without making an API request. Generation latency is estimated using registered throughput information when available, otherwise using the latency regression, and capped by request_latency when supplied. Input tokens and prompt caching are accepted and validated in preparation for future methodology; they do not affect estimates yet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
EcoLogits model ID: the developer's namespace and the model name, such as "openai/gpt-6-luna" or "zai/glm-5.2". |
required |
input_tokens
|
int
|
Total input tokens, including tokens read from or written to the provider's prompt cache. Must be a non-negative integer. Currently does not affect estimates. |
required |
output_tokens
|
int
|
Number of generated tokens, including reasoning tokens when applicable. Must be a non-negative integer. |
required |
provider
|
str | None
|
Hosting service: "openai", "anthropic", "cohere", "google" or "mistralai". When omitted, the model developer's own API is used if registered. Hugging Face is not supported yet. |
None
|
cache_read_tokens
|
int | None
|
Input tokens whose computed state was reused from the provider's prompt cache. A subset of input_tokens. None means unknown or unreported; zero means no cache reads. Currently does not affect estimates. |
None
|
cache_write_tokens
|
int | None
|
Input tokens written to the provider's prompt cache by this request. A subset of input_tokens. None means unknown or unreported; zero means no cache writes. Currently does not affect estimates. |
None
|
datacenter_location
|
str | None
|
Electricity mix zone, using ISO 3166-1 alpha-3 codes or an aggregate zone such as "WOR". Uses the provider's default location when omitted or None. |
None
|
datacenter_pue
|
float | RangeValue | None
|
Power Usage Effectiveness of the datacenter. Values must be finite and at least 1. Uses the provider default when None. |
None
|
datacenter_wue
|
float | RangeValue | None
|
Water Usage Effectiveness of the datacenter in L/kWh. Values must be finite and at least 0. Uses the provider default when None. |
None
|
request_latency
|
float | None
|
Optional measured request latency in seconds. Improves precision when generation was faster than estimated: the estimated generation latency is capped by this value. Must be finite and positive. Estimates latency only when None. |
None
|
Returns:
| Type | Description |
|---|---|
ImpactsOutput
|
Total, usage, and embodied impacts with model and electricity mix warnings. Unknown models, providers, or zones |
ImpactsOutput
|
return errors in the result. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a token count is not a non-negative integer, or the sum of known cache reads and writes exceeds input_tokens, or a datacenter PUE or WUE override is invalid, or request_latency is not a finite positive number. |
Source code in ecologits/estimations/text.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
video_impacts(model_name, resolution, duration, with_audio=True, datacenter_location=None, datacenter_pue=None, datacenter_wue=None)
¶
Determines the impacts of generating a video based on the specified model, resolution, and duration. Calculates and returns the detailed impacts related to computational resources, energy consumption, and data processing associated with the generation task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
The name of the model selected for video generation. |
required |
resolution
|
str
|
The resolution of the video to be generated, typically provided as a string (e.g., "1920x1080" or "1080p"). |
required |
duration
|
float
|
The length of the video to generate, specified in seconds. |
required |
with_audio
|
bool
|
Whether the video generation also includes audio. |
True
|
datacenter_location
|
str | None
|
ISO 3166-1 alpha-3 code of the datacenter location. Uses the provider default when omitted or None; pass "WOR" for the world mix. |
None
|
datacenter_pue
|
float | RangeValue | None
|
Power Usage Effectiveness of the datacenter. Uses the provider default when omitted. |
None
|
datacenter_wue
|
float | RangeValue | None
|
Water Usage Effectiveness of the datacenter in L/kWh. Uses the provider default when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
ImpactsOutput
|
An ImpactsOutput object containing details of the computed impacts. |
Source code in ecologits/estimations/video.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |