AI observability
llm_analytics

Generate an AI-powered summary of an LLM trace or event.

This endpoint analyzes the provided trace/event, generates a line-numbered text representation, and uses an LLM to create a concise summary with line references.

Two ways to use this endpoint:

  1. By ID (recommended): Pass trace_id or generation_id with an optional date_from/date_to. The backend fetches the data automatically. summarize_type is inferred.
  2. By data: Pass the full trace/event data blob in data with summarize_type. This is how the frontend uses it.

Summary Format:

  • Title (concise, max 10 words)
  • Mermaid flow diagram showing the main flow
  • 3-10 summary bullets with line references
  • "Interesting Notes" section for failures, successes, or unusual patterns
  • Line references in [L45] or [L45-52] format pointing to relevant sections

The response includes the structured summary, the text representation, and metadata.

post/api/projects/{project_id}/llm_analytics/summarization/

Request

  • Base URL: https://us.posthog.com
  • URL: https://us.posthog.com/api/projects/{project_id}/llm_analytics/summarization/
  • Auth: HTTP bearer

Path parameters

project_idstring required

Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Request body

summarize_type'trace' | 'event'
  • trace - trace
  • event - event
mode'minimal' | 'detailed'
  • minimal - minimal
  • detailed - detailed
dataunknown
force_refreshboolean

Force regenerate summary, bypassing cache

compact_contextboolean

Bound the input to a cost-conscious size instead of the full model context window. Use it when you summarize many traces at once and need only a short result such as the title.

modelstring nullable

LLM model to use (defaults based on provider)

trace_idstring

Trace ID to summarize. The backend fetches the trace data automatically. Requires date_from for efficient lookup.

generation_idstring

Generation event UUID to summarize. The backend fetches the event data automatically. Requires date_from for efficient lookup.

date_fromstring nullable

Start of date range for ID-based lookup (e.g. '-7d' or '2026-01-01'). Defaults to -30d.

date_tostring nullable

End of date range for ID-based lookup. Defaults to now.

Response

text_reprstring required

Line-numbered text representation that the summary references

metadataunknown

Changes

No recorded changes to this operation across all 1 revision of this API.