Spring AI
Spring AI Adapter
Section titled “Spring AI Adapter”AiSupport implementation backed by Spring AI ChatClient. When this JAR is on the classpath, @AiEndpoint automatically uses Spring AI for streaming.
Maven Coordinates
Section titled “Maven Coordinates”<dependency> <groupId>org.atmosphere</groupId> <artifactId>atmosphere-spring-ai</artifactId> <version>LATEST</version> <!-- check Maven Central for latest --></dependency>How It Works
Section titled “How It Works”Drop the dependency alongside atmosphere-ai and the framework auto-detects it via ServiceLoader:
@AiEndpoint(path = "/ai/chat", systemPrompt = "You are a helpful assistant")public class MyChat {
@Prompt public void onPrompt(String message, StreamingSession session) { session.stream(message); // uses Spring AI ChatClient automatically }}No code changes needed — the SpringAiSupport implementation has priority 100, which takes precedence over the built-in client (priority 0).
Direct Usage
Section titled “Direct Usage”For full control, use SpringAiStreamingAdapter directly:
var session = StreamingSessions.start(resource);springAiAdapter.stream(chatClient, prompt, session);With advisors:
springAiAdapter.stream(chatClient, prompt, session, myAdvisor);With a customizer:
springAiAdapter.stream(chatClient, prompt, session, spec -> { spec.system("Custom system prompt");});Spring Boot Auto-Configuration
Section titled “Spring Boot Auto-Configuration”AtmosphereSpringAiAutoConfiguration provides:
SpringAiStreamingAdapterbeanSpringAiSupportbridge bean (connects Spring-managedChatClientto the SPI)
The ChatClient bean must be configured separately via Spring AI’s own starter.
Samples
Section titled “Samples”- Spring Boot Spring AI Chat — complete example with Spring AI adapter
See Also
Section titled “See Also”- AI Integration —
AiSupportSPI,@AiEndpoint, filters, routing - LangChain4j Adapter
- Google ADK Adapter
- Embabel Adapter