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

> How to add OpenAI as the LLM provider for Atoti Intelligence in an Atoti Java project via Spring AI, including the `spring-ai-starter-model-openai` Maven dependency, `application.yaml` API key and model configuration, and support for OpenAI-compatible APIs.

<Info>
  ### Atoti Intelligence Essentials

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

This guide explains how to configure OpenAI as the Large Language Model (LLM) provider for Atoti Intelligence in an Atoti Java project.

<Note>
  ### Compatible APIs

  Many LLMs support the OpenAI API format. A model from another provider may be compatible with this configuration.
</Note>

## Prerequisites

Before configuring OpenAI, ensure the following requirements are met:

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

## Add the dependency

Add the Spring AI OpenAI dependency to the project.

Add the following to `pom.xml`:

```xml theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
<dependency>
  <groupId>org.springframework.ai</groupId>
  <artifactId>spring-ai-starter-model-openai</artifactId>
</dependency>
```

## Configure the model

Configure the OpenAI model in the application configuration file. This example assumes that `LLM_API_KEY` is passed as an environment variable or JVM argument.

Add the following to `application.yaml`:

```yaml theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
spring:
  ai:
    openai:
      api-key: ${LLM_API_KEY}
      chat:
        options:
          model: gpt-4o
          temperature: 0.
          max-tokens: 5000
```

Replace the model name with an available OpenAI model.

Refer to the [Spring AI documentation](https://docs.spring.io/spring-ai/reference/api/chat/comparison.html) for any additional configuration options.

## Verify the configuration

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

1. Start the Atoti application.
2. Check the application logs for successful LLM initialization.
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 Java](../auto-explain/setup-java)
* [Set up Visualize This in Java](../visualize-this/setup-java)
