Llm

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

Endpoints

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

Create llm skills name files rename

Required API key scopes

llm_skill:write

Path parameters

  • skill_name
    string

Request parameters

  • old_path
    string
  • new_path
    string
  • base_version
    integer

Response


Example request

POST /api/environments/:project_id/llm_skills/name/:skill_name/files-rename
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_skills/name/:skill_name/files-rename/\
-d old_path="string",\
-d new_path="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"description": "string",
"body": "string",
"license": "string",
"compatibility": "string",
"allowed_tools": [
"string"
],
"metadata": {},
"files": [
{
"path": "string",
"content_type": "string"
}
],
"outline": [
{
"level": 1,
"text": "string"
}
],
"version": 0,
"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"
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"deleted": true,
"is_latest": true,
"latest_version": 0,
"version_count": 0,
"first_version_created_at": "string"
}

Retrieve llm skills name files

Required API key scopes

llm_skill:read

Path parameters

  • file_path
    string
  • skill_name
    string

Query parameters

  • version
    integer

Response


Example request

GET /api/environments/:project_id/llm_skills/name/:skill_name/files/:file_path
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_skills/name/:skill_name/files/:file_path/

Example response

Status 200
RESPONSE
{
"path": "string",
"content": "string",
"content_type": "string"
}

Delete llm skills name files

Required API key scopes

llm_skill:write

Path parameters

  • file_path
    string
  • skill_name
    string

Query parameters

  • base_version
    integer

Response


Example request

DELETE /api/environments/:project_id/llm_skills/name/:skill_name/files/:file_path
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_skills/name/:skill_name/files/:file_path/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"description": "string",
"body": "string",
"license": "string",
"compatibility": "string",
"allowed_tools": [
"string"
],
"metadata": {},
"files": [
{
"path": "string",
"content_type": "string"
}
],
"outline": [
{
"level": 1,
"text": "string"
}
],
"version": 0,
"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"
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"deleted": true,
"is_latest": true,
"latest_version": 0,
"version_count": 0,
"first_version_created_at": "string"
}

Retrieve llm skills resolve name

Required API key scopes

llm_skill:read

Path parameters

  • skill_name
    string

Query parameters

  • before_version
    integer
  • limit
    integer
    Default: 50
  • offset
    integer
  • version
    integer
  • version_id
    string

Response


Example request

GET /api/environments/:project_id/llm_skills/resolve/name/:skill_name
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_skills/resolve/name/:skill_name/

Example response

Status 200
RESPONSE
{
"skill": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"description": "string",
"body": "string",
"license": "string",
"compatibility": "string",
"allowed_tools": [
"string"
],
"metadata": {},
"files": [
{
"path": "string",
"content_type": "string"
}
],
"outline": [
{
"level": 1,
"text": "string"
}
],
"version": 0,
"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"
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"deleted": true,
"is_latest": true,
"latest_version": 0,
"version_count": 0,
"first_version_created_at": "string"
},
"versions": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"version": 0,
"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"
},
"created_at": "2019-08-24T14:15:22Z",
"is_latest": true
}
],
"has_more": true
}

List all llm analytics personal spend

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 / trace breakdowns to a single product; supported values: posthog_code. by_product is always returned for cross-product visibility. Use refresh=true to bypass the 5-minute response cache.

Required API key scopes

user:read

Query parameters

  • date_from
    string
    Default: -30d
  • date_to
    stringnull
  • limit
    integer
    Default: 50
  • product
    string
  • refresh
    boolean
    Default: false

Example request

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

Example response

Status 200
RESPONSE
{
"summary": {
"date_from": "2019-08-24T14:15:22Z",
"date_to": "2019-08-24T14:15:22Z",
"product": "string",
"total_cost_usd": 0.1,
"event_count": 0,
"scoped_cost_usd": 0.1,
"scoped_event_count": 0
},
"by_product": {
"items": [
{
"product": "string",
"event_count": 0,
"cost_usd": 0.1
}
],
"truncated": true
},
"by_tool": {
"items": [
{
"tool": "string",
"generation_count": 0,
"cost_usd": 0.1,
"share_of_scoped": 0.1,
"avg_input_tokens": 0.1
}
],
"truncated": true
},
"by_model": {
"items": [
{
"model": "string",
"generation_count": 0,
"cost_usd": 0.1,
"input_tokens": 0,
"output_tokens": 0
}
],
"truncated": true
},
"top_traces": {
"items": [
{
"trace_id": "string",
"generation_count": 0,
"cost_usd": 0.1,
"started_at": "2019-08-24T14:15:22Z"
}
],
"truncated": true
}
}
Status 400
RESPONSE
{
"detail": "string"
}
Status 401
RESPONSE
{
"detail": "string"
}
Status 403
RESPONSE
{
"detail": "string"
}
Status 404
RESPONSE
{
"detail": "string"
}
Status 429
RESPONSE
{
"detail": "string"
}

List all dataset items

Required API key scopes

dataset:read

Query parameters

  • dataset
    string
  • limit
    integer
  • offset
    integer

Response


Example request

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

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",
"dataset": "d93f2be0-02b1-4d87-8b6e-fc5cba21ed8d",
"input": null,
"output": null,
"metadata": null,
"ref_trace_id": "string",
"ref_timestamp": "2019-08-24T14:15:22Z",
"ref_source_id": "string",
"deleted": true,
"created_at": "2019-08-24T14:15:22Z",
"updated_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"
},
"team": 0
}
]
}

Create dataset items

Required API key scopes

dataset:write

Request parameters

  • dataset
    string
  • input
  • output
  • metadata
  • ref_trace_id
    stringnull
  • ref_timestamp
    stringnull
  • ref_source_id
    stringnull
  • deleted
    booleannull

Response


Example request

POST /api/projects/:project_id/dataset_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/dataset_items/\
-d dataset="string"

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"dataset": "d93f2be0-02b1-4d87-8b6e-fc5cba21ed8d",
"input": null,
"output": null,
"metadata": null,
"ref_trace_id": "string",
"ref_timestamp": "2019-08-24T14:15:22Z",
"ref_source_id": "string",
"deleted": true,
"created_at": "2019-08-24T14:15:22Z",
"updated_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"
},
"team": 0
}

Retrieve dataset items

Required API key scopes

dataset:read

Path parameters

  • id
    string

Response


Example request

GET /api/projects/:project_id/dataset_items/: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/dataset_items/:id/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"dataset": "d93f2be0-02b1-4d87-8b6e-fc5cba21ed8d",
"input": null,
"output": null,
"metadata": null,
"ref_trace_id": "string",
"ref_timestamp": "2019-08-24T14:15:22Z",
"ref_source_id": "string",
"deleted": true,
"created_at": "2019-08-24T14:15:22Z",
"updated_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"
},
"team": 0
}

Update dataset items

Required API key scopes

dataset:write

Path parameters

  • id
    string

Request parameters

  • dataset
    string
  • input
  • output
  • metadata
  • ref_trace_id
    stringnull
  • ref_timestamp
    stringnull
  • ref_source_id
    stringnull
  • deleted
    booleannull

Response


Example request

PATCH /api/projects/:project_id/dataset_items/: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/dataset_items/:id/\
-d dataset="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"dataset": "d93f2be0-02b1-4d87-8b6e-fc5cba21ed8d",
"input": null,
"output": null,
"metadata": null,
"ref_trace_id": "string",
"ref_timestamp": "2019-08-24T14:15:22Z",
"ref_source_id": "string",
"deleted": true,
"created_at": "2019-08-24T14:15:22Z",
"updated_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"
},
"team": 0
}

Delete dataset items

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

Required API key scopes

dataset:write

Path parameters

  • id
    string

Example request

DELETE /api/projects/:project_id/dataset_items/: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/dataset_items/:id/

Example response

Status 405 No response body

List all datasets

Required API key scopes

dataset:read

Query parameters

  • id__in
    array
  • limit
    integer
  • offset
    integer
  • order_by
    array
  • search
    string

Response


Example request

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

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",
"description": "string",
"metadata": null,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"deleted": true,
"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"
},
"team": 0
}
]
}

Create datasets

Required API key scopes

dataset:write

Request parameters

  • name
    string
  • description
    stringnull
  • metadata
  • deleted
    booleannull

Response


Example request

POST /api/projects/:project_id/datasets
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/datasets/\
-d name="string"

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"description": "string",
"metadata": null,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"deleted": true,
"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"
},
"team": 0
}

Retrieve datasets

Required API key scopes

dataset:read

Path parameters

  • id
    string

Response


Example request

GET /api/projects/:project_id/datasets/: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/datasets/:id/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"description": "string",
"metadata": null,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"deleted": true,
"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"
},
"team": 0
}

Update datasets

Required API key scopes

dataset:write

Path parameters

  • id
    string

Request parameters

  • name
    string
  • description
    stringnull
  • metadata
  • deleted
    booleannull

Response


Example request

PATCH /api/projects/:project_id/datasets/: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/datasets/:id/\
-d name="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"description": "string",
"metadata": null,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"deleted": true,
"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"
},
"team": 0
}

Delete datasets

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

Required API key scopes

dataset:write

Path parameters

  • id
    string

Example request

DELETE /api/projects/:project_id/datasets/: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/datasets/:id/

Example response

Status 405 No response body

Community questions

Questions about this page? or post a community question.