https://github.com/bootcamptoprod/spring-ai-openrouter-integration
A simple Spring Boot application showcasing how to integrate OpenRouter with Spring AI to use different LLM models
https://github.com/bootcamptoprod/spring-ai-openrouter-integration
integrate-openrouter-with-spring-ai openrouter openrouter-api openrouter-integration spring-ai spring-ai-openrouter spring-ai-openrouter-integration
Last synced: 12 months ago
JSON representation
A simple Spring Boot application showcasing how to integrate OpenRouter with Spring AI to use different LLM models
- Host: GitHub
- URL: https://github.com/bootcamptoprod/spring-ai-openrouter-integration
- Owner: BootcampToProd
- Created: 2025-07-04T17:35:15.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-07-04T22:07:15.000Z (12 months ago)
- Last Synced: 2025-07-04T23:19:36.419Z (12 months ago)
- Topics: integrate-openrouter-with-spring-ai, openrouter, openrouter-api, openrouter-integration, spring-ai, spring-ai-openrouter, spring-ai-openrouter-integration
- Language: Java
- Homepage: https://bootcamptoprod.com/integrate-openrouter-with-spring-ai/
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🤖 Spring AI + OpenRouter: The Universal LLM Gateway
This repository demonstrates how to integrate **OpenRouter** with **Spring AI**, allowing you to access hundreds of Large Language Models (LLMs) from providers like OpenAI, Google, Anthropic, and many more through a single, unified API. This project showcases the power of switching between different AI models by changing just one line in your configuration file, with zero code modifications.
📖 **Dive Deeper**: For a complete walkthrough, detailed explanations of OpenRouter's benefits, and step-by-step instructions for building this example application, read our comprehensive blog post.
👉 [Integrate OpenRouter with Spring AI: Switch Between 400+ AI Models with Zero Code Changes](https://bootcamptoprod.com/integrate-openrouter-with-spring-ai/)
🎥 **Visual Learning**: Prefer video tutorials? Watch our step-by-step implementation guide on YouTube.
👉 YouTube Tutorial - Coming Soon
---
## 📦 Environment Variables
Make sure to provide this Java environment variable when running the application:
- `OPENROUTER_API_KEY`: Your secret API key from the OpenRouter.
---
## 💡 About This Project
This project implements a simple **Smart Chat Assistant** to demonstrate the ease of integrating OpenRouter with Spring AI. It showcases how to:
* Configure Spring AI to use any OpenAI-compatible API endpoint.
* Use a single `ChatClient` to access a vast array of models.
* Switch between different LLMs (e.g., from a free model to a paid one like GPT-4o) just by editing the `application.yml` file.
The application exposes a simple REST endpoint that takes a user's message, sends it to the configured model via OpenRouter, and returns the AI-generated response.
---