This repository is a practical implementation of Spring AI with Java, providing functions to retrieve data from external APIs (such as weather and stock APIs) and feed it into OpenAI prompts. The goal is to enable applications to deliver intelligent, up-to-date, real-time data to users by leveraging AI capabilities with live data sources.
- Integrate Spring AI with Java to build intelligent applications.
- Retrieve and process data from external APIs (on this example, for weather and stock prices).
- Feed external data into OpenAI models for enhanced, context-aware responses.
- Provide a practical foundation for real-time data and AI integration.
The project is built with the following core technologies:
- Java 21
- Spring Boot 3.5.3
- Spring AI 1.0.0
- OpenAI Model Integration via Spring AI
- Lombok (for reducing boilerplate code)
- Jackson Databind (for JSON serialization/deserialization)
- Spring Boot Starter Web (for building RESTful APIs)
- Spring Boot Starter Test (for testing)
All dependencies and versions are managed via Maven. See pom.xml
for details.
- Java 21 or higher installed
- Maven 3.8+ installed.
- An OpenAI API Key
-
Clone the repository:
git clone https://github.com/Intercont/spring-ai-functions.git cd spring-ai-functions
-
Configure your environment:
- Set your OpenAI API key in your environment variables or in your IDE if you are running from it:
export OPENAI_API_KEY=YOUR_OPENAI_API_KEY
- Set your Api Ninjas API key in your environment variables or in your IDE if you are running from it:
export API_NINJAS_KEY=YOUR_API_NINJAS_KEY
-
Build the project:
mvn clean install
-
Run the application:
mvn spring-boot:run
-
Access APIs:
- The application will start on http://localhost:8080 by default.
- Explore the exposed endpoints for retrieving real-time data and AI-powered results.
Contributions are welcome! Please open issues or pull requests to help improve the project.
This project is provided for educational and practical purposes. See the repository for license details.
Maintainer: Intercont
Built with Spring Boot and Spring AI.
Subscribe at igorfragadev.com for more