Ollama runs open-source language models locally and for free on your own hardware, making it a practical development alternative to cloud AI services. section 1.2.2
Use Ollama with Spring AI by following this setup path:
- Install Ollama, then pull models such as Gemma 2B or Mistral 7B with the ollama command-line tool. section 1.2.2
- Add the Spring AI Ollama starter dependency; no API key is required because the service runs locally. section 1.2.2
- Select the model with spring.ai.ollama.chat.model, since Spring AI otherwise defaults to Mistral 7B. section 1.2.2
$ ollama pull gemma:2b
Pull a local Gemma model before connecting it to the application. section 1.2.2
Choosing a local model
Gemma 2B ran comfortably on an older MacBook Pro, while Gemma 7B used more memory and generated responses significantly more slowly. section 1.2.2







