A beginner-friendly Spring Boot application that demonstrates how to integrate and use OpenAI's chat capabilities with Spring AI framework.
📚 Read the Detailed Blog Series on Medium!
Learn step-by-step tutorials and deep dives into Spring AI concepts:
This project shows you how to:
- Create a Spring Boot application
- Connect to OpenAI's API using Spring AI
- explore all the chat functionalities provided by Spring AI
Technologies Used:
- Java 17
- Spring Boot 3.3.5
- Spring AI 1.0.1
- Gradle (build tool)
- OpenAI API
Before you start, make sure you have:
- Java 17 or higher installed on your computer
- Gradle (comes with the project as a wrapper)
- OpenAI API Key - Get one from OpenAI
- Git (optional, for cloning the repository)
git clone <repository-url>
cd spring_ai_101Create a file named .env or set an environment variable:
Option A: Using .env file
OPENAI_API_KEY=your_openai_api_key_hereOption B: Using application.properties
Create src/main/resources/application.properties:
spring.ai.openai.api-key=your_openai_api_key_here
spring.ai.openai.chat.options.model=gpt-4Using Gradle:
./gradlew bootRunOr if you're on Windows:
gradlew.bat bootRunThe application will start at http://localhost:8080