Production-ready Spring Boot application integrating Google Gemini (gemini-3-flash-preview) via Ollama Cloud.
Supports both Text Chat and Image + Text Chat using clean architecture and Thymeleaf UI.
- ✅ Gemini Text Chat API
- ✅ Gemini Image + Text Chat API (Vision)
- ✅ Spring Boot REST API integration
- ✅ Thymeleaf Web UI
- ✅ Ollama Cloud model support
- ✅ Production-ready service architecture
- ✅ Clean DTO-based request/response structure
- ✅ Multipart file upload support
- ✅ Externalized configuration
gemini-3-flash-preview:cloud
https://ollama.com
springboot-gemini-integration
│
├── controller
│ ├── GeminiController.java
│ └── PageController.java
│
├── service
│ └── GeminiService.java
│
├── dto
│ ├── ChatRequest.java
│ └── ChatResponse.java
│
├── config
│ └── RestTemplateConfig.java
│
├── templates
│ └── index.html
│
└── application.yml
server:
port: 8080
gemini:
api:
url: http://localhost:11434/api/chat
model: gemini-3-flash-preview:cloudollama serveollama pull gemini-3-flash-preview:cloud./mvnw spring-boot:runor
mvn spring-boot:runApplication runs at:
http://localhost:8080
Text Chat
Image + Text Chat
Accessible at:
http://localhost:8080
Endpoint
POST /api/gemini/chat
Request
{
"message": "Explain Spring Boot"
}Response
{
"response": "Spring Boot is a Java framework..."
}Endpoint
POST /api/gemini/chat-with-image
Form Data
message: What is in this image?
image: file.jpg
curl -X POST http://localhost:8080/api/gemini/chat \
-H "Content-Type: application/json" \
-d '{"message":"Explain AI"}'curl -X POST http://localhost:8080/api/gemini/chat-with-image \
-F "message=Describe this image" \
-F "image=@test.png"- Java 17+
- Spring Boot 3+
- Thymeleaf
- RestTemplate
- Ollama Cloud
- Gemini Flash Preview
- Maven
Handles communication with Gemini model.
Supports:
- Text chat
- Image + Text chat
- JSON parsing
- Error handling
Provides REST APIs:
/api/gemini/chat
/api/gemini/chat-with-image
Provides Web UI integration via Thymeleaf.
- Layered architecture
- Exception handling
- External configuration
- Multipart upload support
- Clean separation of concerns
- Multi-model support (Kimi, Qwen, Mistral)
- Streaming responses
- Chat history
- Authentication
- Docker support
- Model router
Akash Kobal
GitHub: https://github.com/AkashKobal
MIT License
If this project helped you, please star the repository ⭐

