Java SDK
The AG-UI Java SDK is a modular library for the Agent User Interaction Protocol. You can use it to call a remote AG-UI agent from Java, to serve your own agent to any AG-UI front end, or both. Note: This SDK is community contributed and maintained. Source code lives insdks/community/java.
The SDK is built around a few design choices:
- Plain JDK streaming. An agent run is a
java.util.concurrent.Flow.Publisher<Event>, the Reactive Streams interface that ships with the JDK. The core needs no Reactor, RxJava or coroutines, and you can adapt the publisher to any of them. - No runtime dependencies in the core.
java-core,java-clientandjava-serverdepend only on the JDK. JSON goes through aSerializerinterface that you plug in. A ready-made Jackson implementation is available. - Sealed, record-based model.
EventandMessageare sealed interfaces implemented by records, so you can handle them with an exhaustiveswitch. - Transport-neutral server. The server core does not depend on any HTTP framework. It ships an adapter for the JDK’s built-in HTTP server, and separate Spring WebFlux, Spring WebMVC and Spring AI integrations.
Requirements
- Java 17 or later
- For the Spring modules: Spring Boot 4.1.x, and Spring AI 2.x for the Spring AI modules
Modules
All artifacts are published to Maven Central under thecom.ag-ui.community group ID.
Core library
Spring integration
The Spring modules are versioned in two lines. The Spring Boot line follows the Spring Boot version it targets, and the Spring AI line follows the Spring AI version.
Installation
Add the modules you need.java-client and java-server pull in java-core transitively.
Quick start
Implement an agent
Agent is a functional interface. It takes a RunAgentInput and returns a Flow.Publisher<Event>. Each subscription to that publisher is one run. The JDK’s SubmissionPublisher is the simplest way to produce events:
Serve it
The JDK’s built-in HTTP server is enough to expose the agent as an SSE endpoint:POST a RunAgentInput to http://localhost:8080/agent.
Call it
HttpAgent is the client side. It is also an Agent, so it is consumed the same way as a local agent:
Use Spring AI without writing code
To serve an LLM through Spring AI, addag-ui-spring-ai-spring-boot-starter (or ag-ui-spring-ai-webmvc-boot-starter for a Servlet app) together with a Spring AI model starter such as spring-ai-starter-model-openai. A SpringAiAgent is registered from the auto-configured ChatClient.Builder and served at /agent. See Spring AI.
Next steps
- Core: the
Agentinterface, streaming, and serialization - Types:
RunAgentInput, messages, tools, and interrupts - Events: every event record and its fields
- Client: calling remote agents with
HttpAgent - Server: serving agents with the JDK server or your own transport
- Spring: WebFlux and WebMVC endpoints and starters
- Spring AI: turning a
ChatClientinto an AG-UI agent