Automated OpenAI API Cost & Usage Tracker to Google Sheets
detail.loadingPreview
This workflow automatically retrieves and organizes your OpenAI API token usage and cost data. It processes this information, linking it to specific API keys and projects, and then seamlessly exports it to Google Sheets for easy monitoring and analysis.
About This Workflow
This robust n8n workflow provides a comprehensive solution for managing your OpenAI API expenses. Scheduled to run periodically, it intelligently queries the OpenAI API to gather detailed token usage and associated cost data. The workflow then meticulously processes this raw data, identifying individual API keys and projects, and merging all relevant information. By structuring this data, it offers clear insights into consumption patterns and financial outlay. Finally, it automates the export of this organized usage and cost information into designated Google Sheets, empowering you with an effortless, real-time overview of your AI infrastructure spend.
Key Features
- Scheduled Monitoring: Automatically fetch OpenAI API usage and cost data at regular intervals.
- Granular Data Collection: Retrieve token usage and associated costs for your OpenAI API keys and projects.
- Intelligent Data Structuring: Processes, merges, and cleanses data, linking usage and costs to specific API keys and project IDs.
- Automated Google Sheets Export: Seamlessly append organized usage and cost reports directly to your Google Sheets.
- Customizable Data Processing: Utilize code nodes for flexible data transformation and enrichment.
How To Use
- Configure Schedule Trigger: Set your desired frequency for fetching data (e.g., daily, weekly).
- Set OpenAI API Credentials: Update the
Set api_key and project idsnode with your OpenAI API keys and any specific project IDs you wish to track. Ensure your HTTP Request nodes (OpenAI Admin - get token usage,OpenAI Admin - Get cost) are correctly configured with credentials for OpenAI API access. - Customize Data Processing (Optional): If needed, modify the
Codenodes (Add api_key name to token usage,Get project_ids) to tailor data extraction or enrichment logic. - Connect Google Sheets: Authenticate the
Append Usage to GSheetsandAppend Cost to GSheetsnodes with your Google account. Specify the spreadsheet IDs and sheet names where you want the usage and cost data to be appended. - Activate Workflow: Enable the workflow to start automatically tracking and reporting your OpenAI API usage and costs.
Apps Used
Workflow JSON
{
"id": "8cbcec86-c41b-47f3-8071-25e6c341e51c",
"name": "Automated OpenAI API Cost & Usage Tracker to Google Sheets",
"nodes": 24,
"category": "Operations",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: 8cbcec86-c41b...
About the Author
N8N_Community_Pick
Curator
Hand-picked high quality workflows from the global community.
Statistics
Related Workflows
Discover more workflows you might like
Google Sheets to Icypeas: Automated Bulk Domain Scanning
This workflow streamlines the process of performing bulk domain scans by integrating your Google Sheets data directly with the Icypeas platform. Automate the submission of company names from your spreadsheet to Icypeas for comprehensive domain information, saving valuable time and effort.
Dynamic Bible Scripture Retrieval Workflow
This n8n workflow provides a robust solution for dynamically querying and retrieving Bible scriptures from the getBible.net API. It takes structured JSON input for references, translation, and version, returning the corresponding passages in a standardized API response format.
Instant WooCommerce Order Notifications via Telegram
When a new order is placed on your WooCommerce store, instantly receive detailed notifications directly to your Telegram chat. Stay on top of your e-commerce operations with real-time alerts, including order specifics and a direct link to view the order.