Tracking Usage

Monitor your API spending with LangMart's comprehensive usage tracking tools. This guide covers the usage dashboard, cost breakdowns, and optimization strategies.

Usage Dashboard

Access your usage analytics at Analytics > Usage Analytics.

Overview Metrics

The dashboard shows key metrics at a glance:

  • Total Requests - Number of API calls made
  • Success Rate - Percentage of successful requests
  • Total Tokens - Combined input and output tokens
  • Total Cost - Credits spent in the selected period
  • Average Latency - Mean response time
  • Models Used - Number of unique models accessed

Time Range Selection

View usage for different periods:

  • Last 24 Hours - Recent activity with hourly breakdown
  • Last 7 Days - Weekly view with daily breakdown
  • Last 30 Days - Monthly overview

Granularity Options

Adjust the detail level:

  • Hourly - Available for 24-hour view
  • Daily - Default for most views
  • Weekly - Aggregate weekly totals
  • Monthly - Long-term trends

Cost Breakdown by Model

See exactly which models are consuming your credits:

Top Models by Cost

A ranked list showing:

  • Model name and provider
  • Number of requests
  • Token usage (input/output)
  • Total cost
  • Percentage of total spend

Model Performance Table

Detailed metrics for each model:

Metric Description
Requests Total API calls to this model
Tokens Total tokens processed
Cost Credits spent
Avg Latency Mean response time
% of Total Share of your total spend

Time Series Charts

Visualize your usage patterns over time:

  • Requests Over Time - See request volume trends
  • Token Usage Over Time - Track token consumption
  • Cost Over Time - Monitor spending patterns

Cost Projections

Based on your usage patterns, the dashboard projects:

  • Next 7 Days - Estimated spend for coming week
  • Next 30 Days - Monthly projection
  • Daily Average - Your typical daily spend

These projections help you:

  • Plan credit purchases
  • Identify unexpected cost increases
  • Budget for upcoming periods

Latency Distribution

Understand your API performance:

  • Response time buckets - How many requests fall into each latency range
  • Average latency - Mean response time across all requests
  • Time to first token - For streaming requests

Cost Insights

Access detailed optimization recommendations at Analytics > Cost Insights.

Insight Types

The system analyzes your usage and suggests:

Model Switch Recommendations

  • Identifies expensive models
  • Suggests cheaper alternatives
  • Shows potential savings

Token Optimization

  • Flags requests with excessive tokens
  • Suggests prompt optimization
  • Identifies output length issues

Usage Pattern Analysis

  • Detects unusual spending
  • Identifies peak usage times
  • Suggests scheduling optimizations

Provider Comparison

  • Compares costs across providers
  • Shows price differences for similar models
  • Recommends cost-effective alternatives

Severity Levels

Insights are prioritized by potential impact:

  • High - Significant savings opportunity (>20% reduction possible)
  • Medium - Moderate savings available (5-20% reduction)
  • Low - Minor optimizations (< 5% reduction)

Cost Optimization Tips

Choose Models Wisely

  1. Match model to task - Don't use GPT-4 for simple formatting
  2. Test with cheaper models first - Upgrade only if needed
  3. Use model routing - Automatically select cost-effective models

Optimize Prompts

  1. Be concise - Shorter prompts cost less
  2. Use system prompts efficiently - Don't repeat instructions
  3. Set max_tokens - Limit output length when appropriate

Implement Caching

  1. Cache repeated queries - Avoid redundant API calls
  2. Use semantic caching - Cache similar requests
  3. Leverage cached input tokens - Save on repeated context

Monitor Actively

  1. Set up cost alerts - Get notified before overspending
  2. Review weekly - Check for unusual patterns
  3. Audit monthly - Deep dive into usage trends

Batch Requests

  1. Combine related queries - Reduce per-request overhead
  2. Use batch endpoints - When processing multiple items
  3. Schedule non-urgent work - Run during off-peak times

Exporting Data

Export your usage data for external analysis:

  1. Go to Analytics > Usage Analytics
  2. Set your desired date range
  3. Click Export (if available)
  4. Choose format (CSV, JSON)

Use exported data for:

  • Internal reporting
  • Budget planning
  • Compliance documentation
  • Custom analysis

API Access to Usage Data

Access usage data programmatically:

GET /api/billing/usage
GET /api/billing/usage/current
GET /api/billing/usage/by-model
GET /api/account/analytics/usage

See the API documentation for full details.