> Markdown version of [API Key for your IDE](https://vaadin.com/docs/latest/building-apps/ai/technical-setup/ide). Section index: [llms.txt](https://vaadin.com/docs/latest/building-apps/llms.txt)

# Configure Your Development Environment for AI

Choose a Java library to call an LLM API from your Vaadin application. For the individual configuration of common models, see each option in the respective documentation:

- [Spring AI — ChatModel](https://docs.spring.io/spring-ai/reference/api/chatmodel.html)

- [LangChain4j — Language Models](https://docs.langchain4j.dev/category/language-models)

## <a id="set-the-api-key-in-your-os"></a>Set the API Key in Your OS

To access commercial LLMs (e.g., OpenAI or Anthropic) you need to configure an API key to authenticate your requests. The recommended approach is to define the key as an environment variable in your operating system, so it is **not hard-coded or committed** to source control and can be reused across multiple projects.

**macOS / Linux**

```bash
export OPENAI_API_KEY="sk-..."
```

**Windows**

```powershell
$env:OPENAI_API_KEY="sk-..."
```

Alternatively, you can provide the API Key as a "local" environment variable or as a Java system property through your IDE’s Run/Debug configuration. You can find detailed instructions in the [IDE Quick Guides](#ide-quick-guides) section below.

You can also give API Keys as VM arguments. The following VM argument sets the `OPENAI_API_KEY` system property:

```
-DOPENAI_API_KEY=sk-your-key-here
```

For Spring AI, reference the system property or environment variable in your configuration:

```properties
spring.ai.openai.api-key=${OPENAI_API_KEY}
```

> **Warning:** Never commit API keys to source control. Prefer environment variables or your CI/CD secret store.

## <a id="ide-quick-guides"></a>IDE Quick Guides

If you’re unsure how to set environment variables in your specific IDE, see:

- [IntelliJ IDEA](https://vaadin.com/docs/latest/building-apps/ai/technical-setup/ide/intellij.md) (Ultimate or Community)

- [Visual Studio Code](https://vaadin.com/docs/latest/building-apps/ai/technical-setup/ide/vscode.md)

- [Eclipse IDE](https://vaadin.com/docs/latest/building-apps/ai/technical-setup/ide/eclipse.md)

## <a id="verify-the-setup"></a>Verify the Setup

Run the application and check that the model call succeeds. If you see authentication errors, confirm the variable is set in the environment that starts the JVM and that your configuration references `${OPENAI_API_KEY}`.

> **Note:** For Java/IDE requirements and plugins, see [Development Environment](https://vaadin.com/docs/latest/getting-started/dev-environment.md).
