Order
...
API Usage

📊 API Usage

Aaia-WP includes comprehensive API usage monitoring to help you track your Gemini API consumption, optimize costs, and ensure you stay within your quota limits. This feature provides detailed analytics and insights into your chatbot’s performance.

🎯 Why Monitor API Usage?

Understanding your API consumption is crucial for:

  • Cost Control: Track estimated costs to avoid unexpected bills
  • Performance Optimization: Identify usage patterns to optimize your chatbot
  • Quota Management: Stay within Google’s free tier limits
  • Analytics Insights: Understand user engagement with your AI assistant

📈 Accessing Usage Analytics

Finding the API Usage Tab

In your WordPress dashboard, navigate to Settings > Aaia XP and click on the “API Usage” tab. This dedicated section provides comprehensive monitoring tools and detailed analytics about your API consumption.

Real-Time Data Updates

The usage monitor automatically tracks every API request made by your chatbot, including request counts, estimated token usage, and calculated costs based on current Gemini pricing models.

💡 Understanding Usage Metrics

Summary Cards

The dashboard displays three key metrics for the last 30 days:

Requests: Total number of API calls made to Gemini. Each user message typically generates one request, though complex interactions may require multiple calls.

Estimated Tokens: Approximate token consumption based on message length and system instructions. Tokens represent the “computational units” that Gemini uses to process your requests.

Estimated Cost: Calculated expenses based on Google’s current pricing structure. This helps you understand the financial impact of your chatbot usage.

📊 Visual Analytics

Daily Request Charts

Interactive charts show your daily request patterns, helping you identify:

  • Peak Usage Times: When your users are most active
  • Traffic Patterns: Weekly and monthly trends
  • Spike Detection: Unusual activity that might indicate bot traffic or viral content

Cost Visualization

Daily cost charts provide financial insights by displaying:

  • Daily Spending: Track costs on a day-by-day basis
  • Cost Trends: Identify increasing or decreasing usage patterns
  • Budget Planning: Project future expenses based on current usage

📋 Detailed Usage Tables

Daily Breakdown

The detailed table shows:

  • Date: Specific day of usage
  • Requests: Number of API calls for that day
  • Estimated Tokens: Token consumption for the day
  • Estimated Cost: Associated costs in USD

This granular data helps you understand exactly when and how your API quota is being consumed.

⚙️ Optimization Features

Context Cache Integration

When Context Cache is enabled in API Settings, you’ll see significant reductions in token consumption. The cache stores system instructions and frequently used context for 24 hours, reducing:

  • Repeat Token Usage: System instructions don’t need to be sent with every request
  • Context Efficiency: Conversation context is cached and reused
  • Cost Savings: Up to 60% reduction in token consumption for active sites

Session Management Benefits

With Session Management enabled (Beta feature), you can achieve even greater savings:

  • Short Conversations (5-10 messages): ~30% token reduction
  • Medium Conversations (10-30 messages): ~70% token reduction
  • Long Conversations (30+ messages): ~90% token reduction

🔄 Data Management

Refresh Functionality

Use the “Refresh Data” button to:

  • Update Statistics: Get the latest usage information
  • Sync Records: Ensure accuracy between local tracking and actual usage
  • Real-Time Monitoring: Check current consumption levels

Data Retention

Usage data is stored locally in your WordPress database and automatically:

  • Maintains 30-Day History: Keeps detailed records for analysis
  • Auto-Cleanup: Removes older data to prevent database bloat
  • Privacy Protection: All data stays on your server

🚨 Usage Alerts and Limits

Understanding Google’s Limits

Google’s free tier provides:

  • 15 requests per minute: Rate limiting for API calls
  • 1,500 requests per day: Daily quota for free accounts
  • Generous Token Allowance: Sufficient for most small to medium websites

Monitoring Recommendations

Daily Checks: Review usage patterns regularly to identify trends

Weekly Analysis: Look for unusual spikes or decreases in activity

Monthly Planning: Use historical data to project future needs

Alert Setup: Consider external monitoring if you approach quota limits

💰 Cost Optimization Strategies

Enable Context Caching

Activate Context Cache in API Settings to reduce token consumption by up to 60% for sites with consistent system instructions and page context.

Optimize System Instructions

Keep your system instructions concise but effective. Longer instructions consume more tokens with each request.

Configure Session Management

Enable the beta Session Management feature for dramatic token savings on sites with longer conversations.

Review Assistant Configuration

Regularly assess your chatbot’s settings to ensure optimal performance without unnecessary token consumption.

🔍 Troubleshooting Usage Issues

High Usage Concerns

If you notice unexpectedly high usage:

Check for Bot Traffic: Automated requests can inflate usage Review System Instructions: Long instructions increase token consumption Analyze User Patterns: Look for unusual conversation lengths Verify Rate Limiting: Ensure proper request throttling

Low Usage Analysis

Unexpectedly low usage might indicate:

Configuration Issues: Check if the chatbot is properly displayed User Experience Problems: Verify chatbot accessibility and positioning Content Relevance: Ensure your assistant provides value to visitors

🚀 What’s Next

Understanding your API usage ensures cost-effective operation while maximizing value. Continue to Session Management to learn about advanced token optimization features, or explore Page Context to understand how content integration affects consumption.