Skip to main content

GET /api/usage - Usage Statistics

Track your AI API usage, costs, and performance metrics.

Endpoint

GET https://regpilot.dev/api/usage?projectId={project_id}

Authentication

Required: X-API-Key header

Query Parameters

ParameterTypeRequiredDescription
projectIdStringYesYour project ID
periodStringNoday, week, month (default: month)

Response

{
  budget: {
    limit: number,        // Credit limit ($)
    used: number,         // Credits used ($)
    remaining: number     // Credits remaining ($)
  },
  cache: {
    hits: number,         // Cache hits
    misses: number,       // Cache misses
    hitRate: number       // Hit rate (0-100%)
  },
  models: {
    [model: string]: {
      requests: number,
      tokens: number,
      cost: number
    }
  },
  period: {
    start: string,        // ISO date
    end: string          // ISO date
  }
}

Example

const response = await fetch(
  `https://regpilot.dev/api/usage?projectId=${projectId}`,
  {
    headers: {
      'X-API-Key': process.env.REGPILOT_API_KEY!
    }
  }
);

const stats = await response.json();

console.log(`Budget: $${stats.budget.used}/$${stats.budget.limit}`);
console.log(`Cache Hit Rate: ${stats.cache.hitRate}%`);
console.log(`Savings: $${stats.cache.hits * 0.01}`); // Estimated

Back: API Reference →