beginnerSpring AI Setup & Hello World

Why does Spring AI provide `ChatClient` as an abstraction instead of exposing each provider's raw SDK directly?

`ChatClient` gives one consistent fluent API (`.prompt().user(...).call()`) across OpenAI, Anthropic, Ollama, and others, so switching providers or supporting multiple providers in one app doesn't mean rewriting business logic — only the underlying `ChatModel` bean configuration changes.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to What's the difference between a system message and a user message in a chat prompt?← Back to all Spring AI questions