Managing Prompt Actions via Confident AI SDK
Overview
The Confident AI SDK exposes every Prompt Action method on the platform. This page documents how to call these methods in all supported languages. See the introduction to install the SDK and set your API key.
Methods
Get Actions
Lists the prompt actions on the prompt, newest first. A prompt action runs an evaluation automatically when something happens to the prompt, such as a new commit.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.prompts.get_actions(prompt_id="<PROMPT-ID>")For async mode, call a_get_actions and await it as shown below:
result = await client.prompts.a_get_actions(...)Parameters
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.prompts.getActions("<PROMPT-ID>");Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
Returns
This method returns an object of type PromptActionList.
Create Action
Creates a prompt action that runs an evaluation whenever one of its triggers happens to the prompt. The evaluation is created with the action, so its datasetId and evaluatorCollectionId must belong to your project, and its name must not already be taken by another evaluation in the project.
from confident_ai import ConfidentAI
from confident_ai.prompts import EvalTaskInput, PromptActionTrigger
client = ConfidentAI()
result = client.prompts.create_action(
prompt_id="<PROMPT-ID>",
trigger=[
PromptActionTrigger.COMMIT
],
eval_task=EvalTaskInput(
name="Greeting regression",
dataset_id="<DATASET-ID>",
evaluator_collection_id="<EVALUATOR-COLLECTION-ID>",
variable_mapping={"name": "input"}
),
enabled=True,
)For async mode, call a_create_action and await it as shown below:
result = await client.prompts.a_create_action(...)Parameters
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
trigger | List[PromptActionTrigger] | Required. The events that start the action. List each trigger once; the action runs whenever any of them happens to the prompt. See PromptActionTrigger. |
eval_task | EvalTaskInput | Required. The evaluation the action runs. See EvalTaskInput. |
enabled | Optional[bool] | Whether the action runs when triggered. Defaults to true on create; omit it to keep the current value when updating. |
import { ConfidentAI } from "confident-ai";
import { PromptActionTrigger } from "confident-ai/prompts";
const client = new ConfidentAI();
const result = await client.prompts.createAction(
"<PROMPT-ID>",
[
PromptActionTrigger.COMMIT
],
{
name: "Greeting regression",
datasetId: "<DATASET-ID>",
evaluatorCollectionId: "<EVALUATOR-COLLECTION-ID>",
variableMapping: { name: "input" }
},
true,
);Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
trigger | PromptActionTrigger[] | Required. The events that start the action. List each trigger once; the action runs whenever any of them happens to the prompt. See PromptActionTrigger. |
evalTask | EvalTaskInput | Required. The evaluation the action runs. See EvalTaskInput. |
enabled | boolean | Whether the action runs when triggered. Defaults to true on create; omit it to keep the current value when updating. |
Returns
This method returns an object of type PromptActionRef.
Update Action
Updates a prompt action and returns it. Send at least one field. When you send evalTask, name is required and its other fields you omit keep their stored values. The new dataset and evaluator collection must belong to your project, and the evaluation name must not be taken by another evaluation.
from confident_ai import ConfidentAI
from confident_ai.prompts import EvalTaskInput, PromptActionTrigger
client = ConfidentAI()
result = client.prompts.update_action(
prompt_id="<PROMPT-ID>",
prompt_action_id="<PROMPT-ACTION-ID>",
trigger=[
PromptActionTrigger.COMMIT
],
eval_task=EvalTaskInput(
name="Greeting regression",
dataset_id="<DATASET-ID>",
evaluator_collection_id="<EVALUATOR-COLLECTION-ID>",
variable_mapping={"name": "input"}
),
enabled=True,
)For async mode, call a_update_action and await it as shown below:
result = await client.prompts.a_update_action(...)Parameters
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
prompt_action_id | str | Required. The unique id of the prompt action. |
trigger | Optional[List[PromptActionTrigger]] | The events that start the action. List each trigger once; the action runs whenever any of them happens to the prompt. See PromptActionTrigger. |
eval_task | Optional[EvalTaskInput] | The evaluation the action runs. See EvalTaskInput. |
enabled | Optional[bool] | Whether the action runs when triggered. Defaults to true on create; omit it to keep the current value when updating. |
import { ConfidentAI } from "confident-ai";
import { PromptActionTrigger } from "confident-ai/prompts";
const client = new ConfidentAI();
const result = await client.prompts.updateAction(
"<PROMPT-ID>",
"<PROMPT-ACTION-ID>",
{
trigger: [
PromptActionTrigger.COMMIT
],
evalTask: {
name: "Greeting regression",
datasetId: "<DATASET-ID>",
evaluatorCollectionId: "<EVALUATOR-COLLECTION-ID>",
variableMapping: { name: "input" }
},
enabled: true
},
);Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
promptActionId | string | Required. The unique id of the prompt action. |
trigger | PromptActionTrigger[] | The events that start the action. List each trigger once; the action runs whenever any of them happens to the prompt. See PromptActionTrigger. |
evalTask | EvalTaskInput | The evaluation the action runs. See EvalTaskInput. |
enabled | boolean | Whether the action runs when triggered. Defaults to true on create; omit it to keep the current value when updating. |
Returns
This method returns an object of type PromptAction.
Delete Action
Permanently deletes a prompt action, and its evaluation when no other action uses it.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.prompts.delete_action(
prompt_id="<PROMPT-ID>",
prompt_action_id="<PROMPT-ACTION-ID>",
)For async mode, call a_delete_action and await it as shown below:
result = await client.prompts.a_delete_action(...)Parameters
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
prompt_action_id | str | Required. The unique id of the prompt action. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.prompts.deleteAction(
"<PROMPT-ID>",
"<PROMPT-ACTION-ID>",
);Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
promptActionId | string | Required. The unique id of the prompt action. |
Returns
This method returns an object of type PromptActionRef.
Types
EvalTask
The evaluation a prompt action runs.
class EvalTask:
id: str
name: str
dataset_id: Optional[str] = Field(alias="datasetId")
evaluator_collection_id: Optional[str] = Field(alias="evaluatorCollectionId")
variable_mapping: Optional[Dict[str, str]] = Field(alias="variableMapping")idstrRequired
This is the unique id of the evaluation.
Example: "<EVAL-TASK-ID>"
namestrRequired
This is the name of the evaluation, unique within your project.
Example: "Greeting regression"
dataset_idOptional[str]Required
This is the id of the dataset the prompt is evaluated against, or null when none is set.
Example: "<DATASET-ID>"
evaluator_collection_idOptional[str]Required
This is the id of the evaluator collection that scores the outputs, or null when none is set.
Example: "<EVALUATOR-COLLECTION-ID>"
variable_mappingOptional[Dict[str, str]]Required
This maps each prompt variable to the dataset field that fills it, or is null when none is set.
Example: {"name":"input"}
interface EvalTask {
id: string;
name: string;
datasetId: string | null;
evaluatorCollectionId: string | null;
variableMapping: Record<string, string> | null;
}idstringRequired
This is the unique id of the evaluation.
Example: "<EVAL-TASK-ID>"
namestringRequired
This is the name of the evaluation, unique within your project.
Example: "Greeting regression"
datasetIdstring | nullRequired
This is the id of the dataset the prompt is evaluated against, or null when none is set.
Example: "<DATASET-ID>"
evaluatorCollectionIdstring | nullRequired
This is the id of the evaluator collection that scores the outputs, or null when none is set.
Example: "<EVALUATOR-COLLECTION-ID>"
variableMappingRecord<string, string> | nullRequired
This maps each prompt variable to the dataset field that fills it, or is null when none is set.
Example: {"name":"input"}
EvalTaskInput
The evaluation a prompt action runs. name is always required; when updating, the other fields you omit keep their stored values.
class EvalTaskInput:
name: str
dataset_id: Optional[str] = Field(default=None, alias="datasetId")
evaluator_collection_id: Optional[str] = Field(default=None, alias="evaluatorCollectionId")
variable_mapping: Optional[Dict[str, str]] = Field(default=None, alias="variableMapping")namestrRequired
The name of the evaluation, unique within your project. Test runs the action starts are named after it.
Example: "Greeting regression"
dataset_idOptional[str]
The id of the dataset whose finalized goldens the prompt is evaluated against, or null for none. Omit it to keep the current dataset when updating. The action only runs once a dataset and an evaluator collection are both set.
Example: "<DATASET-ID>"
evaluator_collection_idOptional[str]
The id of the evaluator collection that scores the outputs, or null for none. Omit it to keep the current collection when updating.
Example: "<EVALUATOR-COLLECTION-ID>"
variable_mappingOptional[Dict[str, str]]
Maps each prompt variable to the dataset field that fills it, as { variable: field }. Send null to clear it, or omit it to keep the current mapping when updating.
Example: {"name":"input"}
interface EvalTaskInput {
name: string;
datasetId?: string | null;
evaluatorCollectionId?: string | null;
variableMapping?: Record<string, string> | null;
}namestringRequired
The name of the evaluation, unique within your project. Test runs the action starts are named after it.
Example: "Greeting regression"
datasetIdstring | null
The id of the dataset whose finalized goldens the prompt is evaluated against, or null for none. Omit it to keep the current dataset when updating. The action only runs once a dataset and an evaluator collection are both set.
Example: "<DATASET-ID>"
evaluatorCollectionIdstring | null
The id of the evaluator collection that scores the outputs, or null for none. Omit it to keep the current collection when updating.
Example: "<EVALUATOR-COLLECTION-ID>"
variableMappingRecord<string, string> | null
Maps each prompt variable to the dataset field that fills it, as { variable: field }. Send null to clear it, or omit it to keep the current mapping when updating.
Example: {"name":"input"}
PromptAction
An evaluation that runs automatically when something happens to the prompt.
class PromptAction:
id: str
prompt_id: str = Field(alias="promptId")
enabled: bool
trigger: List[PromptActionTrigger]
eval_task: EvalTask = Field(alias="evalTask")
created_at: str = Field(alias="createdAt")
updated_at: str = Field(alias="updatedAt")idstrRequired
This is the unique id of the prompt action.
Example: "<PROMPT-ACTION-ID>"
prompt_idstrRequired
This is the id of the prompt the action belongs to.
Example: "<PROMPT-ID>"
enabledboolRequired
Whether the action runs when triggered.
Example: true
triggerList[PromptActionTrigger]Required
eval_taskEvalTaskRequired
See EvalTask.
created_atstrRequired
When the action was created.
Example: "2025-01-18T16:45:00+00:00"
updated_atstrRequired
When the action was last changed.
Example: "2025-01-20T09:12:00+00:00"
interface PromptAction {
id: string;
promptId: string;
enabled: boolean;
trigger: PromptActionTrigger[];
evalTask: EvalTask;
createdAt: string;
updatedAt: string;
}idstringRequired
This is the unique id of the prompt action.
Example: "<PROMPT-ACTION-ID>"
promptIdstringRequired
This is the id of the prompt the action belongs to.
Example: "<PROMPT-ID>"
enabledbooleanRequired
Whether the action runs when triggered.
Example: true
triggerPromptActionTrigger[]Required
evalTaskEvalTaskRequired
See EvalTask.
createdAtstringRequired
When the action was created.
Example: "2025-01-18T16:45:00+00:00"
updatedAtstringRequired
When the action was last changed.
Example: "2025-01-20T09:12:00+00:00"
PromptActionList
The prompt actions on a prompt.
class PromptActionList:
prompt_actions: List[PromptAction] = Field(alias="promptActions")prompt_actionsList[PromptAction]Required
This is the list of prompt actions on the prompt, newest first.
See PromptAction.
interface PromptActionList {
promptActions: PromptAction[];
}promptActionsPromptAction[]Required
This is the list of prompt actions on the prompt, newest first.
See PromptAction.
PromptActionRef
A reference to a prompt action.
class PromptActionRef:
id: stridstrRequired
This is the unique id of the prompt action.
Example: "<PROMPT-ACTION-ID>"
interface PromptActionRef {
id: string;
}idstringRequired
This is the unique id of the prompt action.
Example: "<PROMPT-ACTION-ID>"
PromptActionTrigger
What happens to the prompt that starts the action. COMMIT is a new commit on any branch, VERSION is a version being released, MERGE is a branch being merged into main, and PULL_REQUEST is a pull request being opened.
class PromptActionTrigger(Enum):
COMMIT = "COMMIT"
VERSION = "VERSION"
MERGE = "MERGE"
PULL_REQUEST = "PULL_REQUEST"enum PromptActionTrigger {
COMMIT = "COMMIT",
VERSION = "VERSION",
MERGE = "MERGE",
PULL_REQUEST = "PULL_REQUEST",
}COMMIT · VERSION · MERGE · PULL_REQUEST
Last updated on