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

# atoti_ai_openai.ConnectionConfig

### *final class* atoti\_ai\_openai.ConnectionConfig

Configuration for connecting to OpenAI.

<Warning>
  This feature is [`experimental`](./atoti.experimental#atoti.experimental), its key is `"ai"`.
</Warning>

### Example

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> import os
>>> from atoti_ai import AiConfig
>>> from atoti_ai_openai import ConnectionConfig, ChatConfig
```

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> with tt.experimental({"ai"}):
...     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-4.1",
...         temperature=0.0,
...         max_tokens=5000,
...         top_p=0.8,
...     )
...     ai_config = AiConfig(connection=connection_config, chat=chat_config)
```

<Callout icon="link">
  **See also**:
  The other [`ConnectionConfig`](./atoti_ai.connection_config#atoti_ai.ConnectionConfig) implementations.
</Callout>

#### api\_key *: [str](https://docs.python.org/3/library/stdtypes.html#str) | [None](https://docs.python.org/3/library/constants.html#None)* *= None*

OpenAI API key for authentication.

#### base\_url *: [str](https://docs.python.org/3/library/stdtypes.html#str) | [None](https://docs.python.org/3/library/constants.html#None)* *= None*

Base URL for the OpenAI API.

Useful for OpenAI-compatible providers.
The path to the API (such as `/v1`) must be included.

#### custom\_headers *: [Mapping](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping)\[[str](https://docs.python.org/3/library/stdtypes.html#str), [str](https://docs.python.org/3/library/stdtypes.html#str)] | [None](https://docs.python.org/3/library/constants.html#None)* *= None*

Custom HTTP headers to add to every request.

#### max\_retries *: [int](https://docs.python.org/3/library/functions.html#int) | [None](https://docs.python.org/3/library/constants.html#None)* *= None*

Maximum number of retries for requests to OpenAI.

#### organization\_id *: [str](https://docs.python.org/3/library/stdtypes.html#str) | [None](https://docs.python.org/3/library/constants.html#None)* *= None*

OpenAI organization ID.

#### timeout *: [timedelta](https://docs.python.org/3/library/datetime.html#datetime.timedelta) | [None](https://docs.python.org/3/library/constants.html#None)* *= None*

Timeout for requests to OpenAI.
