Llm

For instructions on how to authenticate to use this endpoint, see API overview.

Endpoints

POST
GET
POST
GET
PATCH
DELETE
GET
POST
GET
POST
GET
PATCH
DELETE
POST
GET
POST
GET
POST

Create llm analytics clustering config set event filters

Team-level clustering configuration (event filters for automated pipelines).

Required API key scopes

llm_analytics:write

Example request

POST /api/projects/:project_id/llm_analytics/clustering_config/set_event_filters
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/clustering_config/set_event_filters/

Example response

Status 200

List all llm analytics clustering jobs

CRUD for clustering job configurations (max 5 per team).

Required API key scopes

llm_analytics:read

Query parameters

  • limit
    integer
  • offset
    integer

Response


Example request

GET /api/projects/:project_id/llm_analytics/clustering_jobs
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/clustering_jobs/

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?offset=400&limit=100",
"previous": "http://api.example.org/accounts/?offset=200&limit=100",
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"analysis_level": "trace",
"event_filters": null,
"enabled": true,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}
]
}

Create llm analytics clustering jobs

CRUD for clustering job configurations (max 5 per team).

Required API key scopes

llm_analytics:write

Request parameters

  • name
    string
  • analysis_level
  • event_filters
  • enabled
    boolean

Response


Example request

POST /api/projects/:project_id/llm_analytics/clustering_jobs
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/clustering_jobs/\
-d name="string",\
-d analysis_level=undefined

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"analysis_level": "trace",
"event_filters": null,
"enabled": true,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}

Retrieve llm analytics clustering jobs

CRUD for clustering job configurations (max 5 per team).

Required API key scopes

llm_analytics:read

Path parameters

  • id
    string

Response


Example request

GET /api/projects/:project_id/llm_analytics/clustering_jobs/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/clustering_jobs/:id/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"analysis_level": "trace",
"event_filters": null,
"enabled": true,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}

Update llm analytics clustering jobs

CRUD for clustering job configurations (max 5 per team).

Required API key scopes

llm_analytics:write

Path parameters

  • id
    string

Request parameters

  • name
    string
  • analysis_level
  • event_filters
  • enabled
    boolean

Response


Example request

PATCH /api/projects/:project_id/llm_analytics/clustering_jobs/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/clustering_jobs/:id/\
-d name="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"analysis_level": "trace",
"event_filters": null,
"enabled": true,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}

Delete llm analytics clustering jobs

CRUD for clustering job configurations (max 5 per team).

Required API key scopes

llm_analytics:write

Path parameters

  • id
    string

Example request

DELETE /api/projects/:project_id/llm_analytics/clustering_jobs/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X DELETE \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/clustering_jobs/:id/

Example response

Status 204 No response body

Retrieve llm analytics evaluation config

Get the evaluation config for this team

Required API key scopes

evaluation:read

Response


Example request

GET /api/projects/:project_id/llm_analytics/evaluation_config
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/evaluation_config/

Example response

Status 200
RESPONSE
{
"trial_eval_limit": 0,
"trial_evals_used": 0,
"trial_evals_remaining": 0,
"active_provider_key": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"provider": "openai",
"name": "string",
"state": "unknown",
"error_message": "string",
"api_key": "string",
"api_key_masked": "string",
"azure_endpoint": "http://example.com",
"api_version": "string",
"azure_endpoint_display": "string",
"api_version_display": "string",
"set_as_active": false,
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"last_used_at": "2019-08-24T14:15:22Z"
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}

Create llm analytics evaluation config set active key

Set the active provider key for evaluations

Required API key scopes

evaluation:write

Request parameters

  • key_id
    string

Response


Example request

POST /api/projects/:project_id/llm_analytics/evaluation_config/set_active_key
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/evaluation_config/set_active_key/\
-d key_id="string"

Example response

Status 200
RESPONSE
{
"trial_eval_limit": 0,
"trial_evals_used": 0,
"trial_evals_remaining": 0,
"active_provider_key": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"provider": "openai",
"name": "string",
"state": "unknown",
"error_message": "string",
"api_key": "string",
"api_key_masked": "string",
"azure_endpoint": "http://example.com",
"api_version": "string",
"azure_endpoint_display": "string",
"api_version_display": "string",
"set_as_active": false,
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"last_used_at": "2019-08-24T14:15:22Z"
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}

List all llm analytics evaluation reports

CRUD for evaluation report configurations + report run history.

Required API key scopes

llm_analytics:read

Query parameters

  • limit
    integer
  • offset
    integer

Response


Example request

GET /api/projects/:project_id/llm_analytics/evaluation_reports
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/evaluation_reports/

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?offset=400&limit=100",
"previous": "http://api.example.org/accounts/?offset=200&limit=100",
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"evaluation": "8b4883eb-9190-4e70-bfb9-71682af8a50b",
"frequency": "scheduled",
"rrule": "string",
"starts_at": "2019-08-24T14:15:22Z",
"timezone_name": "string",
"next_delivery_date": "2019-08-24T14:15:22Z",
"delivery_targets": null,
"max_sample_size": -2147483648,
"enabled": true,
"deleted": true,
"last_delivered_at": "2019-08-24T14:15:22Z",
"report_prompt_guidance": "string",
"trigger_threshold": 10,
"cooldown_minutes": 60,
"daily_run_cap": 1,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z"
}
]
}

Create llm analytics evaluation reports

CRUD for evaluation report configurations + report run history.

Required API key scopes

llm_analytics:write

Request parameters

  • evaluation
    string
  • frequency
  • rrule
    string
  • starts_at
    stringnull
  • timezone_name
    string
  • delivery_targets
  • max_sample_size
    integer
  • enabled
    boolean
  • deleted
    boolean
  • report_prompt_guidance
    string
  • trigger_threshold
    integernull
  • cooldown_minutes
    integer
  • daily_run_cap
    integer

Response


Example request

POST /api/projects/:project_id/llm_analytics/evaluation_reports
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/evaluation_reports/\
-d evaluation="string"

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"evaluation": "8b4883eb-9190-4e70-bfb9-71682af8a50b",
"frequency": "scheduled",
"rrule": "string",
"starts_at": "2019-08-24T14:15:22Z",
"timezone_name": "string",
"next_delivery_date": "2019-08-24T14:15:22Z",
"delivery_targets": null,
"max_sample_size": -2147483648,
"enabled": true,
"deleted": true,
"last_delivered_at": "2019-08-24T14:15:22Z",
"report_prompt_guidance": "string",
"trigger_threshold": 10,
"cooldown_minutes": 60,
"daily_run_cap": 1,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z"
}

Retrieve llm analytics evaluation reports

CRUD for evaluation report configurations + report run history.

Required API key scopes

llm_analytics:read

Path parameters

  • id
    string

Response


Example request

GET /api/projects/:project_id/llm_analytics/evaluation_reports/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/evaluation_reports/:id/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"evaluation": "8b4883eb-9190-4e70-bfb9-71682af8a50b",
"frequency": "scheduled",
"rrule": "string",
"starts_at": "2019-08-24T14:15:22Z",
"timezone_name": "string",
"next_delivery_date": "2019-08-24T14:15:22Z",
"delivery_targets": null,
"max_sample_size": -2147483648,
"enabled": true,
"deleted": true,
"last_delivered_at": "2019-08-24T14:15:22Z",
"report_prompt_guidance": "string",
"trigger_threshold": 10,
"cooldown_minutes": 60,
"daily_run_cap": 1,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z"
}

Update llm analytics evaluation reports

CRUD for evaluation report configurations + report run history.

Required API key scopes

llm_analytics:write

Path parameters

  • id
    string

Request parameters

  • evaluation
    string
  • frequency
  • rrule
    string
  • starts_at
    stringnull
  • timezone_name
    string
  • delivery_targets
  • max_sample_size
    integer
  • enabled
    boolean
  • deleted
    boolean
  • report_prompt_guidance
    string
  • trigger_threshold
    integernull
  • cooldown_minutes
    integer
  • daily_run_cap
    integer

Response


Example request

PATCH /api/projects/:project_id/llm_analytics/evaluation_reports/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/evaluation_reports/:id/\
-d evaluation="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"evaluation": "8b4883eb-9190-4e70-bfb9-71682af8a50b",
"frequency": "scheduled",
"rrule": "string",
"starts_at": "2019-08-24T14:15:22Z",
"timezone_name": "string",
"next_delivery_date": "2019-08-24T14:15:22Z",
"delivery_targets": null,
"max_sample_size": -2147483648,
"enabled": true,
"deleted": true,
"last_delivered_at": "2019-08-24T14:15:22Z",
"report_prompt_guidance": "string",
"trigger_threshold": 10,
"cooldown_minutes": 60,
"daily_run_cap": 1,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z"
}

Delete llm analytics evaluation reports

Hard delete of this model is not allowed. Use a patch API call to set "deleted" to true

Required API key scopes

llm_analytics:write

Path parameters

  • id
    string

Example request

DELETE /api/projects/:project_id/llm_analytics/evaluation_reports/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X DELETE \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/evaluation_reports/:id/

Example response

Status 405 No response body

Create llm analytics evaluation reports generate

Trigger immediate report generation.

Required API key scopes

llm_analytics:write

Path parameters

  • id
    string

Example request

POST /api/projects/:project_id/llm_analytics/evaluation_reports/:id/generate
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/evaluation_reports/:id/generate/

Example response

Status 202 No response body

List all llm analytics evaluation reports runs

List report runs (history) for this report.

Required API key scopes

llm_analytics:read

Path parameters

  • id
    string

Query parameters

  • limit
    integer
  • offset
    integer

Response


Example request

GET /api/projects/:project_id/llm_analytics/evaluation_reports/:id/runs
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/evaluation_reports/:id/runs/

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?offset=400&limit=100",
"previous": "http://api.example.org/accounts/?offset=200&limit=100",
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"report": "838f2834-0545-48a4-b96c-dd2824df22eb",
"content": null,
"metadata": null,
"period_start": "2019-08-24T14:15:22Z",
"period_end": "2019-08-24T14:15:22Z",
"delivery_status": "pending",
"delivery_errors": null,
"created_at": "2019-08-24T14:15:22Z"
}
]
}

Create llm analytics evaluation summary

Generate an AI-powered summary of evaluation results.

This endpoint analyzes evaluation runs and identifies patterns in passing and failing evaluations, providing actionable recommendations.

Data is fetched server-side by evaluation ID to ensure data integrity.

Use Cases:

  • Understand why evaluations are passing or failing
  • Identify systematic issues in LLM responses
  • Get recommendations for improving response quality
  • Review patterns across many evaluation runs at once

Required API key scopes

llm_analytics:write

Request parameters

  • evaluation_id
    string
  • filter
    Default: all
  • generation_ids
    array
  • force_refresh
    boolean
    Default: false

Response


Example request

POST /api/projects/:project_id/llm_analytics/evaluation_summary
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/evaluation_summary/\
-d evaluation_id="string"

Example response

Status 200
RESPONSE
{
"overall_assessment": "Evaluations show generally good quality with some factual accuracy issues.",
"pass_patterns": [
{
"title": "Clear Communication",
"description": "Responses consistently provided well-structured information",
"frequency": "common",
"example_generation_ids": [
"gen_abc123",
"gen_ghi789"
]
}
],
"fail_patterns": [
{
"title": "Factual Errors",
"description": "Some responses contained inaccurate information",
"frequency": "occasional",
"example_generation_ids": [
"gen_def456"
]
}
],
"na_patterns": [],
"recommendations": [
"Implement fact-checking for critical claims",
"Add source citations where applicable"
],
"statistics": {
"total_analyzed": 3,
"pass_count": 2,
"fail_count": 1,
"na_count": 0
}
}
Status 400
Status 403
Status 404
Status 500

Retrieve llm analytics models

List available models for a provider.

Required API key scopes

evaluation:read

Query parameters

  • key_id
    string
  • provider
    string
    One of: "anthropic""azure_openai""fireworks""gemini""openai""openrouter""together_ai"

Response


Example request

GET /api/projects/:project_id/llm_analytics/models
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/models/

Example response

Status 200
RESPONSE
{
"models": [
{
"id": "string",
"posthog_available": true
}
]
}

Create llm analytics offline evaluations experiment items

Required API key scopes

llm_analytics:read

Request parameters

  • experiment_id
    string
  • date_from
    stringnull
  • date_to
    stringnull

Response


Example request

POST /api/projects/:project_id/llm_analytics/offline_evaluations/experiment_items
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/llm_analytics/offline_evaluations/experiment_items/\
-d experiment_id="string"

Example response

Status 200
RESPONSE
{
"results": [
[
null
]
]
}
Status 400
Status 500

Community questions

Questions about this page? or post a community question.