> Markdown version of [Visual Studio Code](https://vaadin.com/docs/next/building-apps/ai/technical-setup/ide/vscode). Section index: [llms.txt](https://vaadin.com/docs/next/building-apps/llms.txt)

# Visual Studio Code

In Visual Studio Code you can configure environment variables for your project in different ways:

- Add the variable directly in `.vscode/launch.json`:

  ```json
  {
    "configurations": [
      {
        "type": "java",
        "name": "Launch Vaadin App",
        "request": "launch",
        "mainClass": "com.example.Application",
        "env": {
          "OPENAI_API_KEY": "your-key-here"
        }
      }
    ]
  }
  ```

- Store the variable in a `.env` file and reference it from `launch.json`. This allows you to add `.env` to `.gitignore` to avoid committing keys.

```json
{
  "configurations": [
    {
      "type": "java",
      "name": "Launch Vaadin App",
      "request": "launch",
      "mainClass": "com.example.Application",
      "envFile": "${workspaceFolder}/.env"
    }
  ]
}
```

You can then reference the variable in your configuration files:

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