provider experiments POST /api/projects/{project_id}/experiments/create_from_prompt/
@utdk/posthog /api/projects/{project_id}/experiments/create_from_prompt/
experiments_create_from_prompt_create
Create an experiment that compares N versions of an LLM prompt using a metric template. The user picks 2+ versions of an existing LLMPrompt and 1+ metric templates (cost / latency / eval_pass_rate). The endpoint builds the matching variants (control + test-N, each named after its prompt version) and attaches one metric per selected template, each scoped to the prompt's $ai_prompt_name. Resulting experiment is in draft state.
project_id path required
Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.
string

Try it

Authentication
Configure credentials for PostHog API
experimentsCreateFromPromptCreate
POST/api/projects/{project_id}/experiments/create_from_prompt/
Create an experiment that compares N versions of an LLM prompt using a metric template. The user picks 2+ versions of an existing LLMPrompt and 1+ metric templates (cost / latency / eval_pass_rate). The endpoint builds the matching variants (control + test-N, each named after its prompt version) and attaches one metric per selected template, each scoped to the prompt's $ai_prompt_name. Resulting experiment is in draft state.

Parameters

required

Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Input

required

The name of the LLM prompt to experiment on. Must already exist for this team.

required

Ordered list of prompt version numbers to assign to experiment variants. The first entry is the control variant. Must contain between 2 and 10 distinct versions.

required

One or more metric templates to attach as primary metrics. Each template becomes one metric on the experiment. Allowed values: cost, latency, eval_pass_rate.

Optional experiment name. If omitted, a name is generated from the prompt and versions.

Optional feature flag key. If omitted, a slug is derived from the experiment name.

Optional experiment description.

Configure credentials above to enable sending.

Code snippet
Updates live as you fill in the form above.

TypeScript

import posthog from '@utdk/posthog';

await posthog.experimentsCreateFromPromptCreate()