> ## 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.

> [!NOTE]
>
> ### Atoti Intelligence Essentials
>
> This is part of the Atoti Intelligence Essentials offer.

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](https://docs.activeviam.com/atoti-intelligence/6.2/developer-guide/enable-ai-tools/configure-and-start/set-up-an-llm.md).

## 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/6.2/languages/pycon.tmLanguage.json"]}}
uv add "atoti[ai]"
```

## Enable Auto-Explain

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

```python theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
import atoti as tt
from atoti_ai import AiConfig
session_config = tt.SessionConfig(ai=AiConfig())
```

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

## Configure Auto-Explain

Auto-Explain constants are read and set as attributes of [`AutoExplain`](https://docs.activeviam.com/engine/python-sdk/latest/api/atoti_ai.AutoExplain), reached through [`Cube.auto_explain`](https://docs.activeviam.com/engine/python-sdk/latest/api/atoti.Cube.auto_explain). For the meaning, defaults, and tuning guidance of each constant, see [Configure Auto-Explain](https://docs.activeviam.com/atoti-intelligence/6.2/developer-guide/enable-ai-tools/auto-explain/configuration.md).

For example, to make the analysis stop after five levels instead of the default 15:

```python theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
cube.auto_explain.max_depth = 5
```

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](https://docs.activeviam.com/atoti-intelligence/6.2/developer-guide/enable-ai-tools/auto-explain/how-it-works.md) — the algorithm and a worked example
* [Configure Auto-Explain](https://docs.activeviam.com/atoti-intelligence/6.2/developer-guide/enable-ai-tools/auto-explain/configuration.md) — constants reference and tuning guidance
* [How to use Auto-Explain](https://docs.activeviam.com/atoti-intelligence/6.2/user-guide/auto-explain.md) in the Atoti UI
* [`atoti_ai.AutoExplain`](https://docs.activeviam.com/engine/python-sdk/latest/api/atoti_ai.AutoExplain) API reference
