LLM prompts

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

Endpoints

GET
POST
GET
PATCH
POST
POST
GET

List all llm prompts

Required API key scopes

llm_prompt:read

Path parameters

  • project_id
    string

Query parameters

  • content
    string
    Default: full
    One of: "full""preview""none"
  • limit
    integer
  • offset
    integer
  • search
    string

Response


Example request

GET /api/environments/:project_id/llm_prompts
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_prompts/

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",
"prompt": null,
"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": {
"property1": null,
"property2": null
},
"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",
"prompt_preview": "string",
"prompt_size_bytes": 0
}
]
}

Create llm prompts

Required API key scopes

llm_prompt:write

Path parameters

  • project_id
    string

Request parameters

  • name
    string
  • prompt

Response


Example request

POST /api/environments/:project_id/llm_prompts
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_prompts/\
-d name="string",\
-d prompt=undefined

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"prompt": null,
"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": {
"property1": null,
"property2": null
},
"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 prompts name

Required API key scopes

llm_prompt:read

Path parameters

  • project_id
    string
  • prompt_name
    string

Query parameters

  • version
    integer

Response


Example request

GET /api/environments/:project_id/llm_prompts/name/:prompt_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_prompts/name/:prompt_name/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"prompt": null,
"version": 0,
"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": "2019-08-24T14:15:22Z"
}

Update llm prompts name

Required API key scopes

llm_prompt:write

Path parameters

  • project_id
    string
  • prompt_name
    string

Request parameters

  • prompt
  • edits
    Click to open
    array
  • base_version
    integer

Response


Example request

PATCH /api/environments/:project_id/llm_prompts/name/:prompt_name
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_prompts/name/:prompt_name/\
-d prompt=undefined

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"prompt": null,
"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": {
"property1": null,
"property2": null
},
"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"
}

Create llm prompts name archive

Required API key scopes

llm_prompt:write

Path parameters

  • project_id
    string
  • prompt_name
    string

Request parameters

  • name
    string
  • prompt

Response


Example request

POST /api/environments/:project_id/llm_prompts/name/:prompt_name/archive
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_prompts/name/:prompt_name/archive/\
-d name="string",\
-d prompt=undefined

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"prompt": null,
"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": {
"property1": null,
"property2": null
},
"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"
}

Create llm prompts name duplicate

Required API key scopes

llm_prompt:write

Path parameters

  • project_id
    string
  • prompt_name
    string

Request parameters

  • new_name
    string

Response


Example request

POST /api/environments/:project_id/llm_prompts/name/:prompt_name/duplicate
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_prompts/name/:prompt_name/duplicate/\
-d new_name="string"

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"prompt": null,
"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": {
"property1": null,
"property2": null
},
"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 prompts resolve name

Required API key scopes

llm_prompt:read

Path parameters

  • project_id
    string
  • prompt_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_prompts/resolve/name/:prompt_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_prompts/resolve/name/:prompt_name/

Example response

Status 200
RESPONSE
{
"prompt": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"prompt": null,
"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": {
"property1": null,
"property2": null
},
"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": {
"property1": null,
"property2": null
},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"is_latest": true
}
],
"has_more": true
}

Community questions

Questions about this page? or post a community question.