What You’ll Learn
How to:- Track costs per user and feature
- Set up cost alerts before budget overruns
- Enable caching to reduce redundant API costs
- Analyze cost trends over time
Prerequisites
- Helicone API key (get one here)
- An LLM application with API calls
- 5 minutes to implement tracking
Step 1: Add Cost Tracking Headers
Start by tagging your requests with metadata for cost segmentation.Key Headers:
Helicone-User-Id: Track costs per user for unit economicsHelicone-Property-Feature: Identify which features drive costsHelicone-Property-Environment: Separate dev/staging/production costsHelicone-Property-UserTier: Compare free vs. paid user costs
Step 2: Organize Multi-Step Workflows
For complex workflows (like AI agents), use sessions to track the total cost of completing a task.Step 3: View Cost Analytics
Dashboard Overview
Navigate to your Helicone dashboard to see:
- Total costs (today, this week, this month)
- Cost trends over time
- Top cost-driving models and features
- Cost per user breakdown
Session Cost Analysis
View Sessions to see:
- Average cost per workflow type
- Cost distribution across steps
- Expensive outliers to investigate
Step 4: Set Up Cost Alerts
Preventing budget overruns before they happen.Create Cost Alert
- Click “Create Alert”
- Select Cost as the metric
- Set your threshold (e.g., $100/day)
- Choose time window (e.g., 1 day)
- Add filters (optional):
- Environment = “production” (exclude dev costs)
- Feature = “document-analysis” (monitor specific features)
Configure Notifications
Add notification channels:
- Email:
[email protected] - Slack:
#alertschannel
Step 5: Enable Caching for Cost Reduction
Cache repetitive requests to eliminate redundant API costs.Best caching opportunities:
- FAQ and support responses
- Static content generation
- Development/testing environments
- Repeated queries with identical inputs
Expected Results
After implementing cost tracking:Week 1
Insights
- Premium users cost 120 value (3.4x ROI)
- Free users cost $28/month, unsustainable without limits
- Document analysis is most expensive feature at $0.45/session
- Caching FAQ responses saved $112 (23% hit rate)
Step 6: Analyze and Optimize
Identify Cost Drivers
Look for:
- High-cost users to potentially upgrade or limit
- Features with poor cost-to-value ratios
- Unexpected development environment costs
- Cache opportunities (repeated similar requests)
Advanced: Query Costs Programmatically
Use the Helicone API to build custom cost dashboards:Best Practices
Troubleshooting
Costs showing as $0 or 'not supported'
Costs showing as $0 or 'not supported'
Helicone calculates costs based on model detection:
- Using AI Gateway: 100% accurate costs
- Direct integration: Best-effort based on 300+ model pricing
Properties not appearing in filters
Properties not appearing in filters
Properties take a few minutes to appear in filters after first use. Ensure:
- Header format:
Helicone-Property-[Name] - Values are strings (not numbers or booleans)
- Requests are successfully logging (check dashboard)
Cost alerts not triggering
Cost alerts not triggering
Check:
- Alert threshold and time window
- Minimum request count (low traffic may not trigger)
- Filters (too restrictive may exclude all requests)
- Notification channels are configured correctly
Next Steps
Cost Tracking Guide
In-depth cost optimization strategies
User Metrics
Track per-user usage and costs
Sessions
Group requests to understand workflow costs
Alerts
Configure cost and error alerts