provider AI observabilityllm_analytics POST
/api/environments/{environment_id}/llm_analytics/text_repr/ @utdk/posthog
/api/environments/{environment_id}/llm_analytics/text_repr/ environments_llm_analytics_text_repr_create
Generate a human-readable text representation of an LLM trace event.
This endpoint converts AI observability events ($ai_generation, $ai_span, $ai_embedding, or $ai_trace)
into formatted text representations suitable for display, logging, or analysis.
**Supported Event Types:**
- `$ai_generation`: Individual LLM API calls with input/output messages
- `$ai_span`: Logical spans with state transitions
- `$ai_embedding`: Embedding generation events (text input → vector)
- `$ai_trace`: Full traces with hierarchical structure
**Options:**
- `max_length`: Maximum character count (default: 2000000)
- `truncated`: Enable middle-content truncation within events (default: true)
- `truncate_buffer`: Characters at start/end when truncating (default: 1000)
- `include_markers`: Use interactive markers vs plain text indicators (default: true)
- Frontend: set true for `<<<TRUNCATED|base64|...>>>` markers
- Backend/LLM: set false for `... (X chars truncated) ...` text
- `collapsed`: Show summary vs full trace tree (default: false)
- `include_hierarchy`: Include tree structure for traces (default: true)
- `max_depth`: Maximum depth for hierarchical rendering (default: unlimited)
- `tools_collapse_threshold`: Number of tools before auto-collapsing list (default: 5)
- Tool lists >5 items show `<<<TOOLS_EXPANDABLE|...>>>` marker for frontend
- Or `[+] AVAILABLE TOOLS: N` for backend when `include_markers: false`
- `include_line_numbers`: Prefix each line with line number like L001:, L010: (default: false)
**Use Cases:**
- Frontend display: `truncated: true, include_markers: true, include_line_numbers: true`
- Backend LLM context (summary): `truncated: true, include_markers: false, collapsed: true`
- Backend LLM context (full): `truncated: false`
The response includes the formatted text and metadata about the rendering.
- environment_id path required
- Deprecated. Use /api/projects/{project_id}/ instead.
- string
Try it
Authentication
Configure credentials for PostHog API
Code snippet
Updates live as you fill in the form above.
TypeScript
import posthog from '@utdk/posthog';
await posthog.environmentsLlmAnalyticsTextReprCreate()