exploring-llm-costs

Aggregate LLM spend and token metrics from PostHog events.

75|14|Updated Feb 18, 2026
One-click install
npx skills add https://github.com/PostHog/ai-plugin --skill exploring-llm-costs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: exploring-llm-costs
Source: https://github.com/PostHog/ai-plugin/tree/main/skills/exploring-llm-costs
Command: npx skills add https://github.com/PostHog/ai-plugin --skill exploring-llm-costs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Analyze and optimize LLM costs across PostHog analytics, enabling you to quantify spend, identify waste, and drive cost-efficient usage of AI features.

Core Features & Use Cases

  • Cost breakdowns by model, provider, user, and trace
  • Token and cache-efficiency analysis
  • Materialization of cost insights into dashboards and alerts
  • Use case: identify the most expensive models or traces and surface actionable optimizations

Quick Start

Ask it to surface total LLM spend by time and model, generate a cost breakdown, and create shareable insights.

Frequently Asked Questions about exploring-llm-costs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I analyze LLM costs and token usage from PostHog traces?

Analyze LLM costs in PostHog by aggregating total spend, per-model and per-provider breakdowns, token usage, and cache metrics from $ai_generation and $ai_embedding events. It reads cost properties like $ai_total_cost_usd and $ai_model to quantify spend and identify waste.

Can I break down LLM spending by user, model, and provider in PostHog?

Yes, you can break down LLM spending by user, model, provider, and trace in PostHog. The analysis aggregates cost data from ingested $ai_generation events to surface actionable insights and identify your most expensive models or individual traces.

What PostHog events and properties are required to track LLM cost analytics?

Tracking LLM cost analytics requires PostHog ingestion of $ai_generation and $ai_embedding events with properties like $ai_total_cost_usd, $ai_model, $ai_provider, $ai_input_tokens, and $ai_output_tokens. These fields enable detailed spend aggregation and cache-efficiency analysis.

How do I create dashboards and alerts for LLM cost spikes in PostHog?

Create dashboards and alerts for LLM cost spikes by materializing the aggregated spend and token usage insights into PostHog monitoring views. You can generate shareable cost breakdowns and set up alerts based on per-model or per-user spending thresholds.

Does this approach work for optimizing token usage and cache efficiency?

Yes, this approach works for optimizing token usage and cache efficiency by analyzing $ai_input_tokens, $ai_output_tokens, and related cache metrics. It quantifies spend across AI features to help you identify waste and drive cost-efficient usage patterns.