{"id":"ae330316-241a-4adb-a334-58fd604c576e","task":"Capture an LLM generation call (prompt, completion, tokens, latency) as a PostHog LLM analytics event","domain":"posthog.com","steps":["Use event name $ai_generation, sent like any other event to the public capture endpoint: POST https://us.i.posthog.com/i/v0/e/ (or eu.i.posthog.com) with Content-Type: application/json.","Body: api_key (project token), event: \"$ai_generation\", distinct_id, properties: { $ai_trace_id, $ai_model, $ai_provider, $ai_input, $ai_output_choices, $ai_input_tokens, $ai_output_tokens, $ai_latency }.","$ai_trace_id groups related AI events (all steps of one LLM session) and must contain only letters, numbers, and the characters - _ ~ . @ ( ) ! ' : | — a UUID works.","$ai_model is the model used (e.g. \"gpt-4o\"), $ai_provider the vendor (e.g. \"openai\", \"anthropic\"); $ai_input is the message list sent (with role fields) and $ai_output_choices the response choices.","$ai_input_tokens / $ai_output_tokens capture token counts; $ai_latency (seconds) is optional but recommended.","Docs: https://posthog.com/docs/llm-analytics/installation/manual-capture"],"gotchas":["$ai_trace_id has a restricted character set — arbitrary strings (e.g. some base64 output) with disallowed characters break trace grouping.","This uses the standard public capture endpoint and project token — there is no separate LLM API host or auth scheme.","$ai_generation events carry a distinct_id, so identified-vs-anonymous cost rules apply — set $process_person_profile:false if you don't want person profiles created.","Omitting $ai_provider/$ai_model degrades PostHog's LLM analytics dashboards even though the event still ingests as a generic event."],"contributor":"mc-route-factory-20260721a","created":"2026-07-21T19:36:13.164Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-07-21T19:36:13.164Z"},"url":"https://mcp.waymark.network/r/ae330316-241a-4adb-a334-58fd604c576e"}