> ## 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 Atoti Intelligence to use OpenAI in Python

> How to configure OpenAI as the LLM provider for Atoti Intelligence in an Atoti Python project, using `ConnectionConfig` and `ChatConfig` from `atoti_ai_openai` with `AiConfig`, including OpenAI-compatible providers.

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

This guide explains how to configure OpenAI as the LLM provider for Atoti Intelligence in an Atoti Python project.

> [!NOTE]
>
> ### Compatible APIs
>
> Many LLMs support the OpenAI API format. A model from another provider may be compatible with this configuration.

## Prerequisites

Before configuring OpenAI, ensure the following requirements are met:

* An Atoti Python project
* An OpenAI account with API access, or a compatible provider
* An OpenAI API key

## Install the package

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

## Configure the LLM

Use [`ConnectionConfig`](https://docs.activeviam.com/engine/python-sdk/latest/api/atoti_ai_openai.ConnectionConfig) and [`ChatConfig`](https://docs.activeviam.com/engine/python-sdk/latest/api/atoti_ai_openai.ChatConfig) from `atoti_ai_openai` to configure the LLM connection, then pass them to [`AiConfig`](https://docs.activeviam.com/engine/python-sdk/latest/api/atoti_ai.config.AiConfig).

The following example uses Azure OpenAI, an OpenAI-compatible provider. Adapt the `base_url` and environment variable names for other providers.

```python theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
import atoti as tt
import os
from atoti_ai import AiConfig
from atoti_ai_openai import ConnectionConfig, ChatConfig
connection_config = ConnectionConfig(
    api_key=os.environ["AZURE_OPENAI_API_KEY"],
    base_url="https://aiwopenai.openai.azure.com/openai/v1",
)
chat_config = ChatConfig(
    model="gpt-5",
    max_completion_tokens=5000,
)
ai_config = AiConfig(connection=connection_config, chat=chat_config)
session_config = tt.SessionConfig(ai=ai_config)
```

Then pass the config to the session through [`SessionConfig`](https://docs.activeviam.com/engine/python-sdk/latest/api/atoti.config.SessionConfig):

```python theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
session = tt.Session.start(tt.SessionConfig(ai=ai_config))
```

### `ConnectionConfig` parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `api_key` | `RedactedStr` | No | OpenAI API key for authentication. |
| `base_url` | `str` | No | Base URL for the OpenAI API. Useful for OpenAI-compatible providers. The path to the API (such as `/v1`) must be included. |
| `custom_headers` | `FrozenMapping[str, RedactedStr]` | No | Custom HTTP headers to add to every request. |
| `max_retries` | `int` | No | Maximum number of retries for requests to OpenAI. |
| `organization_id` | `str` | No | OpenAI organization ID. |
| `timeout` | `Duration` | No | Timeout for requests to OpenAI. |

### `ChatConfig` parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `model` | `str` | Yes | The ID of the model to use, for example `"gpt-4o"`. |
| `extra_body` | `FrozenMapping[str, bool \| int \| float \| str]` | No | Additional parameters for OpenAI-compatible servers. |
| `max_completion_tokens` | `int` | No | Maximum number of tokens to generate for reasoning models (e.g. o1, o3). Mutually exclusive with `max_tokens`. |
| `max_tokens` | `int` | No | Maximum number of tokens to generate in the response. For non-reasoning models. Mutually exclusive with `max_completion_tokens`. |
| `parallel_tool_calls` | `bool` | No | Enable parallel function calling during tool use. |
| `seed` | `int` | No | Seed for deterministic sampling (Beta). |
| `temperature` | `float` | No | Controls randomness in responses from 0.0 (deterministic) to 2.0 (creative). Not supported by reasoning models (e.g. o1, o3, gpt-5). |
| `tool_choice` | `str` | No | Tool/function calling behavior (`"none"`, `"auto"`, or a specific function name). |
| `top_p` | `float` | No | Nucleus sampling parameter. Controls diversity via cumulative probability. Not supported by reasoning models (e.g. o1, o3, gpt-5). |

## Verify the configuration

After completing the configuration, verify that the LLM connection works:

1. Start the Atoti session.
2. Open the Atoti UI.
3. Test an AI feature such as Visualize This or Auto-Explain.

## Related reading

After configuring OpenAI, proceed to set up AI features:

* [Set up Auto-Explain in Python](https://docs.activeviam.com/atoti-intelligence/6.2/developer-guide/enable-ai-tools/auto-explain/setup-python.md)
* [Set up Visualize This in Python](https://docs.activeviam.com/atoti-intelligence/6.2/developer-guide/enable-ai-tools/visualize-this/setup-python.md)
* [`atoti_ai_openai`](https://docs.activeviam.com/engine/python-sdk/latest/api/atoti_ai_openai) API reference
