Llm

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

Endpoints

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

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/environments/: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/environments/:project_id/llm_analytics/evaluation_reports/:id/

Example response

Status 405 No response body

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/environments/: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/environments/: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/environments/: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/environments/:project_id/llm_analytics/evaluation_reports/:id/generate/

Example response

Status 202 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/environments/: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/environments/: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/environments/: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/environments/: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"
}
]
}

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/environments/: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/environments/: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/environments/: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/environments/: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/environments/: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/environments/: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/environments/: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/environments/:project_id/llm_analytics/offline_evaluations/experiment_items/\
-d experiment_id="string"

Example response

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

Create llm analytics provider key validations

Validate LLM provider API keys without persisting them

Required API key scopes

llm_provider_key:write

Example request

POST /api/environments/:project_id/llm_analytics/provider_key_validations
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/environments/:project_id/llm_analytics/provider_key_validations/

Example response

Status 200

List all llm analytics provider keys

Required API key scopes

llm_provider_key:read

Query parameters

  • limit
    integer
  • offset
    integer

Response


Example request

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

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",
"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"
}
]
}

Create llm analytics provider keys

Required API key scopes

llm_provider_key:write

Request parameters

  • provider
  • name
    string
  • api_key
    string
  • azure_endpoint
    string
  • api_version
    string
  • set_as_active
    boolean
    Default: false

Response


Example request

POST /api/environments/:project_id/llm_analytics/provider_keys
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/environments/:project_id/llm_analytics/provider_keys/\
-d provider=undefined,\
-d name="string"

Example response

Status 201
RESPONSE
{
"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"
}

Retrieve llm analytics provider keys

Required API key scopes

llm_provider_key:read

Path parameters

  • id
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"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"
}

Update llm analytics provider keys

Required API key scopes

llm_provider_key:write

Path parameters

  • id
    string

Request parameters

  • provider
  • name
    string
  • api_key
    string
  • azure_endpoint
    string
  • api_version
    string
  • set_as_active
    boolean
    Default: false

Response


Example request

PATCH /api/environments/:project_id/llm_analytics/provider_keys/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:project_id/llm_analytics/provider_keys/:id/\
-d provider=undefined

Example response

Status 200
RESPONSE
{
"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"
}

Delete llm analytics provider keys

Required API key scopes

llm_provider_key:write

Path parameters

  • id
    string

Example request

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

Example response

Status 204 No response body

Create llm analytics provider keys assign

Assign this key to evaluations and optionally re-enable them.

Path parameters

  • id
    string

Request parameters

  • provider
  • name
    string
  • api_key
    string
  • azure_endpoint
    string
  • api_version
    string
  • set_as_active
    boolean
    Default: false

Response


Example request

POST /api/environments/:project_id/llm_analytics/provider_keys/:id/assign
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/environments/:project_id/llm_analytics/provider_keys/:id/assign/\
-d provider=undefined,\
-d name="string"

Example response

Status 200
RESPONSE
{
"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"
}

Retrieve llm analytics provider keys dependent configs

Get evaluations using this key and alternative keys for replacement.

Path parameters

  • id
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"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"
}

Create llm analytics provider keys validate

Path parameters

  • id
    string

Request parameters

  • provider
  • name
    string
  • api_key
    string
  • azure_endpoint
    string
  • api_version
    string
  • set_as_active
    boolean
    Default: false

Response


Example request

POST /api/environments/:project_id/llm_analytics/provider_keys/:id/validate
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/environments/:project_id/llm_analytics/provider_keys/:id/validate/\
-d provider=undefined,\
-d name="string"

Example response

Status 200
RESPONSE
{
"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"
}

Retrieve llm analytics provider keys trial evaluations

List enabled evaluations currently using trial credits for a given provider.

Response


Example request

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

Example response

Status 200
RESPONSE
{
"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"
}

Community questions

Questions about this page? or post a community question.