Accounting & Finance
Automatically Track Token Usage with Custom Code Tool
Automates CV parsing from PDF uploads to structured JSON via AI (OpenAI), tracks token usage/costs in Google Sheets, and generates monthly invoices via Gmail for client billing.
Built · ~7.5 hours saved per week
Businesses or teams that provide AI-powered services like CV parsing to clients and need to monitor and bill for AI usage.
Users upload CV PDFs via a form. AI extracts data into JSON. It tracks OpenAI token usage and costs per request, logs to Google Sheets. At month-end, it sums usage for a client and emails an invoice.
Import into self-hosted n8n. Add credentials for Google Sheets, Gmail. Set OpenAI API key in the Custom LLM code. Connect the Google Sheets tool to the code node. Activate the workflow.
Self-hosted n8n (Langchain nodes required). OpenAI API key. Google Sheets and Gmail accounts.
Change the JSON schema for different data extraction. Swap OpenAI model or costs. Add more clients by adjusting client\_id. Integrate with other billing tools.
Key Technologies: n8n Workflow Automation,Langchain Code Node,OpenAI GPT-4o-mini,Google Sheets,Gmail,Form Trigger
Automation Value: Automates AI service delivery from PDF upload to structured output, reducing manual data entry. Tracks exact AI costs per client automatically, enabling accurate billing without extra tools. Generates and sends monthly invoices based on real usage, saving time on accounting. Provides insights into client AI consumption for better budgeting and pricing.
Best Practices: Use custom Langchain code nodes for deep integration and tracking in self-hosted n8n. Hardcode API keys securely in code nodes, but consider environment variables for production. Separate service delivery from billing logic for maintainability. Filter and aggregate data before actions to optimize performance. Document workflows with sticky notes for team collaboration. Test with real PDFs to ensure schema matches extraction needs.
Tags: Operations Automations, Reports & Analytics, n8n
Integrations: Google Sheets, Code, Schedule, Email