Introducing Confident Monitor

Managing Journeys via Confident AI SDK

Every Journeys method in the Confident AI Python and TypeScript SDKs.

Overview

The Confident AI SDK exposes every Journey 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

List Journeys

Lists the journeys in your Confident AI project one page at a time, newest first. Each journey is returned with its id, name, and how many states and goldens it has; retrieve one by id to read its states, edges and paths.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.journeys.list(page=1, page_size=25)

For async mode, call a_list and await it as shown below:

result = await client.journeys.a_list(...)

Parameters

ParameterTypeDescription
pageOptional[int]The page to return. Defaults to 1.
page_sizeOptional[int]The number of journeys per page, at most 100. Defaults to 25.

Returns

This method returns an object of type JourneyList.

Create Journey

Creates a journey with a root Start state and returns its id. Build it out by adding states and edges, or send graphSource as ai to have Confident AI draft them for you in the background. Names are unique within a project; reusing one returns a 409.

from confident_ai import ConfidentAI
from confident_ai.journeys import JourneyGraphSource

client = ConfidentAI()

result = client.journeys.create(
    name="Refund request",
    description="A customer asks for a refund on a recent order. The agent verifies who they are, then either issues the refund or hands the conversation to a human.",
    graph_source=JourneyGraphSource.AI,
)

For async mode, call a_create and await it as shown below:

result = await client.journeys.a_create(...)

Parameters

ParameterTypeDescription
namestrRequired. The name of the journey, unique within the project.
descriptionOptional[str]What the user is trying to get done on this journey. When graphSource is ai, the draft is written from this and the name, so say how the conversation can end.
graph_sourceOptional[JourneyGraphSource]Send ai to have Confident AI draft the journey's states and edges in the background with your project's platform model. Omit it to start with only the root Start state. The draft lands shortly after the response, so retrieve the journey to see it; if drafting fails, the journey keeps only its Start state. See JourneyGraphSource.

Returns

This method returns an object of type JourneyRef.

Get Journey

Retrieves a journey by id with its whole graph: every state and edge, each path from the root state to an end, and how many goldens have been generated for each path and in which datasets. Paths with no goldens are the branches of the conversation your tests do not cover yet.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.journeys.get(journey_id="<JOURNEY-ID>")

For async mode, call a_get and await it as shown below:

result = await client.journeys.a_get(...)

Parameters

ParameterTypeDescription
journey_idstrRequired. The id of the journey.

Returns

This method returns an object of type Journey.

Update Journey

Renames a journey or rewrites its description, and returns it with its whole graph. Names are unique within a project; taking another journey's name returns a 409.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.journeys.update(
    journey_id="<JOURNEY-ID>",
    name="Refund request",
    description="A customer asks for a refund on a recent order. The agent verifies who they are, then either issues the refund or hands the conversation to a human.",
)

For async mode, call a_update and await it as shown below:

result = await client.journeys.a_update(...)

Parameters

ParameterTypeDescription
journey_idstrRequired. The id of the journey.
nameOptional[str]The name of the journey, unique within the project. Omit it to keep the current name.
descriptionOptional[str]What the user is trying to get done on this journey. Send null to clear it, or omit it to keep the current one.

Returns

This method returns an object of type Journey.

Delete Journey

Permanently deletes a journey with all of its states and edges. Goldens generated from it are kept in their datasets but no longer belong to a journey. This action cannot be undone.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.journeys.delete(journey_id="<JOURNEY-ID>")

For async mode, call a_delete and await it as shown below:

result = await client.journeys.a_delete(...)

Parameters

ParameterTypeDescription
journey_idstrRequired. The id of the journey.

Returns

This method returns an object of type JourneyRef.

Generate Goldens

Generates multi-turn goldens for the chosen paths of a journey and adds them to a multi-turn dataset. Your project's platform model writes one scenario and expected outcome per path from its states' instructions and edge conditions, so this consumes usage; if no platform model is configured, or writing one fails, the scenario is the path's instructions joined in order. Each golden remembers its path, so the journey reports coverage and path results for it.

from confident_ai import ConfidentAI
from confident_ai.journeys import JourneyPathGoldenCountInput

client = ConfidentAI()

result = client.journeys.generate_goldens(
    journey_id="<JOURNEY-ID>",
    dataset_id="<DATASET-ID>",
    paths=[
        JourneyPathGoldenCountInput(
            state_ids=["<JOURNEY-STATE-ID>"],
            count=3
        )
    ],
    persona_id="<PERSONA-ID>",
)

For async mode, call a_generate_goldens and await it as shown below:

result = await client.journeys.a_generate_goldens(...)

Parameters

ParameterTypeDescription
journey_idstrRequired. The id of the journey.
dataset_idstrRequired. The id of the dataset to add the goldens to. It must be a multi-turn dataset in this project.
pathsList[JourneyPathGoldenCountInput]Required. The paths to generate goldens for, and how many for each. At most 50, the most paths a journey lists. A path listed twice uses its last count. See JourneyPathGoldenCountInput.
persona_idOptional[str]The id of a persona to attach to every golden, so the simulated user is played in its voice and the scenarios are written for it. Send null or omit it for no persona.

Returns

This method returns an object of type GenerateJourneyGoldensResult.

Get Path Results

Retrieves how the test cases simulated from a journey's goldens went: for each test case, the path it was generated for and the path the conversation actually took, plus each metric's results per path. Use it to find the branches where your LLM app strays from the journey or fails its metrics.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.journeys.get_path_results(
    journey_id="<JOURNEY-ID>",
    start="2025-01-01T00:00:00+00:00",
    end="2025-01-31T23:59:59+00:00",
)

For async mode, call a_get_path_results and await it as shown below:

result = await client.journeys.a_get_path_results(...)

Parameters

ParameterTypeDescription
journey_idstrRequired. The id of the journey.
startOptional[str]Only include test cases last updated at or after this time, in ISO 8601 format. Send it with end, or omit both to include every test case.
endOptional[str]Only include test cases last updated at or before this time, in ISO 8601 format. Send it with start; it must be later than start.

Returns

This method returns an object of type JourneyPathResults.

Types

GenerateJourneyGoldensResult

How many goldens were generated from a journey's paths.

class GenerateJourneyGoldensResult:
    golden_count: int = Field(alias="goldenCount")

golden_countintRequired

The number of goldens created.

Example: 9

Journey

A map of the ways a conversation with your LLM app can go. States are the steps, edges are the conditions that move the conversation between them, and each route from the root state to an end is a path you can generate multi-turn goldens for, so every branch gets tested.

class Journey:
    id: str
    name: str
    description: Optional[str]
    root_state_id: Optional[str] = Field(alias="rootStateId")
    states: List[JourneyState]
    edges: List[JourneyEdge]
    paths: List[JourneyPath]
    paths_truncated: bool = Field(alias="pathsTruncated")
    datasets: List[JourneyPathDataset]
    created_at: str = Field(alias="createdAt")
    updated_at: str = Field(alias="updatedAt")

idstrRequired

The id of the journey, generated by Confident AI.

Example: "<JOURNEY-ID>"

namestrRequired

The name of the journey, unique within the project.

Example: "Refund request"

descriptionOptional[str]Required

What the user is trying to get done on this journey, or null when none was given.

Example: "A customer asks for a refund on a recent order. The agent verifies who they are, then either issues the refund or hands the conversation to a human."

root_state_idOptional[str]Required

The id of the root Start state, which every path begins at. It cannot be deleted.

Example: "<JOURNEY-STATE-ID>"

statesList[JourneyState]Required

Every state in the journey, oldest first.

See JourneyState.

edgesList[JourneyEdge]Required

Every edge in the journey, oldest first.

See JourneyEdge.

pathsList[JourneyPath]Required

Every route from the root state to a state with no further edges, following only edges with a non-empty when and never visiting a state twice. At most 50 are listed.

See JourneyPath.

paths_truncatedboolRequired

true when the journey has more than 50 paths, so paths lists only the first 50.

Example: false

datasetsList[JourneyPathDataset]Required

The datasets holding goldens generated from this journey.

See JourneyPathDataset.

created_atstrRequired

The time the journey was created, as an ISO 8601 datetime.

Example: "2025-01-15T10:30:00+00:00"

updated_atstrRequired

The time the journey's name or description was last changed, as an ISO 8601 datetime.

Example: "2025-01-16T09:12:00+00:00"

JourneyEdge

A transition from one state of a journey to another, taken when its condition holds.

class JourneyEdge:
    id: str
    from_state_id: str = Field(alias="fromStateId")
    to_state_id: str = Field(alias="toStateId")
    when: str
    created_at: str = Field(alias="createdAt")
    updated_at: str = Field(alias="updatedAt")

idstrRequired

The id of the edge, generated by Confident AI.

Example: "<JOURNEY-EDGE-ID>"

from_state_idstrRequired

The id of the state the edge leaves from.

Example: "<JOURNEY-STATE-ID>"

to_state_idstrRequired

The id of the state the edge leads to.

Example: "<JOURNEY-STATE-ID>"

whenstrRequired

The condition under which the conversation moves along this edge. Empty when none has been given, which keeps the edge out of the journey's paths.

Example: "The customer has given an order number and the email on the account, and they match."

created_atstrRequired

The time the edge was created, as an ISO 8601 datetime.

Example: "2025-01-15T10:30:00+00:00"

updated_atstrRequired

The time the edge was last changed, as an ISO 8601 datetime.

Example: "2025-01-16T09:12:00+00:00"

JourneyGraphSource

Where a new journey's first states and edges come from. ai has Confident AI draft them from the journey's name and description.

class JourneyGraphSource(Enum):
    AI = "ai"

AI

JourneyList

One page of journeys, with the total across all pages.

class JourneyList:
    journeys: List[JourneySummary]
    total_journeys: int = Field(alias="totalJourneys")
    page: int
    page_size: int = Field(alias="pageSize")

journeysList[JourneySummary]Required

The journeys for the current page, newest first.

See JourneySummary.

total_journeysintRequired

The total number of journeys in this project.

Example: 3

pageintRequired

The page this response covers.

Example: 1

page_sizeintRequired

The number of journeys per page.

Example: 25

JourneyPath

One route through a journey, from the root state to a state with no further edges, and the goldens generated for it.

class JourneyPath:
    state_ids: List[str] = Field(alias="stateIds")
    golden_count: int = Field(alias="goldenCount")
    datasets: List[JourneyPathDataset]

state_idsList[str]Required

The ids of the states along the path, in order, starting with the root state.

Example: ["<JOURNEY-STATE-ID>"]

golden_countintRequired

The number of goldens generated for exactly this path.

Example: 4

datasetsList[JourneyPathDataset]Required

The datasets holding this path's goldens.

See JourneyPathDataset.

JourneyPathDataset

A dataset holding goldens generated from a journey, and how many of them it holds.

class JourneyPathDataset:
    id: str
    alias: str
    golden_count: int = Field(alias="goldenCount")

idstrRequired

The id of the dataset.

Example: "<DATASET-ID>"

aliasstrRequired

The alias of the dataset, unique within your project.

Example: "refund-conversations"

golden_countintRequired

The number of the journey's goldens this dataset holds.

Example: 6

JourneyPathGoldenCountInput

A path of a journey and how many goldens to generate for it.

class JourneyPathGoldenCountInput:
    state_ids: List[str] = Field(alias="stateIds")
    count: int

state_idsList[str]Required

The ids of the path's states, in order from the root state, exactly as the journey lists them under paths. A path that is not one of the journey's paths is skipped.

Example: ["<JOURNEY-STATE-ID>"]

countintRequired

How many goldens to generate for the path, at most 100. They all share one scenario, and differ only in how each simulated conversation plays out.

Example: 3

JourneyPathMetricStat

How one metric did across the test cases generated for one path of a journey.

class JourneyPathMetricStat:
    journey_state_ids: List[str] = Field(alias="journeyStateIds")
    name: str
    avg_score: Optional[float] = Field(alias="avgScore")
    passed: int
    failed: int

journey_state_idsList[str]Required

The path these results are for, as state ids in order from the root state.

Example: ["<JOURNEY-STATE-ID>"]

namestrRequired

The name of the metric.

Example: "Conversation Completeness"

avg_scoreOptional[float]Required

The metric's average score across the path's test cases, or null when none was scored.

Example: 0.82

passedintRequired

The number of the path's test cases that passed the metric.

Example: 7

failedintRequired

The number of the path's test cases that failed the metric. Results that errored count as neither passed nor failed.

Example: 2

JourneyPathResults

How the test cases generated from a journey's paths actually went: which path each conversation took, and how each path did on each metric.

class JourneyPathResults:
    test_cases: List[JourneyPathTestCase] = Field(alias="testCases")
    metrics: List[JourneyPathMetricStat]

test_casesList[JourneyPathTestCase]Required

Every test case simulated from this journey's goldens in the time window, in no particular order.

See JourneyPathTestCase.

metricsList[JourneyPathMetricStat]Required

Metric results for the same test cases, one entry per path and metric. Skipped and flaky metric results are left out.

See JourneyPathMetricStat.

JourneyPathTestCase

A test case simulated from one of a journey's goldens, with the path it was meant to follow and the one it took.

class JourneyPathTestCase:
    test_case_id: str = Field(alias="testCaseId")
    test_run_id: str = Field(alias="testRunId")
    name: str
    journey_state_ids: List[str] = Field(alias="journeyStateIds")
    journey_path: List[str] = Field(alias="journeyPath")
    status: Optional[TestCaseStatus]
    success: Optional[bool]
    completion_time: Optional[float] = Field(alias="completionTime")

test_case_idstrRequired

The id of the test case.

Example: "<TEST-CASE-ID>"

test_run_idstrRequired

The id of the test run the test case belongs to.

Example: "<TEST-RUN-ID>"

namestrRequired

The name of the test case.

Example: "Refund request, verified"

journey_state_idsList[str]Required

The path the test case's golden was generated for, as state ids in order from the root state.

Example: ["<JOURNEY-STATE-ID>"]

journey_pathList[str]Required

The state the simulated conversation was in on each user turn, in order, so a state repeats while the conversation stays in it. Compare it with journeyStateIds to see where the conversation left the intended path. [] when it was not recorded.

Example: ["<JOURNEY-STATE-ID>"]

statusOptional[TestCaseStatus]Required

Where the test case is in its run, or null when it was not recorded.

See TestCaseStatus.

Example: "COMPLETED"

successOptional[bool]Required

Whether the test case passed its metrics, or null when it has no verdict yet.

Example: true

completion_timeOptional[float]Required

How long the test case took to run, in seconds, or null when it was not recorded.

Example: 12.4

JourneyRef

A reference to a journey by its id.

class JourneyRef:
    id: str

idstrRequired

The id of the journey, generated by Confident AI.

Example: "<JOURNEY-ID>"

JourneyState

One step of a journey: a point the conversation can reach, with instructions for what happens there.

class JourneyState:
    id: str
    name: str
    instructions: str
    golden_count: int = Field(alias="goldenCount")
    created_at: str = Field(alias="createdAt")
    updated_at: str = Field(alias="updatedAt")

idstrRequired

The id of the state, generated by Confident AI.

Example: "<JOURNEY-STATE-ID>"

namestrRequired

The name of the state, unique within the journey.

Example: "Verify identity"

instructionsstrRequired

What happens at this step of the conversation, as golden generation reads it.

Example: "The agent asks for the order number and the email on the account, and checks they match before going further."

golden_countintRequired

The number of goldens generated for a path through this state.

Example: 10

created_atstrRequired

The time the state was created, as an ISO 8601 datetime.

Example: "2025-01-15T10:30:00+00:00"

updated_atstrRequired

The time the state was last changed, as an ISO 8601 datetime.

Example: "2025-01-16T09:12:00+00:00"

JourneySummary

A journey as it appears in a list: enough to recognise it and pick its id. Retrieve one by id to read its states, edges and paths.

class JourneySummary:
    id: str
    name: str
    state_count: int = Field(alias="stateCount")
    golden_count: int = Field(alias="goldenCount")

idstrRequired

The id of the journey, generated by Confident AI.

Example: "<JOURNEY-ID>"

namestrRequired

The name of the journey.

Example: "Refund request"

state_countintRequired

The number of states in the journey, including its root.

Example: 4

golden_countintRequired

The number of goldens generated from the journey.

Example: 10

TestCaseStatus

Where a test case is in its run: GENERATING its output, EVALUATING its metrics, COMPLETED, or ERRORED. WAITING means an asynchronous result has not arrived yet.

class TestCaseStatus(Enum):
    GENERATING = "GENERATING"
    EVALUATING = "EVALUATING"
    ERRORED = "ERRORED"
    COMPLETED = "COMPLETED"
    WAITING = "WAITING"

GENERATING · EVALUATING · ERRORED · COMPLETED · WAITING

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

Last updated on

Built byConfident AI