@utdk/posthog 1.0.0-20260712.5-dev.e2949a6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +373 -0
- package/README.md +172 -0
- package/docs/account_relationship_definitions.md +194 -0
- package/docs/accounts.md +380 -0
- package/docs/actions.md +274 -0
- package/docs/activity_logs.md +144 -0
- package/docs/advanced_activity_logs.md +101 -0
- package/docs/agent_platform.md +2525 -0
- package/docs/ai-observability.md +514 -0
- package/docs/alerts.md +444 -0
- package/docs/annotations.md +200 -0
- package/docs/batch_exports.md +2118 -0
- package/docs/business_knowledge.md +468 -0
- package/docs/code-invites.md +72 -0
- package/docs/cohorts.md +412 -0
- package/docs/comments.md +321 -0
- package/docs/conversations.md +695 -0
- package/docs/custom_property_definitions.md +442 -0
- package/docs/custom_property_sources.md +194 -0
- package/docs/customer_analytics.md +442 -0
- package/docs/customer_journeys.md +380 -0
- package/docs/customer_profile_configs.md +380 -0
- package/docs/dashboard_templates.md +258 -0
- package/docs/dashboards.md +1896 -0
- package/docs/data_color_themes.md +380 -0
- package/docs/data_modeling_jobs.md +264 -0
- package/docs/data_warehouse.md +928 -0
- package/docs/dataset_items.md +382 -0
- package/docs/datasets.md +382 -0
- package/docs/desktop_file_system.md +753 -0
- package/docs/desktop_file_system_shortcut.md +244 -0
- package/docs/docs.md +72 -0
- package/docs/early_access_feature.md +194 -0
- package/docs/elements.md +510 -0
- package/docs/endpoints.md +1030 -0
- package/docs/engineering_analytics.md +712 -0
- package/docs/environments.md +881 -0
- package/docs/error_tracking.md +5108 -0
- package/docs/evaluation_runs.md +78 -0
- package/docs/evaluations.md +446 -0
- package/docs/event_definitions.md +425 -0
- package/docs/event_filter.md +280 -0
- package/docs/event_schemas.md +163 -0
- package/docs/events.md +208 -0
- package/docs/experiment_holdouts.md +194 -0
- package/docs/experiment_saved_metrics.md +194 -0
- package/docs/experiments.md +1088 -0
- package/docs/exports.md +256 -0
- package/docs/external_data_schemas.md +752 -0
- package/docs/external_data_sources.md +2296 -0
- package/docs/feature_flags.md +808 -0
- package/docs/field_notes.md +206 -0
- package/docs/file_system.md +880 -0
- package/docs/file_system_shortcut.md +444 -0
- package/docs/flag_value.md +46 -0
- package/docs/groups.md +514 -0
- package/docs/groups_types.md +349 -0
- package/docs/health_issues.md +386 -0
- package/docs/heatmap_screenshots.md +72 -0
- package/docs/heatmaps.md +136 -0
- package/docs/hog_flows.md +1576 -0
- package/docs/hog_function_templates.md +101 -0
- package/docs/hog_functions.md +974 -0
- package/docs/ingestion_warnings_v2.md +40 -0
- package/docs/insight_variables.md +380 -0
- package/docs/insights.md +1722 -0
- package/docs/integrations.md +1954 -0
- package/docs/js-snippet.md +104 -0
- package/docs/live_debugger_breakpoints.md +264 -0
- package/docs/llm_analytics.md +3373 -0
- package/docs/llm_prompts.md +442 -0
- package/docs/llm_skills.md +952 -0
- package/docs/logs.md +2446 -0
- package/docs/managed_viewsets.md +140 -0
- package/docs/marketing_analytics.md +518 -0
- package/docs/max.md +772 -0
- package/docs/max_tools.md +70 -0
- package/docs/mcp_analytics.md +712 -0
- package/docs/mcp_server_installations.md +970 -0
- package/docs/mcp_servers.md +78 -0
- package/docs/mcp_tools.md +82 -0
- package/docs/messaging_templates.md +444 -0
- package/docs/metrics.md +462 -0
- package/docs/notebooks.md +838 -0
- package/docs/object_media_previews.md +228 -0
- package/docs/organizations.md +2958 -0
- package/docs/persons.md +1514 -0
- package/docs/platform_features.md +700 -0
- package/docs/plugin_configs.md +70 -0
- package/docs/product_enablement.md +39 -0
- package/docs/product_tours.md +357 -0
- package/docs/project_secret_api_keys.md +444 -0
- package/docs/property_access_controls.md +200 -0
- package/docs/property_definitions.md +244 -0
- package/docs/query.md +560 -0
- package/docs/quota_limits.md +40 -0
- package/docs/reminders.md +194 -0
- package/docs/replay.md +1020 -0
- package/docs/reverse_proxy.md +200 -0
- package/docs/sandbox-custom-images.md +209 -0
- package/docs/sandbox-environments.md +168 -0
- package/docs/saved.md +392 -0
- package/docs/saved_query_column_annotations.md +224 -0
- package/docs/scheduled_changes.md +200 -0
- package/docs/schema_property_groups.md +194 -0
- package/docs/sdk_health.md +40 -0
- package/docs/session_group_summaries.md +200 -0
- package/docs/session_recordings.md +260 -0
- package/docs/session_summaries.md +200 -0
- package/docs/sessions.md +132 -0
- package/docs/signals.md +1428 -0
- package/docs/single_session_summaries.md +72 -0
- package/docs/streamlit_apps.md +456 -0
- package/docs/subscriptions.md +634 -0
- package/docs/surveys.md +731 -0
- package/docs/taggers.md +446 -0
- package/docs/task-automations.md +200 -0
- package/docs/task-runs.md +654 -0
- package/docs/task_channels.md +136 -0
- package/docs/task_mentions.md +40 -0
- package/docs/tasks.md +776 -0
- package/docs/tracing.md +1186 -0
- package/docs/uploaded_media.md +44 -0
- package/docs/user_home_settings.md +72 -0
- package/docs/user_interview_topics.md +1288 -0
- package/docs/user_interviews.md +444 -0
- package/docs/users.md +1267 -0
- package/docs/vision.md +2022 -0
- package/docs/visual_review.md +816 -0
- package/docs/warehouse_column_annotations.md +224 -0
- package/docs/warehouse_column_statistics.md +80 -0
- package/docs/warehouse_dag.md +40 -0
- package/docs/warehouse_model_paths.md +70 -0
- package/docs/warehouse_saved_queries.md +1056 -0
- package/docs/warehouse_saved_query_folders.md +318 -0
- package/docs/warehouse_tables.md +584 -0
- package/docs/warehouse_view_link.md +456 -0
- package/docs/warehouse_view_links.md +456 -0
- package/docs/web_analytics.md +136 -0
- package/docs/web_analytics_achievements.md +200 -0
- package/docs/web_experiments.md +194 -0
- package/docs/web_vitals.md +74 -0
- package/docs/wizard.md +170 -0
- package/index.ts +22 -0
- package/metadata.ts +41419 -0
- package/openapi.json +297382 -0
- package/overlay.yaml +23 -0
- package/package.json +34 -0
- package/provenance.json +24 -0
- package/research.json +80 -0
- package/types/index.ts +17547 -0
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
# AI Observability
|
|
2
|
+
|
|
3
|
+
## Operations
|
|
4
|
+
|
|
5
|
+
### `posthog.environmentsLlmAnalyticsEvaluationSummaryCreate`
|
|
6
|
+
|
|
7
|
+
- **HTTP**: `POST /api/environments/{environment_id}/llm_analytics/evaluation_summary/`
|
|
8
|
+
- **What it does**:
|
|
9
|
+
Generate an AI-powered summary of evaluation results.
|
|
10
|
+
|
|
11
|
+
This endpoint analyzes evaluation runs and identifies patterns in passing
|
|
12
|
+
and failing evaluations, providing actionable recommendations.
|
|
13
|
+
|
|
14
|
+
Data is fetched server-side by evaluation ID to ensure data integrity.
|
|
15
|
+
|
|
16
|
+
**Use Cases:**
|
|
17
|
+
- Understand why evaluations are passing or failing
|
|
18
|
+
- Identify systematic issues in LLM responses
|
|
19
|
+
- Get recommendations for improving response quality
|
|
20
|
+
- Review patterns across many evaluation runs at once
|
|
21
|
+
|
|
22
|
+
- **OpenAPI operationId**: `environments_llm_analytics_evaluation_summary_create`
|
|
23
|
+
- **Path params**: None
|
|
24
|
+
- **Query params**: None
|
|
25
|
+
- **Response codes**: `200`, `400`, `403`, `404`, `500`
|
|
26
|
+
- **Transport options**: None
|
|
27
|
+
- **TypeScript**: [Client interface](../types.ts)
|
|
28
|
+
|
|
29
|
+
**Inputs**
|
|
30
|
+
|
|
31
|
+
- Client input type: `{ [key: string]: unknown }`
|
|
32
|
+
- Client transport options: None
|
|
33
|
+
|
|
34
|
+
**Outputs**
|
|
35
|
+
|
|
36
|
+
- Client return type: `{ overall_assessment: string; pass_patterns: ({ title: string; description: string; frequency: string; example_generation_ids: (string)[] })[]; fail_patterns: ({ title: string; description: string; frequency: string; ex...`
|
|
37
|
+
- OpenAPI response codes: `200`, `400`, `403`, `404`, `500`
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import posthog from "@utdk/posthog";
|
|
41
|
+
|
|
42
|
+
type EnvironmentsLlmAnalyticsEvaluationSummaryCreateInput = Parameters<typeof posthog.environmentsLlmAnalyticsEvaluationSummaryCreate> extends [infer T, ...unknown[]] ? T : undefined;
|
|
43
|
+
type EnvironmentsLlmAnalyticsEvaluationSummaryCreateOutput = Awaited<ReturnType<typeof posthog.environmentsLlmAnalyticsEvaluationSummaryCreate>>;
|
|
44
|
+
|
|
45
|
+
const result: EnvironmentsLlmAnalyticsEvaluationSummaryCreateOutput = await posthog.environmentsLlmAnalyticsEvaluationSummaryCreate();
|
|
46
|
+
|
|
47
|
+
// Result shape (from schema): { overall_assessment: string; pass_patterns: ({ title: string; description: string; frequency: string; example_generation_ids: (string)[] })[]; fail_patterns: ({ title: string; description: string; frequency: string; ex...
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### `posthog.environmentsLlmAnalyticsOfflineEvaluationsExperimentItemsCreate`
|
|
51
|
+
|
|
52
|
+
- **HTTP**: `POST /api/environments/{environment_id}/llm_analytics/offline_evaluations/experiment_items/`
|
|
53
|
+
- **OpenAPI operationId**: `environments_llm_analytics_offline_evaluations_experiment_items_create`
|
|
54
|
+
- **Path params**: None
|
|
55
|
+
- **Query params**: None
|
|
56
|
+
- **Response codes**: `200`, `400`, `500`
|
|
57
|
+
- **Transport options**: None
|
|
58
|
+
- **TypeScript**: [Client interface](../types.ts)
|
|
59
|
+
|
|
60
|
+
**Inputs**
|
|
61
|
+
|
|
62
|
+
- Client input type: `{ [key: string]: unknown }`
|
|
63
|
+
- Client transport options: None
|
|
64
|
+
|
|
65
|
+
**Outputs**
|
|
66
|
+
|
|
67
|
+
- Client return type: `{ results: ((unknown)[])[] }`
|
|
68
|
+
- OpenAPI response codes: `200`, `400`, `500`
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import posthog from "@utdk/posthog";
|
|
72
|
+
|
|
73
|
+
type EnvironmentsLlmAnalyticsOfflineEvaluationsExperimentItemsCreateInput = Parameters<typeof posthog.environmentsLlmAnalyticsOfflineEvaluationsExperimentItemsCreate> extends [infer T, ...unknown[]] ? T : undefined;
|
|
74
|
+
type EnvironmentsLlmAnalyticsOfflineEvaluationsExperimentItemsCreateOutput = Awaited<ReturnType<typeof posthog.environmentsLlmAnalyticsOfflineEvaluationsExperimentItemsCreate>>;
|
|
75
|
+
|
|
76
|
+
const result: EnvironmentsLlmAnalyticsOfflineEvaluationsExperimentItemsCreateOutput = await posthog.environmentsLlmAnalyticsOfflineEvaluationsExperimentItemsCreate();
|
|
77
|
+
|
|
78
|
+
// Result shape (from schema): { results: ((unknown)[])[] }
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### `posthog.environmentsLlmAnalyticsSummarizationCreate`
|
|
82
|
+
|
|
83
|
+
- **HTTP**: `POST /api/environments/{environment_id}/llm_analytics/summarization/`
|
|
84
|
+
- **What it does**:
|
|
85
|
+
Generate an AI-powered summary of an LLM trace or event.
|
|
86
|
+
|
|
87
|
+
This endpoint analyzes the provided trace/event, generates a line-numbered text
|
|
88
|
+
representation, and uses an LLM to create a concise summary with line references.
|
|
89
|
+
|
|
90
|
+
**Two ways to use this endpoint:**
|
|
91
|
+
|
|
92
|
+
1. **By ID (recommended):** Pass `trace_id` or `generation_id` with an optional `date_from`/`date_to`.
|
|
93
|
+
The backend fetches the data automatically. `summarize_type` is inferred.
|
|
94
|
+
2. **By data:** Pass the full trace/event data blob in `data` with `summarize_type`.
|
|
95
|
+
This is how the frontend uses it.
|
|
96
|
+
|
|
97
|
+
**Summary Format:**
|
|
98
|
+
- Title (concise, max 10 words)
|
|
99
|
+
- Mermaid flow diagram showing the main flow
|
|
100
|
+
- 3-10 summary bullets with line references
|
|
101
|
+
- "Interesting Notes" section for failures, successes, or unusual patterns
|
|
102
|
+
- Line references in [L45] or [L45-52] format pointing to relevant sections
|
|
103
|
+
|
|
104
|
+
The response includes the structured summary, the text representation, and metadata.
|
|
105
|
+
|
|
106
|
+
- **OpenAPI operationId**: `environments_llm_analytics_summarization_create`
|
|
107
|
+
- **Path params**: None
|
|
108
|
+
- **Query params**: None
|
|
109
|
+
- **Response codes**: `200`, `400`, `403`, `500`
|
|
110
|
+
- **Transport options**: None
|
|
111
|
+
- **TypeScript**: [Client interface](../types.ts)
|
|
112
|
+
|
|
113
|
+
**Inputs**
|
|
114
|
+
|
|
115
|
+
- Client input type: `{ [key: string]: unknown }`
|
|
116
|
+
- Client transport options: None
|
|
117
|
+
|
|
118
|
+
**Outputs**
|
|
119
|
+
|
|
120
|
+
- Client return type: `{ summary: { title: string; flow_diagram: string; summary_bullets: ({ text: string; line_refs: string })[]; interesting_notes: ({ text: string; line_refs: string })[] }; text_repr: string; metadata?: unknown }`
|
|
121
|
+
- OpenAPI response codes: `200`, `400`, `403`, `500`
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import posthog from "@utdk/posthog";
|
|
125
|
+
|
|
126
|
+
type EnvironmentsLlmAnalyticsSummarizationCreateInput = Parameters<typeof posthog.environmentsLlmAnalyticsSummarizationCreate> extends [infer T, ...unknown[]] ? T : undefined;
|
|
127
|
+
type EnvironmentsLlmAnalyticsSummarizationCreateOutput = Awaited<ReturnType<typeof posthog.environmentsLlmAnalyticsSummarizationCreate>>;
|
|
128
|
+
|
|
129
|
+
const result: EnvironmentsLlmAnalyticsSummarizationCreateOutput = await posthog.environmentsLlmAnalyticsSummarizationCreate();
|
|
130
|
+
|
|
131
|
+
// Result shape (from schema): { summary: { title: string; flow_diagram: string; summary_bullets: ({ text: string; line_refs: string })[]; interesting_notes: ({ text: string; line_refs: string })[] }; text_repr: string; metadata?: unknown }
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### `posthog.environmentsLlmAnalyticsSummarizationBatchCheckCreate`
|
|
135
|
+
|
|
136
|
+
- **HTTP**: `POST /api/environments/{environment_id}/llm_analytics/summarization/batch_check/`
|
|
137
|
+
- **What it does**:
|
|
138
|
+
Check which traces have cached summaries available.
|
|
139
|
+
|
|
140
|
+
This endpoint allows batch checking of multiple trace IDs to see which ones
|
|
141
|
+
have cached summaries. Returns only the traces that have cached summaries
|
|
142
|
+
with their titles.
|
|
143
|
+
|
|
144
|
+
**Use Cases:**
|
|
145
|
+
- Load cached summaries on session view load
|
|
146
|
+
- Avoid unnecessary LLM calls for already-summarized traces
|
|
147
|
+
- Display summary previews without generating new summaries
|
|
148
|
+
|
|
149
|
+
- **OpenAPI operationId**: `environments_llm_analytics_summarization_batch_check_create`
|
|
150
|
+
- **Path params**: None
|
|
151
|
+
- **Query params**: None
|
|
152
|
+
- **Response codes**: `200`, `400`, `403`
|
|
153
|
+
- **Transport options**: None
|
|
154
|
+
- **TypeScript**: [Client interface](../types.ts)
|
|
155
|
+
|
|
156
|
+
**Inputs**
|
|
157
|
+
|
|
158
|
+
- Client input type: `{ [key: string]: unknown }`
|
|
159
|
+
- Client transport options: None
|
|
160
|
+
|
|
161
|
+
**Outputs**
|
|
162
|
+
|
|
163
|
+
- Client return type: `{ summaries: ({ trace_id: string; title: string; cached?: boolean })[] }`
|
|
164
|
+
- OpenAPI response codes: `200`, `400`, `403`
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
import posthog from "@utdk/posthog";
|
|
168
|
+
|
|
169
|
+
type EnvironmentsLlmAnalyticsSummarizationBatchCheckCreateInput = Parameters<typeof posthog.environmentsLlmAnalyticsSummarizationBatchCheckCreate> extends [infer T, ...unknown[]] ? T : undefined;
|
|
170
|
+
type EnvironmentsLlmAnalyticsSummarizationBatchCheckCreateOutput = Awaited<ReturnType<typeof posthog.environmentsLlmAnalyticsSummarizationBatchCheckCreate>>;
|
|
171
|
+
|
|
172
|
+
const result: EnvironmentsLlmAnalyticsSummarizationBatchCheckCreateOutput = await posthog.environmentsLlmAnalyticsSummarizationBatchCheckCreate();
|
|
173
|
+
|
|
174
|
+
// Result shape (from schema): { summaries: ({ trace_id: string; title: string; cached?: boolean })[] }
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### `posthog.environmentsLlmAnalyticsTextReprCreate`
|
|
178
|
+
|
|
179
|
+
- **HTTP**: `POST /api/environments/{environment_id}/llm_analytics/text_repr/`
|
|
180
|
+
- **What it does**:
|
|
181
|
+
Generate a human-readable text representation of an LLM trace event.
|
|
182
|
+
|
|
183
|
+
This endpoint converts AI observability events ($ai_generation, $ai_span, $ai_embedding, or $ai_trace)
|
|
184
|
+
into formatted text representations suitable for display, logging, or analysis.
|
|
185
|
+
|
|
186
|
+
**Supported Event Types:**
|
|
187
|
+
- `$ai_generation`: Individual LLM API calls with input/output messages
|
|
188
|
+
- `$ai_span`: Logical spans with state transitions
|
|
189
|
+
- `$ai_embedding`: Embedding generation events (text input → vector)
|
|
190
|
+
- `$ai_trace`: Full traces with hierarchical structure
|
|
191
|
+
|
|
192
|
+
**Options:**
|
|
193
|
+
- `max_length`: Maximum character count (default: 2000000)
|
|
194
|
+
- `truncated`: Enable middle-content truncation within events (default: true)
|
|
195
|
+
- `truncate_buffer`: Characters at start/end when truncating (default: 1000)
|
|
196
|
+
- `include_markers`: Use interactive markers vs plain text indicators (default: true)
|
|
197
|
+
- Frontend: set true for `<<<TRUNCATED|base64|...>>>` markers
|
|
198
|
+
- Backend/LLM: set false for `... (X chars truncated) ...` text
|
|
199
|
+
- `collapsed`: Show summary vs full trace tree (default: false)
|
|
200
|
+
- `include_hierarchy`: Include tree structure for traces (default: true)
|
|
201
|
+
- `max_depth`: Maximum depth for hierarchical rendering (default: unlimited)
|
|
202
|
+
- `tools_collapse_threshold`: Number of tools before auto-collapsing list (default: 5)
|
|
203
|
+
- Tool lists >5 items show `<<<TOOLS_EXPANDABLE|...>>>` marker for frontend
|
|
204
|
+
- Or `[+] AVAILABLE TOOLS: N` for backend when `include_markers: false`
|
|
205
|
+
- `include_line_numbers`: Prefix each line with line number like L001:, L010: (default: false)
|
|
206
|
+
|
|
207
|
+
**Use Cases:**
|
|
208
|
+
- Frontend display: `truncated: true, include_markers: true, include_line_numbers: true`
|
|
209
|
+
- Backend LLM context (summary): `truncated: true, include_markers: false, collapsed: true`
|
|
210
|
+
- Backend LLM context (full): `truncated: false`
|
|
211
|
+
|
|
212
|
+
The response includes the formatted text and metadata about the rendering.
|
|
213
|
+
|
|
214
|
+
- **OpenAPI operationId**: `environments_llm_analytics_text_repr_create`
|
|
215
|
+
- **Path params**: None
|
|
216
|
+
- **Query params**: None
|
|
217
|
+
- **Response codes**: `200`, `400`, `500`, `503`
|
|
218
|
+
- **Transport options**: None
|
|
219
|
+
- **TypeScript**: [Client interface](../types.ts)
|
|
220
|
+
|
|
221
|
+
**Inputs**
|
|
222
|
+
|
|
223
|
+
- Client input type: `{ [key: string]: unknown }`
|
|
224
|
+
- Client transport options: None
|
|
225
|
+
|
|
226
|
+
**Outputs**
|
|
227
|
+
|
|
228
|
+
- Client return type: `{ text: string; metadata: { event_type?: string; event_id?: string; trace_id?: string; rendering: string; char_count: number; truncated: boolean; error?: string } }`
|
|
229
|
+
- OpenAPI response codes: `200`, `400`, `500`, `503`
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
import posthog from "@utdk/posthog";
|
|
233
|
+
|
|
234
|
+
type EnvironmentsLlmAnalyticsTextReprCreateInput = Parameters<typeof posthog.environmentsLlmAnalyticsTextReprCreate> extends [infer T, ...unknown[]] ? T : undefined;
|
|
235
|
+
type EnvironmentsLlmAnalyticsTextReprCreateOutput = Awaited<ReturnType<typeof posthog.environmentsLlmAnalyticsTextReprCreate>>;
|
|
236
|
+
|
|
237
|
+
const result: EnvironmentsLlmAnalyticsTextReprCreateOutput = await posthog.environmentsLlmAnalyticsTextReprCreate();
|
|
238
|
+
|
|
239
|
+
// Result shape (from schema): { text: string; metadata: { event_type?: string; event_id?: string; trace_id?: string; rendering: string; char_count: number; truncated: boolean; error?: string } }
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### `posthog.llmAnalyticsPersonalSpendList`
|
|
243
|
+
|
|
244
|
+
- **HTTP**: `GET /api/llm_analytics/@me/spend/`
|
|
245
|
+
- **What it does**: Return a structured personal LLM spend analysis for the requesting user. Pass `date_from` / `date_to` (absolute like `2026-04-23` or relative like `-7d`) to bound the window — defaults to the last 30 days, max 90 days. The `product=<ai_product>` query param is required and scopes the tool / model / day / trace breakdowns to a single product; supported values: posthog_code. `by_product` is always returned for cross-product visibility. `by_day` returns a day-ascending spend series for the scoped product. Use `refresh=true` to bypass the 5-minute response cache.
|
|
246
|
+
- **OpenAPI operationId**: `llm_analytics_personal_spend_list`
|
|
247
|
+
- **Path params**: None
|
|
248
|
+
- **Query params**: `date_from`, `date_to`, `limit`, `product`, `refresh`
|
|
249
|
+
- **Response codes**: `200`, `400`, `401`, `403`, `404`, `429`
|
|
250
|
+
- **Transport options**: None
|
|
251
|
+
- **TypeScript**: [Client interface](../types.ts)
|
|
252
|
+
|
|
253
|
+
**Inputs**
|
|
254
|
+
|
|
255
|
+
- Client input type: `{ [key: string]: unknown }`
|
|
256
|
+
- Client transport options: None
|
|
257
|
+
|
|
258
|
+
**Outputs**
|
|
259
|
+
|
|
260
|
+
- Client return type: `({ summary: { date_from: string; date_to: string; product: string; total_cost_usd: number; event_count: number; scoped_cost_usd: number; scoped_event_count: number }; by_product: { items: ({ product: string | null; even...`
|
|
261
|
+
- OpenAPI response codes: `200`, `400`, `401`, `403`, `404`, `429`
|
|
262
|
+
|
|
263
|
+
```ts
|
|
264
|
+
import posthog from "@utdk/posthog";
|
|
265
|
+
|
|
266
|
+
type LlmAnalyticsPersonalSpendListInput = Parameters<typeof posthog.llmAnalyticsPersonalSpendList> extends [infer T, ...unknown[]] ? T : undefined;
|
|
267
|
+
type LlmAnalyticsPersonalSpendListOutput = Awaited<ReturnType<typeof posthog.llmAnalyticsPersonalSpendList>>;
|
|
268
|
+
|
|
269
|
+
const result: LlmAnalyticsPersonalSpendListOutput = await posthog.llmAnalyticsPersonalSpendList();
|
|
270
|
+
|
|
271
|
+
// Result shape (from schema): ({ summary: { date_from: string; date_to: string; product: string; total_cost_usd: number; event_count: number; scoped_cost_usd: number; scoped_event_count: number }; by_product: { items: ({ product: string | null; even...
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### `posthog.llmAnalyticsEvaluationSummaryCreate`
|
|
275
|
+
|
|
276
|
+
- **HTTP**: `POST /api/projects/{project_id}/llm_analytics/evaluation_summary/`
|
|
277
|
+
- **What it does**:
|
|
278
|
+
Generate an AI-powered summary of evaluation results.
|
|
279
|
+
|
|
280
|
+
This endpoint analyzes evaluation runs and identifies patterns in passing
|
|
281
|
+
and failing evaluations, providing actionable recommendations.
|
|
282
|
+
|
|
283
|
+
Data is fetched server-side by evaluation ID to ensure data integrity.
|
|
284
|
+
|
|
285
|
+
**Use Cases:**
|
|
286
|
+
- Understand why evaluations are passing or failing
|
|
287
|
+
- Identify systematic issues in LLM responses
|
|
288
|
+
- Get recommendations for improving response quality
|
|
289
|
+
- Review patterns across many evaluation runs at once
|
|
290
|
+
|
|
291
|
+
- **OpenAPI operationId**: `llm_analytics_evaluation_summary_create`
|
|
292
|
+
- **Path params**: None
|
|
293
|
+
- **Query params**: None
|
|
294
|
+
- **Response codes**: `200`, `400`, `403`, `404`, `500`
|
|
295
|
+
- **Transport options**: None
|
|
296
|
+
- **TypeScript**: [Client interface](../types.ts)
|
|
297
|
+
|
|
298
|
+
**Inputs**
|
|
299
|
+
|
|
300
|
+
- Client input type: `{ [key: string]: unknown }`
|
|
301
|
+
- Client transport options: None
|
|
302
|
+
|
|
303
|
+
**Outputs**
|
|
304
|
+
|
|
305
|
+
- Client return type: `{ overall_assessment: string; pass_patterns: ({ title: string; description: string; frequency: string; example_generation_ids: (string)[] })[]; fail_patterns: ({ title: string; description: string; frequency: string; ex...`
|
|
306
|
+
- OpenAPI response codes: `200`, `400`, `403`, `404`, `500`
|
|
307
|
+
|
|
308
|
+
```ts
|
|
309
|
+
import posthog from "@utdk/posthog";
|
|
310
|
+
|
|
311
|
+
type LlmAnalyticsEvaluationSummaryCreateInput = Parameters<typeof posthog.llmAnalyticsEvaluationSummaryCreate> extends [infer T, ...unknown[]] ? T : undefined;
|
|
312
|
+
type LlmAnalyticsEvaluationSummaryCreateOutput = Awaited<ReturnType<typeof posthog.llmAnalyticsEvaluationSummaryCreate>>;
|
|
313
|
+
|
|
314
|
+
const result: LlmAnalyticsEvaluationSummaryCreateOutput = await posthog.llmAnalyticsEvaluationSummaryCreate();
|
|
315
|
+
|
|
316
|
+
// Result shape (from schema): { overall_assessment: string; pass_patterns: ({ title: string; description: string; frequency: string; example_generation_ids: (string)[] })[]; fail_patterns: ({ title: string; description: string; frequency: string; ex...
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### `posthog.llmAnalyticsOfflineEvaluationsExperimentItemsCreate`
|
|
320
|
+
|
|
321
|
+
- **HTTP**: `POST /api/projects/{project_id}/llm_analytics/offline_evaluations/experiment_items/`
|
|
322
|
+
- **OpenAPI operationId**: `llm_analytics_offline_evaluations_experiment_items_create`
|
|
323
|
+
- **Path params**: None
|
|
324
|
+
- **Query params**: None
|
|
325
|
+
- **Response codes**: `200`, `400`, `500`
|
|
326
|
+
- **Transport options**: None
|
|
327
|
+
- **TypeScript**: [Client interface](../types.ts)
|
|
328
|
+
|
|
329
|
+
**Inputs**
|
|
330
|
+
|
|
331
|
+
- Client input type: `{ [key: string]: unknown }`
|
|
332
|
+
- Client transport options: None
|
|
333
|
+
|
|
334
|
+
**Outputs**
|
|
335
|
+
|
|
336
|
+
- Client return type: `{ results: ((unknown)[])[] }`
|
|
337
|
+
- OpenAPI response codes: `200`, `400`, `500`
|
|
338
|
+
|
|
339
|
+
```ts
|
|
340
|
+
import posthog from "@utdk/posthog";
|
|
341
|
+
|
|
342
|
+
type LlmAnalyticsOfflineEvaluationsExperimentItemsCreateInput = Parameters<typeof posthog.llmAnalyticsOfflineEvaluationsExperimentItemsCreate> extends [infer T, ...unknown[]] ? T : undefined;
|
|
343
|
+
type LlmAnalyticsOfflineEvaluationsExperimentItemsCreateOutput = Awaited<ReturnType<typeof posthog.llmAnalyticsOfflineEvaluationsExperimentItemsCreate>>;
|
|
344
|
+
|
|
345
|
+
const result: LlmAnalyticsOfflineEvaluationsExperimentItemsCreateOutput = await posthog.llmAnalyticsOfflineEvaluationsExperimentItemsCreate();
|
|
346
|
+
|
|
347
|
+
// Result shape (from schema): { results: ((unknown)[])[] }
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### `posthog.llmAnalyticsSummarizationCreate`
|
|
351
|
+
|
|
352
|
+
- **HTTP**: `POST /api/projects/{project_id}/llm_analytics/summarization/`
|
|
353
|
+
- **What it does**:
|
|
354
|
+
Generate an AI-powered summary of an LLM trace or event.
|
|
355
|
+
|
|
356
|
+
This endpoint analyzes the provided trace/event, generates a line-numbered text
|
|
357
|
+
representation, and uses an LLM to create a concise summary with line references.
|
|
358
|
+
|
|
359
|
+
**Two ways to use this endpoint:**
|
|
360
|
+
|
|
361
|
+
1. **By ID (recommended):** Pass `trace_id` or `generation_id` with an optional `date_from`/`date_to`.
|
|
362
|
+
The backend fetches the data automatically. `summarize_type` is inferred.
|
|
363
|
+
2. **By data:** Pass the full trace/event data blob in `data` with `summarize_type`.
|
|
364
|
+
This is how the frontend uses it.
|
|
365
|
+
|
|
366
|
+
**Summary Format:**
|
|
367
|
+
- Title (concise, max 10 words)
|
|
368
|
+
- Mermaid flow diagram showing the main flow
|
|
369
|
+
- 3-10 summary bullets with line references
|
|
370
|
+
- "Interesting Notes" section for failures, successes, or unusual patterns
|
|
371
|
+
- Line references in [L45] or [L45-52] format pointing to relevant sections
|
|
372
|
+
|
|
373
|
+
The response includes the structured summary, the text representation, and metadata.
|
|
374
|
+
|
|
375
|
+
- **OpenAPI operationId**: `llm_analytics_summarization_create`
|
|
376
|
+
- **Path params**: None
|
|
377
|
+
- **Query params**: None
|
|
378
|
+
- **Response codes**: `200`, `400`, `403`, `500`
|
|
379
|
+
- **Transport options**: None
|
|
380
|
+
- **TypeScript**: [Client interface](../types.ts)
|
|
381
|
+
|
|
382
|
+
**Inputs**
|
|
383
|
+
|
|
384
|
+
- Client input type: `{ [key: string]: unknown }`
|
|
385
|
+
- Client transport options: None
|
|
386
|
+
|
|
387
|
+
**Outputs**
|
|
388
|
+
|
|
389
|
+
- Client return type: `{ summary: { title: string; flow_diagram: string; summary_bullets: ({ text: string; line_refs: string })[]; interesting_notes: ({ text: string; line_refs: string })[] }; text_repr: string; metadata?: unknown }`
|
|
390
|
+
- OpenAPI response codes: `200`, `400`, `403`, `500`
|
|
391
|
+
|
|
392
|
+
```ts
|
|
393
|
+
import posthog from "@utdk/posthog";
|
|
394
|
+
|
|
395
|
+
type LlmAnalyticsSummarizationCreateInput = Parameters<typeof posthog.llmAnalyticsSummarizationCreate> extends [infer T, ...unknown[]] ? T : undefined;
|
|
396
|
+
type LlmAnalyticsSummarizationCreateOutput = Awaited<ReturnType<typeof posthog.llmAnalyticsSummarizationCreate>>;
|
|
397
|
+
|
|
398
|
+
const result: LlmAnalyticsSummarizationCreateOutput = await posthog.llmAnalyticsSummarizationCreate();
|
|
399
|
+
|
|
400
|
+
// Result shape (from schema): { summary: { title: string; flow_diagram: string; summary_bullets: ({ text: string; line_refs: string })[]; interesting_notes: ({ text: string; line_refs: string })[] }; text_repr: string; metadata?: unknown }
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### `posthog.llmAnalyticsSummarizationBatchCheckCreate`
|
|
404
|
+
|
|
405
|
+
- **HTTP**: `POST /api/projects/{project_id}/llm_analytics/summarization/batch_check/`
|
|
406
|
+
- **What it does**:
|
|
407
|
+
Check which traces have cached summaries available.
|
|
408
|
+
|
|
409
|
+
This endpoint allows batch checking of multiple trace IDs to see which ones
|
|
410
|
+
have cached summaries. Returns only the traces that have cached summaries
|
|
411
|
+
with their titles.
|
|
412
|
+
|
|
413
|
+
**Use Cases:**
|
|
414
|
+
- Load cached summaries on session view load
|
|
415
|
+
- Avoid unnecessary LLM calls for already-summarized traces
|
|
416
|
+
- Display summary previews without generating new summaries
|
|
417
|
+
|
|
418
|
+
- **OpenAPI operationId**: `llm_analytics_summarization_batch_check_create`
|
|
419
|
+
- **Path params**: None
|
|
420
|
+
- **Query params**: None
|
|
421
|
+
- **Response codes**: `200`, `400`, `403`
|
|
422
|
+
- **Transport options**: None
|
|
423
|
+
- **TypeScript**: [Client interface](../types.ts)
|
|
424
|
+
|
|
425
|
+
**Inputs**
|
|
426
|
+
|
|
427
|
+
- Client input type: `{ [key: string]: unknown }`
|
|
428
|
+
- Client transport options: None
|
|
429
|
+
|
|
430
|
+
**Outputs**
|
|
431
|
+
|
|
432
|
+
- Client return type: `{ summaries: ({ trace_id: string; title: string; cached?: boolean })[] }`
|
|
433
|
+
- OpenAPI response codes: `200`, `400`, `403`
|
|
434
|
+
|
|
435
|
+
```ts
|
|
436
|
+
import posthog from "@utdk/posthog";
|
|
437
|
+
|
|
438
|
+
type LlmAnalyticsSummarizationBatchCheckCreateInput = Parameters<typeof posthog.llmAnalyticsSummarizationBatchCheckCreate> extends [infer T, ...unknown[]] ? T : undefined;
|
|
439
|
+
type LlmAnalyticsSummarizationBatchCheckCreateOutput = Awaited<ReturnType<typeof posthog.llmAnalyticsSummarizationBatchCheckCreate>>;
|
|
440
|
+
|
|
441
|
+
const result: LlmAnalyticsSummarizationBatchCheckCreateOutput = await posthog.llmAnalyticsSummarizationBatchCheckCreate();
|
|
442
|
+
|
|
443
|
+
// Result shape (from schema): { summaries: ({ trace_id: string; title: string; cached?: boolean })[] }
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### `posthog.llmAnalyticsTextReprCreate`
|
|
447
|
+
|
|
448
|
+
- **HTTP**: `POST /api/projects/{project_id}/llm_analytics/text_repr/`
|
|
449
|
+
- **What it does**:
|
|
450
|
+
Generate a human-readable text representation of an LLM trace event.
|
|
451
|
+
|
|
452
|
+
This endpoint converts AI observability events ($ai_generation, $ai_span, $ai_embedding, or $ai_trace)
|
|
453
|
+
into formatted text representations suitable for display, logging, or analysis.
|
|
454
|
+
|
|
455
|
+
**Supported Event Types:**
|
|
456
|
+
- `$ai_generation`: Individual LLM API calls with input/output messages
|
|
457
|
+
- `$ai_span`: Logical spans with state transitions
|
|
458
|
+
- `$ai_embedding`: Embedding generation events (text input → vector)
|
|
459
|
+
- `$ai_trace`: Full traces with hierarchical structure
|
|
460
|
+
|
|
461
|
+
**Options:**
|
|
462
|
+
- `max_length`: Maximum character count (default: 2000000)
|
|
463
|
+
- `truncated`: Enable middle-content truncation within events (default: true)
|
|
464
|
+
- `truncate_buffer`: Characters at start/end when truncating (default: 1000)
|
|
465
|
+
- `include_markers`: Use interactive markers vs plain text indicators (default: true)
|
|
466
|
+
- Frontend: set true for `<<<TRUNCATED|base64|...>>>` markers
|
|
467
|
+
- Backend/LLM: set false for `... (X chars truncated) ...` text
|
|
468
|
+
- `collapsed`: Show summary vs full trace tree (default: false)
|
|
469
|
+
- `include_hierarchy`: Include tree structure for traces (default: true)
|
|
470
|
+
- `max_depth`: Maximum depth for hierarchical rendering (default: unlimited)
|
|
471
|
+
- `tools_collapse_threshold`: Number of tools before auto-collapsing list (default: 5)
|
|
472
|
+
- Tool lists >5 items show `<<<TOOLS_EXPANDABLE|...>>>` marker for frontend
|
|
473
|
+
- Or `[+] AVAILABLE TOOLS: N` for backend when `include_markers: false`
|
|
474
|
+
- `include_line_numbers`: Prefix each line with line number like L001:, L010: (default: false)
|
|
475
|
+
|
|
476
|
+
**Use Cases:**
|
|
477
|
+
- Frontend display: `truncated: true, include_markers: true, include_line_numbers: true`
|
|
478
|
+
- Backend LLM context (summary): `truncated: true, include_markers: false, collapsed: true`
|
|
479
|
+
- Backend LLM context (full): `truncated: false`
|
|
480
|
+
|
|
481
|
+
The response includes the formatted text and metadata about the rendering.
|
|
482
|
+
|
|
483
|
+
- **OpenAPI operationId**: `llm_analytics_text_repr_create`
|
|
484
|
+
- **Path params**: None
|
|
485
|
+
- **Query params**: None
|
|
486
|
+
- **Response codes**: `200`, `400`, `500`, `503`
|
|
487
|
+
- **Transport options**: None
|
|
488
|
+
- **TypeScript**: [Client interface](../types.ts)
|
|
489
|
+
|
|
490
|
+
**Inputs**
|
|
491
|
+
|
|
492
|
+
- Client input type: `{ [key: string]: unknown }`
|
|
493
|
+
- Client transport options: None
|
|
494
|
+
|
|
495
|
+
**Outputs**
|
|
496
|
+
|
|
497
|
+
- Client return type: `{ text: string; metadata: { event_type?: string; event_id?: string; trace_id?: string; rendering: string; char_count: number; truncated: boolean; error?: string } }`
|
|
498
|
+
- OpenAPI response codes: `200`, `400`, `500`, `503`
|
|
499
|
+
|
|
500
|
+
```ts
|
|
501
|
+
import posthog from "@utdk/posthog";
|
|
502
|
+
|
|
503
|
+
type LlmAnalyticsTextReprCreateInput = Parameters<typeof posthog.llmAnalyticsTextReprCreate> extends [infer T, ...unknown[]] ? T : undefined;
|
|
504
|
+
type LlmAnalyticsTextReprCreateOutput = Awaited<ReturnType<typeof posthog.llmAnalyticsTextReprCreate>>;
|
|
505
|
+
|
|
506
|
+
const result: LlmAnalyticsTextReprCreateOutput = await posthog.llmAnalyticsTextReprCreate();
|
|
507
|
+
|
|
508
|
+
// Result shape (from schema): { text: string; metadata: { event_type?: string; event_id?: string; trace_id?: string; rendering: string; char_count: number; truncated: boolean; error?: string } }
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
<!-- prompt-hash:
|
|
513
|
+
8c3694991a4c289225f05a4e8f1e098cc74d085a088d7dffd82f00d93797b7f8
|
|
514
|
+
-->
|