Classifiers

February 25, 2026 ยท View on GitHub

Overview

Classifiers API.

Available Operations

moderate

Moderations

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.classifiers.moderate(model="mistral-moderation-latest", inputs="<value>")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescriptionExample
modelstr:heavy_check_mark:ID of the model to use.mistral-moderation-latest
inputsmodels.ClassificationRequestInputs:heavy_check_mark:Text to classify.
metadataDict[str, Any]:heavy_minus_sign:N/A
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.ModerationResponse

Errors

Error TypeStatus CodeContent Type
errors.HTTPValidationError422application/json
errors.SDKError4XX, 5XX*/*

moderate_chat

Chat Moderations

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.classifiers.moderate_chat(inputs=[
        {
            "role": "tool",
            "content": "<value>",
        },
    ], model="LeBaron")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
inputsmodels.ChatModerationRequestInputs3:heavy_check_mark:Chat to classify
modelstr:heavy_check_mark:N/A
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.ModerationResponse

Errors

Error TypeStatus CodeContent Type
errors.HTTPValidationError422application/json
errors.SDKError4XX, 5XX*/*

classify

Classifications

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.classifiers.classify(model="mistral-moderation-latest", inputs=[
        "<value 1>",
    ])

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescriptionExample
modelstr:heavy_check_mark:ID of the model to use.mistral-moderation-latest
inputsmodels.ClassificationRequestInputs:heavy_check_mark:Text to classify.
metadataDict[str, Any]:heavy_minus_sign:N/A
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.ClassificationResponse

Errors

Error TypeStatus CodeContent Type
errors.HTTPValidationError422application/json
errors.SDKError4XX, 5XX*/*

classify_chat

Chat Classifications

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.classifiers.classify_chat(model="Camry", input=[
        {
            "messages": [
                {
                    "role": "system",
                    "content": "<value>",
                },
            ],
        },
    ])

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
modelstr:heavy_check_mark:N/A
inputmodels.Inputs:heavy_check_mark:Chat to classify
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.ClassificationResponse

Errors

Error TypeStatus CodeContent Type
errors.HTTPValidationError422application/json
errors.SDKError4XX, 5XX*/*