Docs

Documentation versions (currently viewingVaadin 25.1 (pre-release))

AI Support

Vaadin provides UI interfaces and an AI orchestrator for building AI-powered UIs with Vaadin, handling streaming, history, attachments, and tool calling.

Vaadin provides a set of UI interfaces and a coordination engine for building AI-powered UIs. The AIOrchestrator wires UI components to an LLM provider, handling streaming responses, conversation history, file attachments, and tool calling behind a simple builder API.

Note
Preview Feature

This is a preview version of AI support features. You need to enable it with the feature flag com.vaadin.experimental.aiComponents. Preview versions may lack some planned features, and breaking changes may be introduced in any Vaadin version. We encourage you to try it out and provide feedback to help us improve it.

Overview

The AI support module consists of three parts:

  • Orchestrator — AIOrchestrator is a non-visual coordination engine that connects UI components to an LLM provider. It has no DOM element and should not be added to a layout.

  • Provider — LLMProvider is the interface for communicating with LLM frameworks. Use the static LLMProvider.from(…​) factory methods to create a provider from a Spring AI or LangChain4j model. You can also implement this interface to connect to any other LLM framework.

  • Component interfaces — AIInput, AIMessageList, AIMessage, and AIFileReceiver define contracts for UI components that the orchestrator can work with. The builder also accepts standard Vaadin components (MessageInput, MessageList, UploadManager, Upload) directly.

Add the UI components to your layout and pass them to the orchestrator through its builder. The orchestrator wires them together and manages the LLM interaction.

Basic Usage

Create an AI Orchestrator by passing an LLM provider and optional UI components to the builder. The following example uses a mock provider — replace it with a real provider via LLMProvider.from(…​) in production (see LLM Providers).

Source code
AIOrchestratorBasic.java

When the user submits a message through the Message Input, the orchestrator automatically:

  1. Displays the user message in the Message List

  2. Sends the message to the LLM provider

  3. Streams the response tokens into the Message List in real time

  4. Records the exchange in the conversation history

By default, user messages are labeled "You" and assistant messages are labeled "Assistant". Use withUserName() and withAssistantName() on the builder to customize these display names.

Server Push

Streaming mode pushes partial responses to the UI as tokens arrive. This requires server push to be enabled. Annotate your application shell with @Push:

Source code
Java
@Push
@SpringBootApplication
public class Application implements AppShellConfigurator {
}
Tip
Synchronous mode does not require push. If push is not available in your environment, disable streaming on the provider. A warning is logged at runtime if push is not enabled when using streaming mode.

Topics

Component Interfaces
AI interface contracts for input, message list, message, and file receiver components used by the AIOrchestrator.
LLM Providers
Connect the AIOrchestrator to Spring AI, LangChain4j, or a custom LLM framework using the LLMProvider interface.
File Attachments
Enable file uploads in the AIOrchestrator to send attachments to the LLM with user prompts.
Tool Calling & Programmatic Prompts
Register tool objects for LLM invocation and send prompts programmatically without a Message Input component.
Conversation History & Session Persistence
Persist and restore conversation history, and reconnect the AIOrchestrator after session deserialization.
Component Usage recommendations

Message Input

Text input for user messages. Pass to the orchestrator with withInput().

Message List

Displays messages. Pass to the orchestrator with withMessageList().

Upload

File uploads via UploadManager. Pass to the orchestrator with withFileReceiver().