Skip to content

This repository is a practical implementation of Spring AI with Java to integrate the power of OpenAI ChatGPT into microservices, step by step, using the most up-to-date resources from the framework

Notifications You must be signed in to change notification settings

Intercont/spring-ai-intro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring AI Intro

This repository provides a practical implementation of integrating Spring AI with Java microservices, demonstrating how to leverage the power of OpenAI's ChatGPT API within modern Spring-based applications. Designed as a step-by-step guide, it showcases best practices and up-to-date techniques for enhancing microservices with AI capabilities.

Technologies Used

  • Java (main language)
  • Spring Boot (microservices framework)
  • Spring AI (AI integration library)
  • OpenAI API (ChatGPT integration)
  • Maven (project management and build tool)

Getting Started

Prerequisites

  • Java 21 or higher installed
  • Maven 3.8+
  • OpenAI API key (sign up at OpenAI and obtain your API key)

Setup Instructions

  1. Clone the repository:

    git clone https://github.com/Intercont/spring-ai-intro.git
    cd spring-ai-intro
    
  2. Configure your OpenAI API Key

    • Create or edit the file src/main/resources/application.properties and add:
      spring.ai.openai.api-key=YOUR_OPENAI_API_KEY
      
    • It is recommended to set the API key as an environment variable instead of having it on your properties file:
      export OPENAI_API_KEY=YOUR_OPENAI_API_KEY
  3. Build the project

    mvn clean package
  4. Run the application

    mvn spring-boot:run

    or, using the generated JAR:

    java -jar target/spring-ai-intro-*.jar

Project Structure

  • src/main/java/: Java source code
  • src/main/resources/: Configuration files
  • pom.xml: Maven build configuration

Features

  • Step-by-step integration of Spring AI with Java microservices
  • Communication with OpenAI’s ChatGPT API
  • Example endpoints and request workflows
  • Easily extensible for custom AI use cases

Contributing

Contributions are welcome! Please open an issue or submit a pull request for suggestions, bug fixes, or enhancements.

License

This project is licensed under the MIT License.


Explore how to empower your Java microservices with AI using Spring AI and OpenAI!

Subscribe at igorfragadev.com for more

About

This repository is a practical implementation of Spring AI with Java to integrate the power of OpenAI ChatGPT into microservices, step by step, using the most up-to-date resources from the framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published