Introducing Confident Voice: Watch the Launch Video Now

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

ParameterTypeDescription
prompt_idstrRequired. 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

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.
triggerList[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_taskEvalTaskInputRequired. The evaluation the action runs. See EvalTaskInput.
enabledOptional[bool]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

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.
prompt_action_idstrRequired. The unique id of the prompt action.
triggerOptional[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_taskOptional[EvalTaskInput]The evaluation the action runs. See EvalTaskInput.
enabledOptional[bool]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

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.
prompt_action_idstrRequired. 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"}

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

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

These are the events that start the action.

See PromptActionTrigger.

Example: ["COMMIT"]

eval_taskEvalTaskRequired

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"

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.

PromptActionRef

A reference to a prompt action.

class PromptActionRef:
    id: str

idstrRequired

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"

COMMIT · VERSION · MERGE · PULL_REQUEST

Building a production pipeline?Design a scalable API workflow for evals, datasets, traces, and promptsTalk to an engineer

Last updated on

Built byConfident AI