Part 2: Spring AI Chat Completions with OpenAI or Ollama

Part 2: Spring AI Chat Completions with OpenAI or Ollama

With Spring AI on the classpath, calling a chat model comes down to three things: add the right starter, set an API key or base URL in config, and inject ChatClient. The same Java code then works whether you’re hitting OpenAI in the cloud or a local Ollama model on your laptop — you swap the dependency and the config, not the logic. This is Part 2 of the Spring AI series. ...