This template provides a straightforward technique to measure and raise awareness about the environmental impact of your AI automations.
By adding a simple calculation step to your workflow, you can estimate the carbon footprint (in grams of CO₂ equivalent) generated by each call to a Large Language Model.
Based on the open methodology from Ecologits.ai, this workflow empowers you to build more responsible AI applications. You can use the calculated footprint to inform your users, track your organization's impact, or simply be more mindful of the resources your workflows consume.
Who is this for?
- Environmentally-conscious developers: Build AI-powered applications with an awareness of their ecological impact.
- Businesses and organizations: Track and report on the carbon footprint of your AI usage as part of your sustainability goals.
- Any n8n user using AI: A simple and powerful snippet that can be added to almost any AI workflow to make its invisible environmental costs visible.
- Educators and advocates: Use this as a practical tool to demonstrate and discuss the real-world impact of AI technologies.
What problem does this solve?
- Makes the abstract tangible: The environmental cost of a single AI call is often overlooked. This workflow translates it into a concrete, measurable number (grams of CO₂e).
- Promotes responsible AI development: Encourages builders to consider the efficiency of their prompts and models by showing the direct impact of the generated output.
- Provides a standardized starting point: Offers a simple, transparent, and extensible method for carbon accounting in your AI workflows, based on a credible, open-source methodology.
- Facilitates transparent communication: Gives you the data needed to transparently communicate the impact of your AI features to stakeholders and users.
How it works
This template demonstrates a simple calculation snippet that you can adapt and add to your own workflows.
- Set conversion factor: A dedicated Conversion factor node at the beginning of the workflow holds the gCO₂e per token value. This makes it easy to configure.
- AI generates output: An AI node (in this example, a Basic LLM Chain) runs and produces a text output.
- Estimate token count: The Calculate gCO₂e node takes the character length of the AI's text output and divides it by 4. This provides a reasonable estimate of the number of tokens generated.
- Calculate carbon footprint: The estimated token count is then multiplied by the conversion factor defined in the first node. The result is the carbon footprint for that single AI call.
Setup
- Set your conversion factor (Critical Step):
- The default factor (
0.0612
) is for GPT-4o hosted in the US.
- Visit ecologits.ai/latest to find the specific conversion factor for your AI model and server region.
- In the Conversion factor node, replace the default value with the correct factor.
- Integrate the snippet into your workflow:
- Copy the Conversion factor and Calculate gCO₂e nodes from this template.
- Place the Conversion factor node near the start of your workflow (before your AI node).
- Place the Calculate gCO₂e node after your AI node.
- Link your AI output:
- Click on the Calculate gCO₂e node.
- In the
AI output
field, replace the expression with the output from your AI node (e.g., {{ $('My OpenAI Node').item.json.choices[0].message.content }}
). The carbon calculation will now work with your data.
- Activate your workflow. The carbon footprint will now be calculated with each execution.
Taking it further
- Improve accuracy with token counts: If your AI node (like the native OpenAI node) directly provides the number of output tokens (e.g.,
completion_tokens
), use that number instead of estimating from the text length. This will give you a more precise calculation.
- Calculate total workflow footprint: If you have multiple AI nodes, add a calculation step after each one. Then, add a final Set node at the end of your workflow to sum all the individual gCO₂e values.
- Display the impact: Add the final
AI output gCO₂e
value to your workflow's results, whether it's a Slack message, an email, or a custom dashboard, to keep the environmental impact top-of-mind.
- A note on AI agents: This estimation method is difficult to apply accurately to AI Agents at this time, as the token usage of their intermediary "thinking" steps is not yet exposed in the workflow data.