Lecture 05: Creating a Spring AI Project
Project Setup with Spring Initializr:
● Go to [Link].
● Choose:
○ IDE: Intellij IDE
○ Project Type: Maven
○ Language: Java
○ Spring Boot Version: Latest stable
○ Group ID: [Link]
○ Artifact/Project Name: springAICode
Dependencies to Add:
● Spring Web—for building a web application.
● Spring AI (Model-specific):
○ For OpenAI → add Spring AI OpenAI Starter.
○ For Anthropic → add Anthropic Starter.
○ For Ollama → add Ollama Starter.
○ For Vertex AI (Google) → add Vertex Starter.
● In this lecture, only Spring Web and Spring AI OpenAI Starter are added.
[Link] after Adding Dependencies:
● spring-boot-starter-web
● spring-ai-openai-spring-boot-starter
Running the Project:
● When you run the app, it starts on the Tomcat server.
● But on the first run, it fails.
Why Does It Fail?
● Error: OpenAI API key must be set.
● Missing property: [Link]-key=YOUR_KEY_HERE
● This must be added in [Link].
Note: To fix the error, you need to generate and set the OpenAI API key.