analyzing-expensive-users
Skill này làm gì
Skill này xếp hạng những người dùng tốn kém nhất trong dữ liệu sử dụng AI của bạn và giải thích lý do. Nó dành cho các nhóm chạy tính năng AI và muốn biết chi tiêu đi đâu.
Khi nào nên dùng
- ✓Khi bạn muốn biết người dùng hoặc tài khoản nào gây ra chi tiêu AI nhiều nhất.
- ✓Khi hóa đơn AI tăng và bạn cần tìm những người dùng đứng sau mức tăng đó.
- ✓Khi bạn muốn xem ví dụ về các cuộc hội thoại tốn kém để thấy chuyện gì đã xảy ra.
Liên kết skill
https://github.com/PostHog/posthog/blob/master/products/ai_observability/skills/analyzing-expensive-users/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Tháng này ai là người dùng AI tốn kém nhất của tôi, và điều gì làm họ tốn chi phí như vậy?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill xếp hạng người dùng theo chi phí trong một khoảng thời gian, so sánh họ với mức sử dụng thông thường, và kiểm tra các yếu tố như mô hình, độ dài prompt, việc thử lại và kích thước đầu ra. Sau đó, skill cho thấy vài ví dụ thực tế để lý do rõ ràng.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Analyzing expensive users
Use this skill when the user wants to understand the most expensive users in AI observability. The job is not just to rank users by cost. The useful answer explains what makes the top users expensive: volume, model choice, prompt size, output size, cache behavior, retries/errors, trace type, feature or tenant dimensions, and representative trace examples.
For general cost rollups, also use exploring-llm-costs. For reading
individual traces, also use exploring-llm-traces.
Tools
| Tool | Purpose |
|---|---|
posthog:execute-sql |
Rank users and compare their metrics against the project baseline |
posthog:query-llm-traces-list |
Find high-cost traces for a specific user (by person UUID) |
posthog:query-llm-trace |
Read representative traces to explain what actually happened |
posthog:read-data-schema |
Discover custom event or person properties before grouping by them |
posthog:generate-app-url |
Build region- and project-qualified links back to the UI |
Core rules
- Start with a bounded time range. If the user does not specify one, use the last 30 days and say so. If the user provides a link or existing filters, preserve the date range, test-account filter, and property filters.
- Start from generated-call spend. The per-user ranking query groups
$ai_generationrows bydistinct_id, withtraces,generations,errors,total_cost,first_seen, andlast_seen. This is the best first pass for finding expensive users. - For full spend by user, include embeddings deliberately. Broader cost
rollups should include
event IN ('$ai_generation', '$ai_embedding'), but call out when the event set changes. - Filter trace-id defaults when interpreting users. Some SDKs use
$ai_trace_idasdistinct_idwhen no user is set. For identified users, excludedistinct_id = properties.$ai_trace_idand flag how much spend becomes unattributed. - Do not guess custom dimensions. Discover event and person properties
before grouping by
feature,tenant_id,plan,workflow_name, or similar customer-specific fields. - Read traces before explaining causality. Aggregates identify suspects; representative traces show whether the user is expensive because of a real workflow, retries, loops, large context, tool-heavy generations, or other behavior.
Workflow
1. Rank users by generated-call spend
Use this first when the question asks for the most expensive users:
posthog:execute-sql
SELECT
distinct_id,
argMax(email, timestamp) AS email,
argMax(name, timestamp) AS name,
argMax(person_id, timestamp) AS person_uuid,
countDistinctIf(ai_trace_id, notEmpty(ai_trace_id)) AS traces,
count() AS generations,
countIf(notEmpty(ai_error) OR ai_is_error = 'true') AS errors,
round(sum(ai_total_cost_usd), 4) AS total_cost,
round(avg(ai_total_cost_usd), 6) AS avg_cost_per_generation,
sum(ai_input_tokens) AS input_tokens,
sum(ai_output_tokens) AS output_tokens,
min(timestamp) AS first_seen,
max(timestamp) AS last_seen
FROM (
SELECT
distinct_id,
timestamp,
person_id,
toString(properties.$ai_trace_id) AS ai_trace_id,
toFloat(properties.$ai_total_cost_usd) AS ai_total_cost_usd,
toString(properties.$ai_error) AS ai_error,
toString(properties.$ai_is_error) AS ai_is_error,
toInt(properties.$ai_input_tokens) AS ai_input_tokens,
toInt(properties.$ai_output_tokens) AS ai_output_tokens,
toString(person.properties.email) AS email,
toString(person.properties.name) AS name
FROM events
WHERE event = '$ai_generation'
AND timestamp >= now() - INTERVAL 30 DAY
)
GROUP BY distinct_id
ORDER BY total_cost DESC
LIMIT 25
If the user is asking for identified users, add this
inside the inner WHERE clause:
AND (
properties.$ai_trace_id IS NULL
OR distinct_id != properties.$ai_trace_id
)
Project only the explicit label columns you need, such as email and name.
Never select the raw person.properties object or a tuple containing it: it
serializes the full property blob into the result and leaks personal data far
beyond a label. I
Câu hỏi thường gặp
Skill dùng khoảng thời gian nào?
Nếu bạn không nêu một khoảng thời gian, skill dùng 30 ngày gần nhất và nói rõ điều đó trong câu trả lời.
Skill có thể cho tôi xem các cuộc hội thoại thực tế không?
Có. Skill mở các trace đại diện để bạn thấy mỗi yêu cầu tốn kém đã làm gì.
Có cần thiết lập thêm không?
Cần dữ liệu quan sát AI trong PostHog, nơi ghi lại chi phí của mỗi lần gọi mô hình.
Chi tiết
Mô tả gốc của tác giả
Analyze the most expensive users in AI observability and explain why they cost so much. Use when the user asks about top spenders, expensive users, per-user LLM cost, user-level cost drivers, or patterns behind high AI observability spend.
repo: PostHog/posthog
Độ phổ biến
- Sao GitHub
- 41k
- Vị trí xếp hạng
- #6826
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
depot-ci
41kGiúp agent của bạn thiết lập và chạy quy trình Depot CI, một lựa chọn thay thế GitHub Actions, gồm chuyển các quy trình hiện có và đọc nhật ký chạy.
depot-container-builds
41kGiúp agent của bạn build image Docker trên các builder từ xa của Depot, gồm image đa nền tảng, đẩy lên registry và sửa lỗi build.
depot-github-runners
41kGiúp agent của bạn chuyển các job GitHub Actions sang runner do Depot quản lý, chọn kích thước và nhãn runner, và xử lý lỗi thiết lập runner.
editing-agents-md
41kGiúp agent của bạn quyết định một quy tắc nên nằm trong file AGENTS.md hay CLAUDE.md, và viết sao cho quy tắc được tuân thủ mà file không bị phình to.
Skill tương tự
gitcrawl
394kCho phép agent của bạn tìm trong kho lưu trữ issue và pull request GitHub, gom các mục trùng lặp và kiểm tra trạng thái hiện tại trên GitHub.
slacrawl
394kCho phép agent của bạn tìm và đếm tin nhắn trong kho lưu trữ Slack cục bộ, kiểm tra kho đó mới đến mức nào và làm mới khi cần.
goplaces
394kGiúp agent của bạn tìm địa điểm, lấy chi tiết và đánh giá, và xác định tên địa điểm bằng Google Places, với đầu ra JSON cho script.