exploring-llm-costs
하는 일
이 스킬은 PostHog가 각 모델 호출마다 기록하는 비용 데이터를 바탕으로 AI 모델 사용 비용에 대한 질문에 답합니다. AI 예산을 관리하거나 어떤 모델이나 기능이 가장 비싼지 알고 싶은 사람을 위한 것입니다.
사용하는 경우
- ✓팀이 AI 모델에 시간에 따라 얼마를 쓰는지 알고 싶을 때.
- ✓비용이 급증해서 어떤 모델, 사용자, 기능이 원인인지 찾아야 할 때.
- ✓AI 지출을 계속 보기 위해 비용 차트나 알림이 필요할 때.
스킬 링크
https://github.com/PostHog/posthog/blob/master/products/ai_observability/skills/exploring-llm-costs/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“지난달 AI 모델에 얼마를 썼고, 어떤 모델이 가장 비쌌나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
PostHog에서 각 AI 모델 호출의 비용을 합산하고, 선택한 기준(모델, 제공자, 사용자, 사용자 지정 속성 등)으로 묶습니다. 기간을 비교해 급증을 설명할 수 있고, 결과를 차트나 대시보드 항목으로 저장할 수 있습니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Exploring LLM costs
PostHog attaches per-call cost metadata to every $ai_generation and $ai_embedding
event at ingestion time. Every cost question reduces to an aggregation over those
two event types — the interesting variation is only in how you group, filter, and
compare.
This skill covers the common cost investigations: total spend, breakdowns (model, provider, user, trace, custom property), token and cache-hit analysis, regression debugging, and materializing results as insights, dashboards, or alerts.
Tools
| Tool | Purpose |
|---|---|
posthog:query-trends |
Native cost trends with supported sums, breakdowns, and comparisons |
posthog:execute-sql |
Ad-hoc HogQL for any cost aggregation — the workhorse of this skill |
posthog:query-llm-traces-list |
List traces with rolled-up cost, token, and error metrics |
posthog:query-llm-trace |
Cost breakdown of a single trace across all its events |
posthog:read-data-schema |
Discover which custom properties exist for breakdowns |
posthog:insight-create |
Materialize a cost chart as a saved insight |
posthog:dashboard-create |
Bundle cost insights into a dashboard |
posthog:alert-create |
Alert when cost crosses a threshold |
posthog:generate-app-url |
Build region- and project-qualified links back to the UI |
Core rules
Three rules cover most of what goes wrong:
- Sum
$ai_total_cost_usdfor rollups, never the components. Components drop request and web-search fees. The UI's cost cells sum$ai_total_cost_usdoverevent IN ('$ai_generation', '$ai_embedding'); mirror that. Full schema and rationale in cost properties. - Always include both
$ai_generationand$ai_embeddingin cost queries unless the project demonstrably does not use embeddings — missing them silently under-counts.$ai_traceand$ai_spancarry no rollup cost; some SDK wrappers duplicate$ai_total_cost_usdonto$ai_traceso don't include it in rollups or you'll double-count. - Always set a time range. Cost queries without one scan the full events table.
$ai_total_cost_usd is set at ingestion via one of three paths (passthrough,
custom pricing, automatic lookup). When a cost looks wrong, read
$ai_cost_model_source first — see cost sources
for the precedence rules and a diagnostic query.
Cache-hit math depends on whether the provider reports cache tokens inclusively
or exclusively of $ai_input_tokens. Always branch on the per-event
$ai_cache_reporting_exclusive flag, never on provider name — see
cache accounting for the exclusive-vs-inclusive
formula.
distinct_id is the canonical user dimension. Customers often attach custom
properties (feature, tenant_id, workflow_name) — discover them with
posthog:read-data-schema before grouping. Don't guess names.
Workflow: total spend in a window
posthog:execute-sql
SELECT round(sum(toFloat(properties.$ai_total_cost_usd)), 4) AS total_cost_usd
FROM events
WHERE event IN ('$ai_generation', '$ai_embedding')
AND timestamp >= now() - INTERVAL 30 DAY
Workflow: cost breakdowns
Every cost question is a variation of the same template — group by a dimension,
aggregate $ai_total_cost_usd. See breakdown patterns
for ready-to-run recipes:
- Cost over time (daily)
- Cost by model
- Cost by user (top spenders)
- Cost by trace (top expensive traces)
- Cost by custom dimension
- Cost-per-call distribution
- Input vs output vs cache economics
Workflow: inspect a single trace's cost
When the user pastes a trace URL and asks about its cost, fetch the trace and surface the per-event breakdown:
posthog:query-llm-trace
{ "traceId": "<trace_id>", "dateRange": {"date_from": "-30d"} }
Sum $ai_total_cost_usd across the returned events, grouped by span name or
model, to show which step(s) drove the cost. The trace response already
includes totalCost as a convenience.
Workflow: debug a cost regression
"Our LLM bill jumped — w
자주 묻는 질문
비용 수치는 어디서 오나요?
PostHog는 기록될 때 각 AI 호출에 비용 정보를 붙이므로, 합계는 그 데이터에서 나옵니다.
토큰 사용량도 보여 줄 수 있나요?
네. 비용과 함께 토큰과 캐시 히트도 확인할 수 있습니다.
대시보드에 올릴 수 있나요?
네. 비용 차트를 인사이트로 저장하고 대시보드에 추가할 수 있습니다.
상세 정보
작성자의 원본 설명
Investigate LLM spend in PostHog — total cost over time, cost by model, provider, user, trace, or custom dimension, token and cache-hit economics, and cost regressions. Use when the user asks "how much are we spending on LLMs?", "which model / user / feature is most expensive?", "why did cost spike?", wants to build a cost dashboard or alert, or pastes a trace URL and asks about its cost.
repo: PostHog/posthog
인기도
- GitHub 스타
- 41k
- 순위
- #6831
- 라이선스
- —
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
depot-ci
41k에이전트가 GitHub Actions 대안인 Depot CI 워크플로를 설정하고 실행하도록 돕습니다. 기존 워크플로 이전과 실행 로그 읽기를 포함합니다.
depot-container-builds
41k에이전트가 Depot 원격 빌더에서 Docker 이미지를 빌드하도록 돕습니다. 다중 플랫폼 이미지, 레지스트리 푸시, 빌드 실패 수정을 포함합니다.
depot-github-runners
41k에이전트가 GitHub Actions 작업을 Depot 관리형 러너로 옮기고, 러너 크기와 라벨을 고르도록 돕습니다.
editing-agents-md
41k에이전트가 규칙을 AGENTS.md나 CLAUDE.md 중 어디에 둘지 정하고, 파일을 키우지 않으면서 잘 지켜지도록 쓰게 돕습니다.
비슷한 스킬
gitcrawl
394k에이전트가 저장된 GitHub 이슈와 풀 리퀘스트 보관본을 검색하고, 중복 항목을 묶고, GitHub에서 현재 상태를 확인하도록 돕습니다.
slacrawl
394k에이전트가 로컬 Slack 보관본에서 메시지를 검색하고 개수를 세며, 보관본이 얼마나 최신인지 확인하고 필요할 때 새로 고치도록 돕습니다.
goplaces
394k에이전트가 Google Places로 장소를 검색하고, 세부 정보와 리뷰를 가져오고, 장소 이름을 확인하며, 스크립트용 JSON을 출력하도록 돕습니다.