Skip to main content

Mistral Evaluations

Run evaluations of LLM apps and agents, and see the results in Mistral AI Studio.

Overview

This package adds mistralai.evaluations to the Mistral AI Python SDK: client.evaluation.run() runs a task on a dataset, scores it with your evaluators, and uploads the run to AI Studio.

Requirements

  • AI Studio evaluations require an Enterprise organization. Runs, projects, datasets, judges and optimizations stored in AI Studio are available to Enterprise organizations only. Other organizations get an ObservabilityAPIError (status 403) that says so before any task runs. To upgrade, contact sales.
  • Local mode is open to every organization. client.evaluation.run(..., local=True) (or a run without evaluation=) runs and scores everything on your machine, without calling AI Studio.

Namespace package

This package follows PEP 420 implicit namespace packaging: it installs into the shared mistralai namespace and is importable as mistralai.evaluations.

Package Structure

mistralai/                  # Shared namespace (no __init__.py)
├── client/                 # Core SDK (mistralai package on PyPI)
├── workflows/              # Workflows SDK
├── evaluations/            # This package (evaluation utilities)
└── extra/                  # Extra utilities

The mistralai/ directory has no __init__.py, allowing multiple packages to coexist under the shared mistralai namespace.

Installation

pip install mistralai-evaluations

For local development:

uv sync

Usage

Basic evaluation

from mistralai.evaluations import Evaluation, Evaluator, Project

run = await client.evaluation.run(
    project=Project(name="My Project"),
    evaluation=Evaluation(name="My Evaluation"),
    dataset=[{"input": "hello", "expected": "greeting"}],
    task=lambda input_record: classify(input_record["input"]),
    evaluators=[
        Evaluator(name="accuracy", scorer=lambda input_record, output: 1 if output == input_record["expected"] else 0),
    ],
)
run.show(level="scores")

Managed Studio datasets

Pass a Studio dataset ID or slug instead of an inline dataset to resolve all of its records (up to 10,000) before the run starts. The record payload is passed to tasks and scorers exactly like an equivalent inline mapping; dataset record properties and source information are not added to it.

from typing import TypedDict

from mistralai.evaluations import Dataset, Evaluation, Evaluator


class Example(TypedDict):
    question: str
    expected: str


def task(record: Example) -> str:
    return answer(record["question"])


def scorer(record: Example, output: str) -> int:
    return 1 if output == record["expected"] else 0


run = await client.evaluation.run(
    evaluation=Evaluation(name="My Evaluation"),
    dataset=Dataset(slug="customer-support-golden-set"),
    task=task,
    evaluators=[Evaluator(name="accuracy", scorer=scorer)],
)

Use Dataset(slug="customer-support-golden-set") for a readable, stable script, or Dataset(id="018f879d-20cd-7e9f-a1bc-2f4f08b6f170") when you already have the dataset UUID. Exactly one of id and slug is required. The referenced dataset must already exist; selecting it by slug never creates a dataset.

Run-level evaluators

Run evaluators execute after all records are processed and receive the full run context (records, statistics, metrics, metadata). Use them for global assertions or aggregate metrics.

from mistralai.evaluations import RunEvaluator

run = await client.evaluation.run(
    ...,
    evaluators=[
        Evaluator(name="accuracy", scorer=lambda input_record, output: 1 if output == input_record["expected"] else 0),
    ],
    run_evaluators=[
        RunEvaluator(
            name="accuracy_above_50pct",
            scorer=lambda ctx: ctx.statistics["accuracy"].avg > 0.5,
        ),
        RunEvaluator(
            name="all_records_scored",
            scorer=lambda ctx: all(
                len(r.output.generations) > 0 for r in ctx.records
            ),
        ),
    ],
)
# Results are in run.run_scores
print(run.run_scores)  # {"accuracy_above_50pct": True, "all_records_scored": True}

The RunEvaluatorContext provides:

Field Type Description
records list[RunEvaluatorRecord] Each record's input and output (with scores).
statistics dict[str, EvaluatorStatistics] Run-level statistics from regular evaluators.
metrics dict[str, JsonValue] Run-level run_aggregator results.
metadata dict[str, JsonValue] Metadata attached to the run.

Retrying failed records

If an evaluation only partially fails, use retry_failed_records instead of re-running the entire evaluation from scratch. It re-runs only the failed records and patches the original run in place, avoiding work on successful records when failures came from transient API errors, rate limits, or a bug in the task or scorer.

from mistralai.evaluations import Evaluation, Evaluator

run = await client.evaluation.run(
    evaluation=Evaluation(name="My Evaluation"),
    dataset=dataset,
    task=flaky_task,
    evaluators=[Evaluator(name="accuracy", scorer=scorer)],
)

# Fix the task or scorer if needed, then retry only the failed records.
result = await client.evaluation.retry_failed_records(
    run_id=run.run_id,
    dataset=dataset,
    task=fixed_task,
    evaluators=[Evaluator(name="accuracy", scorer=scorer)],
)

print(f"Retried: {result.retried_count}, Patched: {result.patched_count}")

Pass the same dataset used in the original run so the SDK can map failed records back to their inputs. You can pass a fixed task or updated evaluators before retrying. When run-level evaluators are provided, their scores are recomputed after patching.

get_score helper

When writing run evaluators, accessing individual scores requires navigating through generations and score lists. The get_score helper simplifies this:

from mistralai.evaluations import RunEvaluatorContext, Score, get_score

def f1_scorer(ctx: RunEvaluatorContext) -> Score:
    tp = fp = fn = 0
    for record in ctx.records:
        expected = str(record.input["expected"]).lower()
        # Instead of: record.output.generations[0].scores["accuracy"][0].value
        is_correct = get_score(record, "accuracy").value == 1
        ...

Returns a Score object (with value, rationale, metadata).

Parameter Type Default Description
record RunEvaluatorRecord — The record to extract scores from.
evaluator_name str — Name of the evaluator whose scores to retrieve.
aggregate Callable[[list[Score]], Score] None Required when multiple scores exist (multiple generations).

Raises if no scores are found. When num_generations > 1, raises with a helpful message unless an aggregate function is provided. For pre-computed aggregations, use record.output.statistics[evaluator_name] instead.

Development

# Install dependencies
uv sync

# Run tests
uv run pytest

# Lint and format
uv run ruff check --fix .
uv run ruff format .

# Type check
uv run mypy mistralai

Publishing

Release from GitHub

The version is not stored in code. This package uses uv-dynamic-versioning: the published version comes from the release tag (evaluations-sdk/vX.Y.Z), and the workflow stamps the version you pass onto the build via UV_DYNAMIC_VERSIONING_BYPASS. There is no version-bump PR — just run the workflow with the version you want.

Run the "Release Evaluations SDK" GitHub workflow manually. Choose which registries to publish to via the boolean inputs — they're independent, so you can dogfood internally without shipping to clients:

  1. PyPI (public), via a trusted publisher (OIDC) — the primary channel. Default on.
  2. Gemfury, for internal distribution. Default on.
  3. Cloudsmith (mistral-ai/sdk-distribution), for private-preview client distribution. Default off — opt in when previewing to specific clients.

Run the workflow from main for normal SDK releases, or from the relevant mais-* release branch for on-prem patch lines. Enter the version as the workflow version input (PEP 440, e.g. 0.7.0 or 0.7.0rc1); the workflow fails if the tag evaluations-sdk/vX.Y.Z already exists.

The git tag evaluations-sdk/vX.Y.Z records the released commit for that version, so it is created as soon as any selected registry publishes successfully (and none of the selected ones failed). To dogfood privately, publish an rc to Gemfury only; the rc tag won't collide with the later public release.

If one registry succeeds and another fails, rerun the failed GitHub Actions jobs only. Do not rerun the full workflow, because the already-successful registry may reject the duplicate version.

The TypeScript mirror (ts/packages/local-observability-sdk/) still carries its own package.json / cli.ts version and is not published by this workflow; keep it in sync when practical.

Manual Gemfury publish

Retrieve the "Gemfury Upload Token - Mistral" credentials from Bitwarden. The make publish command expects GEMFURY_USERNAME and GEMFURY_PASSWORD environment variables.

# Publish to Gemfury
# this will clean up the dist/ directory then build and publish
make publish

Installing from PyPI (public)

pip install mistralai-evaluations

Installing from Gemfury (internal)

pip install --index-url https://pypi.fury.io/mistralai/ mistralai-evaluations --extra-index-url https://pypi.org/simple/

Metadata

Release files for mistralai-evaluations 0.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mistralai-evaluations 0.11.0
File Size Uploaded Provenance Actions
mistralai_evaluations-0.11.0.tar.gz 276.5 kB With provenance Details for mistralai_evaluations-0.11.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mistralai-evaluations 0.11.0
File Interpreter ABI Platform Actions
mistralai_evaluations-0.11.0-py3-none-any.whl Python 3 none any Details for mistralai_evaluations-0.11.0-py3-none-any.whl

Total release size: 427.1 kB

Release files / mistralai_evaluations-0.11.0.tar.gz

Download URL mistralai_evaluations-0.11.0.tar.gz
Size 276.5 kB
Tags Source
SHA-256 checksum
How to use checksums
81460f83e0fb620a63ea47e558e46266d3938325777be8025998a82e967672aa
BLAKE2b-256 checksum
How to use checksums
da59ddab3d48578c8d11e7132a08431dab1fef3426c152399efa148c9c019f30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / mistralai_evaluations-0.11.0-py3-none-any.whl

Download URL mistralai_evaluations-0.11.0-py3-none-any.whl
Size 150.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00e71ee74808edd6b232273cd2c653b2d95802f370133f4b716a1ecefb203fcf
BLAKE2b-256 checksum
How to use checksums
17bf882efd40340faa5f25e632ccc5d9d3c4f70dc4dcdc2b34eae98b97516a8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for mistralai-evaluations 0.11.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mistralai_evaluations-0.11.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page