Introducing Confident Voice: Watch the Launch Video Now

Managing Classifiers via Confident AI SDK

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

Overview

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

Lists the classifiers in your Confident AI project one page at a time, ordered by name. Each is returned as a summary row — enough to pick one; retrieve a classifier by id for its filters, generation config, and labels.

from confident_ai import ConfidentAI
from confident_ai.classifiers import ClassifierDataModel

client = ConfidentAI()

result = client.classifiers.list(
    page=1,
    page_size=25,
    data_model=ClassifierDataModel.TRACE,
)

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

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

Parameters

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

Returns

This method returns an object of type ClassifierList.

Create Classifier

Creates a classifier that tags incoming traces, spans or threads with labels, and returns its id. Sending a preset seeds it with a description, a generation config, and a starting set of labels; any field you send explicitly overrides what the preset would have set.

from confident_ai import ConfidentAI
from confident_ai.classifiers import (
    ClassifierAutoGenerationConfig,
    ClassifierDataModel,
    ClassifierPreset,
)
from confident_ai.common import (
    FilterSet,
    FilterSetGroup,
    FilterSetGroupFilter,
)

client = ConfidentAI()

result = client.classifiers.create(
    name="Sentiment",
    data_model=ClassifierDataModel.TRACE,
    preset=ClassifierPreset.CUSTOM,
    description="Analyzes the emotional tone of user interactions.",
    enabled=True,
    auto_classify=True,
    include_audio=False,
    filters=FilterSet(
        operator="AND",
        groups=[
            FilterSetGroup(
                operator="AND",
                filters=[
                    FilterSetGroupFilter(
                        category="Trace Name",
                        condition="Is",
                        value="checkout"
                    )
                ]
            )
        ]
    ),
    auto_generation_config=ClassifierAutoGenerationConfig(
        sample_size=200
    ),
)

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

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

Parameters

ParameterTypeDescription
namestrRequired. The name of the classifier, unique per data model within the project.
data_modelClassifierDataModelRequired. See ClassifierDataModel.
presetOptional[ClassifierPreset]See ClassifierPreset.
descriptionOptional[str]What this classifier is for. Send null to clear it.
enabledOptional[bool]Whether the classifier runs at all. Defaults to true on create; omit it on an update to leave it unchanged.
auto_classifyOptional[bool]Whether incoming items are classified automatically as they arrive. Defaults to true on create; omit it on an update to leave it unchanged.
include_audioOptional[bool]Whether the item's call recording and any audio in its inputs and outputs are sent to the classifier alongside the text, so it can catch issues that only show in the audio or in a mismatch between the audio and its transcript. Needs an audio- capable platform model. Defaults to false on create; omit it on an update to leave it unchanged.
filtersOptional[FilterSet]Narrows which traces, spans or threads the classifier runs on, so it can watch one route rather than the whole project. Only the groups are stored, so the set's top-level operator is dropped and the groups are combined by the platform. Send null to clear the filters and classify everything of this data model. See FilterSet.
auto_generation_configOptional[ClassifierAutoGenerationConfig]How a generation run samples your traffic to generate labels. Send null to clear it. See ClassifierAutoGenerationConfig.

Returns

This method returns an object of type ClassifierRef.

Get Classifier

Retrieves a classifier by id, with the filters that scope what it runs on, its generation config, and every label it can apply.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.classifiers.get(classifier_id="<CLASSIFIER-ID>")

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

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

Parameters

ParameterTypeDescription
classifier_idstrRequired. The id of the classifier.

Returns

This method returns an object of type Classifier.

Update Classifier

Updates a classifier and returns it. Only the fields you send are changed: omitting a field leaves it untouched, and sending null clears it. dataModel cannot be changed after creation and a preset can only be applied when creating one; labels are managed through their own endpoints.

from confident_ai import ConfidentAI
from confident_ai.classifiers import ClassifierAutoGenerationConfig
from confident_ai.common import (
    FilterSet,
    FilterSetGroup,
    FilterSetGroupFilter,
)

client = ConfidentAI()

result = client.classifiers.update(
    classifier_id="<CLASSIFIER-ID>",
    name="Sentiment",
    description="Analyzes the emotional tone of user interactions.",
    enabled=True,
    auto_classify=True,
    include_audio=False,
    filters=FilterSet(
        operator="AND",
        groups=[
            FilterSetGroup(
                operator="AND",
                filters=[
                    FilterSetGroupFilter(
                        category="Trace Name",
                        condition="Is",
                        value="checkout"
                    )
                ]
            )
        ]
    ),
    auto_generation_config=ClassifierAutoGenerationConfig(
        sample_size=200
    ),
)

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

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

Parameters

ParameterTypeDescription
classifier_idstrRequired. The id of the classifier.
nameOptional[str]The name of the classifier, unique per data model within the project.
descriptionOptional[str]What this classifier is for. Send null to clear it.
enabledOptional[bool]Whether the classifier runs at all. Defaults to true on create; omit it on an update to leave it unchanged.
auto_classifyOptional[bool]Whether incoming items are classified automatically as they arrive. Defaults to true on create; omit it on an update to leave it unchanged.
include_audioOptional[bool]Whether the item's call recording and any audio in its inputs and outputs are sent to the classifier alongside the text, so it can catch issues that only show in the audio or in a mismatch between the audio and its transcript. Needs an audio- capable platform model. Defaults to false on create; omit it on an update to leave it unchanged.
filtersOptional[FilterSet]Narrows which traces, spans or threads the classifier runs on, so it can watch one route rather than the whole project. Only the groups are stored, so the set's top-level operator is dropped and the groups are combined by the platform. Send null to clear the filters and classify everything of this data model. See FilterSet.
auto_generation_configOptional[ClassifierAutoGenerationConfig]How a generation run samples your traffic to generate labels. Send null to clear it. See ClassifierAutoGenerationConfig.

Returns

This method returns an object of type Classifier.

Delete Classifier

Permanently deletes a classifier and all of its labels, and returns its id. Classifications already applied to traces, spans or threads are not removed. This action cannot be undone.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.classifiers.delete(classifier_id="<CLASSIFIER-ID>")

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

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

Parameters

ParameterTypeDescription
classifier_idstrRequired. The id of the classifier.

Returns

This method returns an object of type ClassifierRef.

Generate Labels

Generates labels for a classifier from your project's real traffic: it samples recent traces, spans or threads and runs them through the classifier's normal auto-classification pipeline. Repeated proposals are merged and written back as RECOMMENDED labels for a human to review. The run is asynchronous, so poll the labels endpoint for results. Existing labels are retained, and the sampled entities receive ordinary classification results. Auto Classify must be enabled. Reading traffic and running the model consumes usage.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.classifiers.generate_labels(classifier_id="<CLASSIFIER-ID>")

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

result = await client.classifiers.a_generate_labels(...)

Parameters

ParameterTypeDescription
classifier_idstrRequired. The id of the classifier.

Returns

This method returns an object of type ClassifierLabelGeneration.

List Versions

Lists a classifier's version history, newest first, so the first entry is what the classifying model is shown today. A version is appended whenever the description or the set of labels the model can apply changes, which includes RECOMMENDED labels added by a generation run or by the model itself while the classifier classifies automatically. A version can be restored in the app, not through this API.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.classifiers.list_versions(
    classifier_id="<CLASSIFIER-ID>",
    page=1,
    page_size=25,
)

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

result = await client.classifiers.a_list_versions(...)

Parameters

ParameterTypeDescription
classifier_idstrRequired. The id of the classifier.
pageOptional[int]The page to return. Defaults to 1.
page_sizeOptional[int]The number of versions per page, at most 100. Defaults to 25.

Returns

This method returns an object of type ClassifierVersionList.

Types

Classifier

A classifier: what it runs on, how it generates labels, and the labels it can apply.

class Classifier:
    id: str
    name: str
    description: Optional[str]
    enabled: bool
    auto_classify: bool = Field(alias="autoClassify")
    include_audio: bool = Field(alias="includeAudio")
    data_model: ClassifierDataModel = Field(alias="dataModel")
    filters: FilterSet
    auto_generation_config: Optional[ClassifierAutoGenerationConfig] = Field(alias="autoGenerationConfig")
    labels: List[ClassifierLabel]

idstrRequired

The id of the classifier, generated by Confident AI.

Example: "<CLASSIFIER-ID>"

namestrRequired

The name of the classifier.

Example: "Sentiment"

descriptionOptional[str]Required

What this classifier is for, or null when it has no description.

Example: "Analyzes the emotional tone of user interactions."

enabledboolRequired

Whether the classifier runs at all.

Example: true

auto_classifyboolRequired

Whether incoming items are classified automatically as they arrive.

Example: true

include_audioboolRequired

Whether the item's call recording and any audio in its inputs and outputs are sent to the classifier alongside the text.

Example: false

data_modelClassifierDataModelRequired

filtersFilterSetRequired

auto_generation_configOptional[ClassifierAutoGenerationConfig]Required

How a generation run samples your traffic, or null when the classifier has no generation config.

See ClassifierAutoGenerationConfig.

labelsList[ClassifierLabel]Required

The labels this classifier can apply.

See ClassifierLabel.

ClassifierAutoGenerationConfig

How many recent traces, spans or threads a generation run samples and classifies.

class ClassifierAutoGenerationConfig:
    sample_size: Optional[int] = Field(default=None, alias="sampleSize")

sample_sizeOptional[int]

How many traces, spans or threads to sample. Defaults to 200.

Example: 200

ClassifierDataModel

What kind of production item a classifier labels: TRACE labels individual traces, SPAN labels a span together with the spans under it, THREAD labels whole conversations. It is fixed when the classifier is created.

class ClassifierDataModel(Enum):
    TRACE = "TRACE"
    SPAN = "SPAN"
    THREAD = "THREAD"

TRACE · SPAN · THREAD

ClassifierLabel

One label a classifier can apply to what it classifies.

class ClassifierLabel:
    id: str
    name: str
    description: str
    enabled: bool
    status: ClassifierLabelStatus
    polarity: SignalPolarity

idstrRequired

The id of the label, generated by Confident AI.

Example: "<CLASSIFIER-LABEL-ID>"

namestrRequired

The name of the label, unique within the classifier.

Example: "Positive"

descriptionstrRequired

When this label applies. This is the instruction the classifying model reads, so it states the condition rather than restating the name.

Example: "User expresses satisfaction, gratitude, or positive sentiment."

enabledboolRequired

Whether the label can be applied.

Example: true

statusClassifierLabelStatusRequired

polaritySignalPolarityRequired

ClassifierLabelGeneration

The outcome of dispatching a label generation run. The run itself is asynchronous and returns no handle, so poll the labels endpoint for its results.

class ClassifierLabelGeneration:
    classifier_id: str = Field(alias="classifierId")
    started: bool
    message: str

classifier_idstrRequired

The classifier labels were generated for.

Example: "<CLASSIFIER-ID>"

startedboolRequired

Whether a generation run was dispatched. False means there was too little traffic to sample, or sampling was briefly unavailable — it is an outcome, not an error.

Example: true

messagestrRequired

A human-readable explanation of the outcome.

Example: "Label generation started. Generated labels appear with status RECOMMENDED as the sampled data is classified."

ClassifierLabelStatus

ACTIVE labels are in use; RECOMMENDED ones are generated suggestions awaiting review.

class ClassifierLabelStatus(Enum):
    RECOMMENDED = "RECOMMENDED"
    ACTIVE = "ACTIVE"

RECOMMENDED · ACTIVE

ClassifierList

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

class ClassifierList:
    classifiers: List[ClassifierSummary]
    total_classifiers: int = Field(alias="totalClassifiers")
    page: int
    page_size: int = Field(alias="pageSize")

classifiersList[ClassifierSummary]Required

The classifiers for the current page, ordered by name.

See ClassifierSummary.

total_classifiersintRequired

The total number of classifiers matching the query across all pages.

Example: 3

pageintRequired

The page this response covers.

Example: 1

page_sizeintRequired

The number of classifiers per page.

Example: 25

ClassifierPreset

A Confident AI template to seed a classifier from. SENTIMENT arrives with its labels ready; TOPICS, USE_CASES and ISSUES ship with none and expect a generation run next. CUSTOM seeds nothing.

class ClassifierPreset(Enum):
    CUSTOM = "CUSTOM"
    SENTIMENT = "SENTIMENT"
    TOPICS = "TOPICS"
    USE_CASES = "USE_CASES"
    ISSUES = "ISSUES"

CUSTOM · SENTIMENT · TOPICS · USE_CASES · ISSUES

ClassifierRef

A reference to a classifier by its id.

class ClassifierRef:
    id: str

idstrRequired

The id of the classifier, generated by Confident AI.

Example: "<CLASSIFIER-ID>"

ClassifierSummary

A classifier as it appears in a list: enough to pick one, without its filters, generation config, or labels.

class ClassifierSummary:
    id: str
    name: str
    enabled: bool
    data_model: ClassifierDataModel = Field(alias="dataModel")

idstrRequired

The id of the classifier, generated by Confident AI.

Example: "<CLASSIFIER-ID>"

namestrRequired

The name of the classifier.

Example: "Sentiment"

enabledboolRequired

Whether the classifier runs at all.

Example: true

data_modelClassifierDataModelRequired

ClassifierVersion

An immutable snapshot of what a classifier shows the classifying model: its description and the labels it can apply. Changing either appends a new version, and every classification records the version it was produced under.

class ClassifierVersion:
    id: str
    classifier_id: str = Field(alias="classifierId")
    sequence: int
    version: str
    description: Optional[str]
    labels: List[ClassifierVersionLabel]
    created_at: str = Field(alias="createdAt")
    author: Optional[UserReference]

idstrRequired

The id of the version, generated by Confident AI.

Example: "<CLASSIFIER-VERSION-ID>"

classifier_idstrRequired

The id of the classifier this version belongs to.

Example: "<CLASSIFIER-ID>"

sequenceintRequired

The position of this version in the classifier's history, counting from 1. The highest sequence is the current version, which is the one new classifications run against.

Example: 2

versionstrRequired

The human-readable label for sequence, written as three two-digit groups that roll over at 100, so sequence 2 is 00.00.02 and sequence 100 is 00.01.00.

Example: "00.00.02"

descriptionOptional[str]Required

The classifier description the model was shown, or null when it had none.

Example: "Analyzes the emotional tone of user interactions."

labelsList[ClassifierVersionLabel]Required

The labels the model could apply, ordered by name: enabled ACTIVE labels, plus enabled RECOMMENDED ones when the classifier classifies automatically.

See ClassifierVersionLabel.

created_atstrRequired

When this version was snapshotted.

Example: "2025-01-18T16:45:00+00:00"

authorOptional[UserReference]Required

Who made the change that created this version, or null when it came from an API key or from Confident AI itself, such as a generated label.

See UserReference.

ClassifierVersionLabel

A label as the classifying model was shown it.

class ClassifierVersionLabel:
    name: str
    description: str

namestrRequired

The name of the label.

Example: "Positive"

descriptionstrRequired

When the label applies, as the classifying model read it.

Example: "User expresses satisfaction, gratitude, or positive sentiment."

ClassifierVersionList

One page of a classifier's version history, with the total across all pages.

class ClassifierVersionList:
    versions: List[ClassifierVersion]
    total_classifier_versions: int = Field(alias="totalClassifierVersions")
    page: int
    page_size: int = Field(alias="pageSize")

versionsList[ClassifierVersion]Required

The classifier's history for the current page, newest version first, so the first entry of the first page is the current version.

See ClassifierVersion.

total_classifier_versionsintRequired

The number of versions this classifier has, across every page.

Example: 2

pageintRequired

The page this response covers.

Example: 1

page_sizeintRequired

The number of versions per page.

Example: 25

FilterSet

A set of filter groups combined by a top-level operator. Each group combines its filter rows by its own operator, and each row matches one property, such as Name or User Id, against a value with a condition such as Is or Contains.

class FilterSet:
    operator: Literal["AND", "OR"]
    groups: List[FilterSetGroup]

operatorLiteral["AND", "OR"]Required

How the groups combine: AND matches a record only when every group matches it, and OR matches it when any one group does.

groupsList[FilterSetGroup]Required

The groups of filters to apply, each combining its own filters with its own operator.

SignalPolarity

Whether more of a signal is good, bad, or neither, for trend reporting.

class SignalPolarity(Enum):
    HIGHER_IS_BETTER = "HIGHER_IS_BETTER"
    LOWER_IS_BETTER = "LOWER_IS_BETTER"
    NEUTRAL = "NEUTRAL"

HIGHER_IS_BETTER · LOWER_IS_BETTER · NEUTRAL

UserReference

A Confident AI user, as referenced by the records they created.

class UserReference:
    id: str
    email: str
    name: Optional[str]
    image: Optional[str]

idstrRequired

This is the id of the user.

Example: "<USER-ID>"

emailstrRequired

This is the email address of the user.

Example: "jane@acme.com"

nameOptional[str]Required

This is the display name of the user, or null when they have not set one.

Example: "Jane Doe"

imageOptional[str]Required

This is the URL of the user's avatar, or null when they have none.

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

Last updated on

Built byConfident AI