analyzing-expensive-users

Analyze top-spending AI observability users and explain their LLM cost drivers.

713|118|Updated Aug 11, 2020
One-click install
npx skills add https://github.com/PostHog/posthog-foss --skill analyzing-expensive-users
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: analyzing-expensive-users
Source: https://github.com/PostHog/posthog-foss/tree/main/products/ai_observability/skills/analyzing-expensive-users
Command: npx skills add https://github.com/PostHog/posthog-foss --skill analyzing-expensive-users

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

When AI observability bills spike, teams need to know which users drive the spend and why. This Skill ranks the most expensive users in PostHog AI observability and decomposes their costs into concrete drivers like volume, model choice, token usage, cache behavior, and retry loops.

Core Features & Use Cases

  • Per-User Cost Ranking: Runs HogQL queries over $ai_generation events to rank users by total cost, generations, traces, and error rate, with share-of-spend and p50/p90/p99 baseline comparisons.
  • Cost Driver Decomposition: Breaks each top user's spend down by provider, model, input/output/reasoning tokens, cache usage, and request or web-search fees, then applies a decision tree to identify the root cause.
  • Trace-Level Evidence: Finds a user's most expensive traces and reads representative ones to confirm whether costs come from retry loops, large context, verbose outputs, or tool-heavy generations.
  • Use Case: A platform team notices LLM costs doubled this month. Use this Skill to find that one user's contract-review workflow feeds 90k-token documents to the most expensive model, then get specific optimization levers.

Quick Start

Analyze the most expensive users in AI observability over the last 30 days and explain what is driving their costs.

Frequently Asked Questions about analyzing-expensive-users

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

FAQPage Schema
How do I find the most expensive users in PostHog AI observability?

Run a HogQL query grouping $ai_generation events by distinct_id, summing $ai_total_cost_usd over a bounded time range like the last 30 days. Compare each top user against a per-user baseline with p50, p90, and p99 cost percentiles to show how skewed their spend is.

How to explain why a specific user's LLM costs are high?

Break the user's spend down by provider and model, then examine input, output, reasoning, and cache token totals. High volume points to traffic, high cost per generation points to expensive models or long context, and high errors point to retries, which you confirm by reading representative traces.

Does per-user LLM cost analysis include embedding events?

The default ranking uses only $ai_generation events. For full spend per user, deliberately include $ai_embedding events in the event filter and call out the changed event set in your response so the numbers are interpretable.

Why do some AI observability users appear as trace IDs instead of identified users?

Some SDKs use $ai_trace_id as distinct_id when no user is set. Exclude rows where distinct_id equals properties.$ai_trace_id when analyzing identified users, and report how much spend becomes unattributed.

What are the limitations of aggregate LLM cost queries?

Aggregates identify suspects but cannot prove causality. You must read representative traces with posthog:query-llm-trace before attributing costs to retry loops, large context, or tool-heavy generations, and never fabricate baseline percentiles if the baseline query fails.