Block 1 - Fetch OpenAI Usage Data
- Type / Role
- n8n-nodes-base.httpRequest - httpRequest
- Config choices
- Version 4.3
This workflow is provided as-is. Please review and test before using in production.
Who's this for Finance teams, AI developers, product managers, and business owners who need to monitor and control OpenAI API costs across different models and projects. If you're using GPT 4, GPT ...
n8n-nodes-base.httprequest, n8n-nodes-base.code, n8n-nodes-base.googlesheets, n8n-nodes-base.googledrive, n8n-nodes-base.gmail, n8n-nodes-base.stickynote, n8n-nodes-base.scheduletrigger
This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Patrick Campbell .
Original n8n.io sourceWho's this for Finance teams, AI developers, product managers, and business owners who need to monitor and control OpenAI API costs across different models and projects. If you're using GPT-4, GPT-3.5, or other OpenAI models and want to track spending patterns, identify cost optimization opportunities, and generate stakeholder reports, this workflow is for you.
What it does This workflow automatically tracks your OpenAI token usage on a monthly basis, breaks down costs by model and date, stores the data in Google Sheets with automatic cost calculations, and emails PDF reports to stakeholders. It transforms raw API usage data into actionable insights, helping you understand which models are driving costs, identify usage trends over time, and maintain budget accountability. The workflow runs completely hands-free once configured, generating comprehensive monthly reports without manual intervention.
How it works The workflow executes automatically on the 5th of each month and follows these steps:
Creates a new Google Sheet from your template with the naming format "Token_Tracking_[Month]_[Year]" Fetches the previous month's OpenAI usage data via the OpenAI Admin API Transforms raw API responses into a clean daily breakdown showing usage by model Appends the data to Google Sheets with columns for date, model, input tokens, and output tokens Your Google Sheets formulas automatically calculate costs based on OpenAI's pricing for each model Exports the completed report as both PDF and Excel formats Emails the PDF report to designated stakeholders with a summary message Archives the Excel file to Google Drive for long-term recordkeeping and historical analysis
Requirements
OpenAI account with Admin API access (required to access organization usage endpoints) Google Sheets template pre-configured with cost calculation formulas Google Drive for report storage and archiving Gmail account for sending email notifications n8n instance (self-hosted or cloud) with the following credentials configured:
OpenAI API credentials Google Sheets OAuth2 Google Drive OAuth2 Gmail OAuth2
Setup instructions
Include pricing formulas based on OpenAI's current pricing. Add summary calculations at the bottom to total costs by model.
2. Configure n8n credentials In your n8n instance, set up credentials for:
OpenAI API (you'll need admin access to your organization) Google Sheets (OAuth2 connection) Google Drive (OAuth2 connection) Gmail (OAuth2 connection)
3. Update workflow placeholders Replace the following placeholders in the workflow:
your-api-key-id: Your OpenAI API key ID (find this in your OpenAI dashboard) your-template-file-id: The ID of your Google Sheets template your-archive-folder-id: The Google Drive folder ID where reports should be archived [email protected]: The email address that should receive monthly reports
4. Assign credentials to nodes Open each node that requires credentials and select the appropriate credential from your configured options:
"Fetch OpenAI Usage Data" → OpenAI API credential "Append Data to Google Sheet" → Google Sheets credential "Create Monthly Report from Template" → Google Drive credential "Export Sheet as Excel" → Google Drive credential "Export Sheet as PDF for Email" → Google Drive credential "Archive Report to Drive" → Google Drive credential "Email Report to Stakeholder" → Gmail credential
5. Test the workflow Before enabling the schedule, manually execute the workflow to ensure:
The template copies successfully OpenAI data fetches correctly Data appends to the sheet properly PDF and Excel exports work Email sends successfully File archives to the correct folder
6. Enable the schedule Once testing is complete, activate the workflow. It will run automatically on the 5th of each month.
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.
| Workflow | Track monthly OpenAI token usage with Google Sheets and Gmail reports |
|---|---|
| Complexity | intermediate |
| Nodes | 13 |
| Categories | Document Extraction |
| Author | Patrick Campbell |
| Published | 12 Jan 2026 |
Use the JSON export at /data/workflows/12646/12646.json as the source template for this automation.
Open n8n, import the downloaded JSON, and review each node before activating the workflow.
Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.
Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.
Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.
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.
Who's this for Finance teams, AI developers, product managers, and business owners who need to monitor and control OpenAI API costs across different models and projects. If you're using GPT 4, GPT ...
Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.
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.