Skip to content

Analytics & Monitoring

UniCraft provides comprehensive analytics and monitoring capabilities to help you understand and optimize your AI usage patterns.

The analytics dashboard provides real-time insights into your AI usage:

  • Total Requests: Number of API calls made
  • Total Cost: Cumulative spending across all providers
  • Average Response Time: Mean response time across all requests
  • Success Rate: Percentage of successful requests
  • Active Models: Currently used AI models
  • Hourly, daily, weekly, and monthly views
  • Trend analysis and forecasting
  • Seasonal pattern detection

Analyze your request patterns to optimize usage:

const analytics = await unicraft.analytics.getUsage({
start_date: "2024-01-01",
end_date: "2024-01-31",
group_by: "day",
metrics: ["requests", "cost", "tokens"],
});

Compare performance across different providers:

  • Response times
  • Cost per request
  • Success rates
  • Model availability

Track performance metrics for each model:

  • Average response time
  • Token usage
  • Cost efficiency
  • Quality scores

Monitor your spending patterns:

  • Daily, weekly, monthly cost trends
  • Cost per request analysis
  • Provider cost comparison
  • Budget vs. actual spending

Get recommendations for cost optimization:

  • Underutilized models
  • Expensive request patterns
  • Alternative model suggestions
  • Batch processing opportunities

Set and monitor spending budgets:

const budget = await unicraft.budgets.create({
name: "Monthly AI Budget",
amount: 1000,
period: "monthly",
alerts: [0.8, 0.9, 1.0], // Alert at 80%, 90%, and 100%
});

Monitor response times across providers and models:

  • Average response time
  • 95th percentile response time
  • Response time distribution
  • Performance trends

Track and analyze errors:

  • Error rate by provider
  • Error type classification
  • Error trend analysis
  • Root cause analysis

Monitor provider availability:

  • Uptime statistics
  • Service health checks
  • Outage detection
  • Recovery time tracking

Create custom dashboards for specific use cases:

const dashboard = await unicraft.dashboards.create({
name: "Production Monitoring",
widgets: [
{
type: "line_chart",
metric: "response_time",
provider: "openai",
},
{
type: "gauge",
metric: "success_rate",
threshold: 0.95,
},
],
});

Set up custom alerts for important metrics:

const alert = await unicraft.alerts.create({
name: "High Error Rate",
condition: "error_rate > 0.05",
duration: "5m",
channels: ["email", "slack"],
});

Schedule automated reports:

  • Daily usage summaries
  • Weekly cost reports
  • Monthly performance reviews
  • Custom report templates

Export data in various formats:

  • CSV for spreadsheet analysis
  • JSON for programmatic access
  • PDF for presentations
  • Real-time API access

Access analytics data programmatically:

// Get usage data
const usage = await unicraft.analytics.getUsage({
start_date: "2024-01-01",
end_date: "2024-01-31",
});
// Get cost data
const costs = await unicraft.analytics.getCosts({
group_by: "provider",
include_breakdown: true,
});
// Get performance data
const performance = await unicraft.analytics.getPerformance({
metrics: ["response_time", "success_rate"],
time_range: "7d",
});

Receive real-time notifications via webhooks:

const webhook = await unicraft.webhooks.create({
url: "https://your-app.com/webhooks/unicraft",
events: ["request.completed", "error.occurred", "budget.exceeded"],
});

Integrate with popular monitoring tools:

  • Grafana dashboards
  • DataDog metrics
  • New Relic monitoring
  • Custom monitoring solutions
  1. Regular Monitoring: Check your analytics dashboard regularly
  2. Set Up Alerts: Configure alerts for important metrics
  3. Analyze Trends: Look for patterns in your usage data
  4. Optimize Based on Data: Use analytics insights to optimize your AI usage
  5. Budget Planning: Use historical data to plan future budgets