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

# ConnectionConfig

<span id="atoti_ai_openai.ConnectionConfig" />

> atoti\_ai\_openai.ConnectionConfig(<br />
>     \*,<br />
>     *api\_key*: [str](https://docs.python.org/3/library/stdtypes.html#str) | [None](https://docs.python.org/3/library/constants.html#None) = `None`,<br />
>     *base\_url*: [str](https://docs.python.org/3/library/stdtypes.html#str) | [None](https://docs.python.org/3/library/constants.html#None) = `None`,<br />
>     *organization\_id*: [str](https://docs.python.org/3/library/stdtypes.html#str) | [None](https://docs.python.org/3/library/constants.html#None) = `None`,<br />
>     *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`,<br />
>     *max\_retries*: [int](https://docs.python.org/3/library/functions.html#int) | [None](https://docs.python.org/3/library/constants.html#None) = `None`,<br />
>     *timeout*: [timedelta](https://docs.python.org/3/library/datetime.html#datetime.timedelta) | [None](https://docs.python.org/3/library/constants.html#None) = `None`,<br />
> )

Configuration for connecting to OpenAI.

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/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)
```

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

### Attributes

<h4 id="atoti_ai_openai.ConnectionConfig.api_key">
  *api\_key*
</h4>

OpenAI API key for authentication.

<h4 id="atoti_ai_openai.ConnectionConfig.base_url">
  *base\_url*
</h4>

Base URL for the OpenAI API.

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

<h4 id="atoti_ai_openai.ConnectionConfig.organization_id">
  *organization\_id*
</h4>

OpenAI organization ID.

<h4 id="atoti_ai_openai.ConnectionConfig.custom_headers">
  *custom\_headers*
</h4>

Custom HTTP headers to add to every request.

<h4 id="atoti_ai_openai.ConnectionConfig.max_retries">
  *max\_retries*
</h4>

Maximum number of retries for requests to OpenAI.

<h4 id="atoti_ai_openai.ConnectionConfig.timeout">
  *timeout*
</h4>

Timeout for requests to OpenAI.
