Skip to main content

Track OpenAI Admin API usage and costs automatically with Google Sheets

Workflow preview

Workflow preview
100%
Track OpenAI Admin API usage and costs automatically with Google Sheets preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

This workflow aims to help you and your team track your expenses with OpenAI It automatically collects your OpenAI organization’s API usage and cost data every few days and saves it to a ready to u...

Best for

  • Document Extraction automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.scheduletrigger, n8n-nodes-base.httprequest, n8n-nodes-base.removeduplicates, n8n-nodes-base.stickynote, n8n-nodes-base.set, n8n-nodes-base.code, n8n-nodes-base.merge, n8n-nodes-base.splitout

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Agent Studio.

Original n8n.io source

1.1 Workflow description

Title
Track OpenAI Admin API usage and costs automatically with Google Sheets
Workflow name
Track OpenAI Admin API usage and costs automatically with Google Sheets

Overview

This workflow aims to help you and your team track your expenses with OpenAI It automatically collects your OpenAI organization’s API usage and cost data every few days and saves it to a ready-to-use Google Sheets template. It pulls detailed metrics for every project and API key, including token usage, model breakdowns, and costs per line item, making it easy for your team to analyze and track spend over time!

Who is it for

  • Finance or ops teams tracking AI usage and spend
  • Data/analytics teams needing detailed project-level breakdowns
  • Technical leads or admins managing OpenAI organization usage and cost
  • Anyone needing a simple audit trail or historical record of OpenAI API activity

How to get started

How it works

  1. Trigger: The workflow runs automatically on a schedule (every 3 days by default, but you can adjust).
  2. Fetch Data: Calls OpenAI’s Admin API to get all token usage and cost details for the reporting window.
  3. Enrich Data: Resolves project names and API key names for clarity in reports.
  4. Write to Sheets: Appends new usage and cost data to your Google Sheet, with one row per project/key/period.

Google Sheets Template

Notes

  • All data is appended, so your sheet keeps historical records. But ⚠️ if you run the workflow manually or change the schedule, you could end up with duplicated rows
  • API key and project enrichment makes reports easier to read.
  • You can adapt the workflow to save results anywhere: BigQuery, Airtable, DB, or even another spreadsheet.
  • Easy to change schedule or reporting window to fit your team’s needs.

Extra

  • Depending on your internal processes, you could also generate monthly files and automatically send the report to your finance team via email or Slack, for example. The possibilities are endless!
  • Note that we intended to do the same with Anthropic and Gemini via API and n8n built-in methods. At this stage, it is not possible to do it, but it could probably be done using Browser Agents!

Service

If you need help implementing the template or modifying it, just reach out 💌

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Schedule Trigger

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 2 - OpenAI Admin - get token usage

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 3 - OpenAI Admin - Get cost

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 4 - Remove Duplicates

Type / Role
n8n-nodes-base.removeDuplicates - removeDuplicates
Config choices
Version 2

Block 5 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - Set api_key and project ids

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 7 - Set api_key id and name

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 8 - Add api_key name to token usage

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 9 - Get project_ids

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 10 - Merge token, usage, projects

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 11 - Merge token and usage

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 12 - Structure usage, cost, projects

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 13 - Split Out api_key and project

Type / Role
n8n-nodes-base.splitOut - splitOut
Config choices
Version 1

Block 14 - Split Out Usage

Type / Role
n8n-nodes-base.splitOut - splitOut
Config choices
Version 1

Block 15 - Split Out Cost

Type / Role
n8n-nodes-base.splitOut - splitOut
Config choices
Version 1

Block 16 - Split Out Usage Results

Type / Role
n8n-nodes-base.splitOut - splitOut
Config choices
Version 1

Block 17 - Split Out Cost results

Type / Role
n8n-nodes-base.splitOut - splitOut
Config choices
Version 1

Block 18 - Structure Usage data

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 19 - Structure Cost data

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 20 - Append Usage to GSheets

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.6

Block 21 - Append Cost to GSheets

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.6

Block 22 - Set Usage data for Gsheets

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 23 - Set Cost data for Gsheets

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 24 - Sticky Note12

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Showing the first 24 of 40 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Track OpenAI Admin API usage and costs automatically with Google Sheets
Complexity advanced
Nodes 40
Categories Document Extraction
Author Agent Studio
Published 14 Jul 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/6002/6002.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Track OpenAI Admin API usage and costs automatically with Google Sheets do?

This workflow aims to help you and your team track your expenses with OpenAI It automatically collects your OpenAI organization’s API usage and cost data every few days and saves it to a ready to u...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Document Extraction use case.