> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up Auto-Explain in Python

> How to enable Auto-Explain in an Atoti Python project through the `ai` plugin and `AiConfig`, access it via `Cube.auto_explain`, and tune its constants from Python.

<Info>
  ### Atoti Intelligence Essentials

  This is part of the Atoti Intelligence Essentials offer.
</Info>

This guide explains how to enable Auto-Explain in an Atoti Python project.

<Note>
  Auto-Explain does not require an LLM to function. The root-cause analysis, contribution percentages, and contribution tables are produced by a deterministic algorithm and are always available without any AI provider configured.

  An LLM is only required if the optional AI summary is needed. To enable AI summaries, configure an LLM provider. See [Set up an LLM](../configure-and-start/set-up-an-llm).
</Note>

## Prerequisites

Before setting up Auto-Explain, ensure the following requirements are met:

* An Atoti Python project
* A license with the AI flag enabled

## Install the package

Install the Atoti AI package:

```bash theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
uv add "atoti[ai]"
```

## Enable Auto-Explain

Pass an [`AiConfig`](https://docs.activeviam.com/products/atoti/python-sdk/latest/api/atoti_ai.ai_config.html) to [`SessionConfig`](https://docs.activeviam.com/products/atoti/python-sdk/latest/api/atoti.config.session_config.html) when starting the session. Auto-Explain works with an empty `AiConfig()`, so no LLM provider is required:

```python theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
import atoti as tt
from atoti_ai import AiConfig

with tt.experimental({"ai"}):
    ai_config = AiConfig()

session = tt.Session.start(tt.SessionConfig(ai=ai_config))
```

Auto-Explain is then available on each cube through [`Cube.auto_explain`](https://docs.activeviam.com/products/atoti/python-sdk/latest/api/atoti.Cube.auto_explain.html).

## Configure Auto-Explain

Auto-Explain constants are read and set as attributes of [`Cube.auto_explain`](https://docs.activeviam.com/products/atoti/python-sdk/latest/api/atoti.Cube.auto_explain.html). For the meaning, defaults, and tuning guidance of each constant, see [Configure Auto-Explain](./configuration).

```python theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
cube = session.cubes["Example"]

cube.auto_explain.max_depth = 5
cube.auto_explain.max_entropy = 0.5

# Restrict analysis to specific hierarchies
h = cube.hierarchies
cube.auto_explain.excluded_hierarchies = {h["Time"]}
```

Per-measure overrides are also available through `excluded_hierarchies_per_measure` and `included_hierarchies_per_measure`, keyed by measure name — the Python equivalent of the Java `excluded-measure-hierarchies` / `included-measure-hierarchies` configuration.

## Verify the setup

After enabling Auto-Explain, verify that it is available:

1. Start the Atoti session.
2. Open the Atoti UI.
3. Right-click two cells in a pivot table.
4. Check that the Auto-Explain option appears in the context menu.

## Related reading

* [How Auto-Explain works](./how-it-works) — the algorithm and a worked example
* [Configure Auto-Explain](./configuration) — constants reference and tuning guidance
* [How to use Auto-Explain](../../../user-guide/auto-explain) in the Atoti UI
* [`atoti_ai.AutoExplain`](https://docs.activeviam.com/products/atoti/python-sdk/latest/api/atoti_ai.auto_explain.html) API reference
