Skip to main content
To use the Scope3 API in Google Sheets, you can create a custom function that calls the API and returns the carbon footprint of AI inferences. This function can be used in any cell in your Google Sheet to calculate the carbon footprint of AI models.

Step 1: Create a custom function

Copy the following code and paste it into the script editor in your Google Sheet. To open the script editor, go to Extensions > Apps Script and paste the code into the editor.

Step 2: Use the custom function

After you’ve added the custom function to your Google Sheet, you can use it in any cell to calculate the carbon footprint of AI inferences. Set up your Google Sheet with the following columns:
  • family: The model family (e.g., ‘claude’)
  • model: The model name (e.g., ‘3.5 Sonnet’)
  • input_tokens: The number of input tokens
  • output_tokens: The number of output tokens
Then, put the custom function in the adjacent cell to calculate the carbon footprint of AI inferences. For example, if your inputs are in cells A2:C10, you can use the following formula:
The sheet should look like this, with the custom function in cell E3. Google Sheet Example