LangChain4j is the leading framework-agnostic Java library for LLM integration — supporting 20+ model providers, 30+ vector stores, RAG, tool calling (including MCP), and agents, without requiring Spring or any specific web framework.
Why It's in Trial
LangChain4j is the right choice when:
- You're not on Spring Boot (Quarkus, Micronaut, plain Java, Jakarta EE)
- You want more explicit control over how AI components are wired together
- You're building agents with complex tool execution loops
- You want to mix and match providers and stores without Spring's auto-configuration
It launched in early 2023 and is now at version 1.18.0 (July 17, 2026) with a stable API. The Fall 2025 Java AI comparison describes it as a "two-horse race" between Spring AI and LangChain4j — both are production-ready, with LangChain4j winning on flexibility and agent maturity.
Key Capabilities
AI Services — declarative interface pattern:
interface CustomerSupport {
@SystemMessage("You are a helpful customer support agent for ACME Corp.")
String chat(String userMessage);
}
CustomerSupport support = AiServices.builder(CustomerSupport.class)
.chatLanguageModel(openAiChatModel)
.chatMemory(MessageWindowChatMemory.withMaxMessages(10))
.tools(new OrderLookupTool())
.build();
The AiServices pattern is LangChain4j's standout feature — define an interface, get an LLM-backed implementation. This is cleaner than Spring AI's ChatClient fluent API for service-oriented code.
Tool calling: Define @Tool-annotated methods on any POJO. LangChain4j handles the function-call loop automatically — the model can call your tools, receive results, and continue reasoning.
class CalendarTool {
@Tool("Get the user's upcoming calendar events")
List<Event> getCalendarEvents(String userId, int daysAhead) {
return calendarService.getEvents(userId, daysAhead);
}
}
MCP support: LangChain4j 1.x supports MCP tool calling — any MCP server can be used as a tool source, giving access to the full ecosystem of Stripe, Figma, Vercel, Postgres MCP servers without custom integration.
Broad provider support: 20+ LLM providers, 30+ embedding/vector stores. Switching providers means swapping one ChatLanguageModel implementation — all higher-level code stays the same.
RAG: Full ingestion pipeline (document loading, splitting, embedding) and retrieval with metadata filtering, re-ranking, and query expansion.
Streaming agents (1.11.0): The TokenStream interface enables streaming agent responses — tokens arrive as they're generated while tool calls execute mid-stream. This closes a gap that previously required workarounds for real-time chat UIs backed by tool-calling agents.
Agent Observability: AgentListener and AgentMonitor (added in 1.10.0) provide observability hooks for monitoring agent execution in production.
Agentic state persistence (1.13.0): Execution state of agentic systems can now be persisted and recovered — agents can checkpoint mid-run and resume without repeating expensive LLM calls. This closes a gap that previously required custom state management or was only available in Koog.
Skill-scoped tools (1.13.0): The new ClassPathSkillLoader groups tools into skills that can be selectively loaded per agent, reducing token overhead from irrelevant tool descriptions.
Spring Boot 4 support (1.13.0): First-class compatibility with Spring Boot 4 (GA since November 2025), alongside continued Spring Boot 3.x support.
Agentic A2A modules (v1.3.0): langchain4j-agentic and langchain4j-agentic-a2a are now first-class modules — not experimental. The agentic module provides workflow patterns (sequential, loop, parallel, conditional) and a supervisor pattern for dynamic agent routing via AgenticScope. The A2A module adds @A2AClientAgent for calling remote A2A servers. A companion langchain4j-agentic-mcp module wraps MCP tools as non-AI agents. Both Red Hat and Microsoft back the project, with Microsoft reporting hundreds of customers in production. 1.13.1 (April 23, 2026) patches a bug where typed A2A agents received incorrect argument types.
Polymorphic return types and ReturnBehavior.IMMEDIATE_IF_LAST (1.14.0): AI Services can now return polymorphic types from tool parameters, and the new ReturnBehavior.IMMEDIATE_IF_LAST flag lets agents return early when the last tool call is ready — removing the extra inference round-trip for simple pipelines.
OpenAI Responses API expansion (1.14.0): Non-streaming ChatModel support, reasoning summaries, encrypted reasoning, and server-side tool execution are now available through the Responses API integration. PDF file input and logprobs are also supported.
Anthropic thinking visibility (1.14.0): The new thinkingDisplay option controls whether the extended thinking token stream is exposed to callers — useful for debugging agents that use Claude's thinking mode without surfacing raw token streams in production logs.
MCP: multiple listeners and session IDs (1.14.0): MCP tool call sessions now expose a stable sessionId and support multiple concurrent listeners, making it easier to correlate tool calls with agent traces in observability pipelines. (1.14.0 changelog)
Security dependency updates (1.14.1, May 11, 2026): Patch release updating opennlp-tools to 2.5.9 and PostgreSQL driver to v42.7.11, which includes security fixes. No API changes. (1.14.1 changelog)
Blackboard agentic pattern (1.16.0, June 2026): New multi-agent coordination pattern where agents read and write to a shared structured state store rather than passing messages directly. Enables parallel agent execution and cleaner agent specialization — each agent focuses on one domain without needing to know about others. Complements the existing supervisor and sequential workflow patterns.
Tool method inheritance (1.16.0): @Tool-annotated methods can now be inherited from superclasses and interfaces, enabling tool reuse across agents without duplication. A BaseAgent class can define common tools (logging, auth checking) that all subclasses inherit automatically.
MCP notification and schema improvements (1.16.0): Better MCP server notification handling and more complete tool schema surfacing give agents visibility into dynamically available tools — important for agents that discover capabilities at runtime from MCP servers. (1.16.0 changelog)
SQL injection security fix (1.16.3, June 18, 2026): Patched SQL injection vulnerabilities in metadata filter handling for the langchain4j-mariadb and langchain4j-pgvector modules. Users of either module should upgrade immediately. No API changes. (1.16.3 changelog)
Debate agentic pattern and tool compensating actions (1.17.0, June 26, 2026): New Debate multi-agent coordination pattern enables a structured adversarial review loop — one agent proposes, another critiques, they iterate until consensus or a turn limit is reached. Complements the existing Blackboard (shared state, 1.16.0) and supervisor patterns. Also adds tool compensating actions: tools can now declare a compensation (rollback) action that runs automatically if a downstream step in the same agent execution fails — enabling saga-style transactional semantics without custom orchestration code. Additional additions: Oracle Database chat memory support, exposure of unmapped raw streaming events for custom event handling, and migration of the OpenAI DALL-E image integration to the GPT Image API. (1.17.0 changelog)
Hibernate ORM compatibility patch (1.17.1, June 30, 2026): Patch release resolving a Hibernate ORM integration incompatibility (HHH-20500 workaround) that affected projects using langchain4j-hibernate-orm chat memory alongside Hibernate 6.x. No API changes. (1.17.1 changelog)
AgentsRegistry, configurable A2A transport, and agentic method flexibility (1.17.2, July 6, 2026): Three additions that collectively harden the multi-agent integration surface. The new AgentsRegistry provides a thin integration layer for external agent providers — external systems can now register and expose their agents to LangChain4j agent graphs without requiring custom wiring. A2A transport is now fully configurable, giving teams control over timeouts, connection pools, and retry behavior in cross-agent calls. @AiService agentic methods no longer need to be public — inherited and package-private methods now work, enabling cleaner base-class abstractions where common behaviors are defined once and inherited without public API exposure. The agentic HTML execution report gains toggle buttons for tool invocations and expand/collapse row support, improving debuggability of long agent traces. Maintenance: Jackson bumped to 2.21.4. (1.17.2 changelog)
BDI agentic pattern, crash-resilient HITL, and expanded provider support (1.18.0, July 17, 2026): The Belief-Desire-Intention (BDI) framework from classical multi-agent systems research — contributed by Red Hat's Mario Fusco — formalizes goal-directed agent decision-making. BDI agents maintain Beliefs (what the agent knows), Desires (goals to achieve), and Intentions (committed plan steps), enabling more structured autonomous behavior than the existing loop/workflow/supervisor/debate patterns. Adds crash-resilient Human-in-the-Loop suspension and resume — agents can pause mid-execution and resume while maintaining full state across JVM restarts, closing a reliability gap that previously required custom state management. Also adds: OpenAI TTS for audio generation, MistralAiBatchChatModel for Mistral's Batch API, and an EmbeddingModel API overhaul with per-call parameters, multimodal inputs, and observability hooks. Oracle Database added as a Chat Memory backend. Provider improvements across Anthropic, Vertex AI, Google Gemini, and OpenAI; internal HTTP client migrated from Retrofit/OkHttp to a new HttpClient abstraction reducing dependencies. (1.18.0 changelog)
Spring AI vs LangChain4j: When to Use Which
| Scenario | Use |
|---|---|
| Existing Spring Boot app | Spring AI |
| Quarkus or Micronaut app | LangChain4j (via native extensions) |
| Plain Java or Jakarta EE | LangChain4j |
| Need complex multi-tool agents | LangChain4j |
| Prefer annotation-driven DI style | Spring AI |
| Prefer explicit, testable interfaces | LangChain4j |
Getting Started
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-open-ai-spring-boot-starter</artifactId>
<version>1.18.0</version>
</dependency>
Key Characteristics
| Property | Value |
|---|---|
| Status | 1.18.0 (July 17, 2026) |
| License | Apache 2.0 |
| Requires | Java 11+ |
| Provider | Community (Red Hat + Microsoft backing) |
| GitHub | langchain4j/langchain4j |
| Website | docs.langchain4j.dev |
LangChain4j is the leading framework-agnostic Java library for LLM integration — supporting 20+ model providers, 30+ vector stores, RAG, tool calling (including MCP), and agents, without requiring Spring or any specific web framework.
Why It's in Trial
LangChain4j is the right choice when:
- You're not on Spring Boot (Quarkus, Micronaut, plain Java, Jakarta EE)
- You want more explicit control over how AI components are wired together
- You're building agents with complex tool execution loops
- You want to mix and match providers and stores without Spring's auto-configuration
It launched in early 2023 and is now at version 1.x with a stable API. The Fall 2025 Java AI comparison describes it as a "two-horse race" between Spring AI and LangChain4j — both are production-ready, with LangChain4j winning on flexibility and agent maturity.
Key Capabilities
AI Services — declarative interface pattern:
interface CustomerSupport {
@SystemMessage("You are a helpful customer support agent for ACME Corp.")
String chat(String userMessage);
}
CustomerSupport support = AiServices.builder(CustomerSupport.class)
.chatLanguageModel(openAiChatModel)
.chatMemory(MessageWindowChatMemory.withMaxMessages(10))
.tools(new OrderLookupTool())
.build();
The AiServices pattern is LangChain4j's standout feature — define an interface, get an LLM-backed implementation. This is cleaner than Spring AI's ChatClient fluent API for service-oriented code.
Tool calling: Define @Tool-annotated methods on any POJO. LangChain4j handles the function-call loop automatically — the model can call your tools, receive results, and continue reasoning.
class CalendarTool {
@Tool("Get the user's upcoming calendar events")
List<Event> getCalendarEvents(String userId, int daysAhead) {
return calendarService.getEvents(userId, daysAhead);
}
}
MCP support: LangChain4j 1.x supports MCP tool calling — any MCP server can be used as a tool source, giving access to the full ecosystem of Stripe, Figma, Vercel, Postgres MCP servers without custom integration.
Broad provider support: 20+ LLM providers, 30+ embedding/vector stores. Switching providers means swapping one ChatLanguageModel implementation — all higher-level code stays the same.
RAG: Full ingestion pipeline (document loading, splitting, embedding) and retrieval with metadata filtering, re-ranking, and query expansion.
Agent Observability: AgentListener and AgentMonitor (added in 1.10.0) provide observability hooks for monitoring agent execution in production.
Agentic A2A modules (v1.3.0): langchain4j-agentic and langchain4j-agentic-a2a are now first-class modules — not experimental. The agentic module provides workflow patterns (sequential, loop, parallel, conditional) and a supervisor pattern for dynamic agent routing via AgenticScope. The A2A module adds @A2AClientAgent for calling remote A2A servers. A companion langchain4j-agentic-mcp module wraps MCP tools as non-AI agents. Both Red Hat and Microsoft back the project, with Microsoft reporting hundreds of customers in production.
Spring AI vs LangChain4j: When to Use Which
| Scenario | Use |
|---|---|
| Existing Spring Boot app | Spring AI |
| Quarkus or Micronaut app | LangChain4j (via native extensions) |
| Plain Java or Jakarta EE | LangChain4j |
| Need complex multi-tool agents | LangChain4j |
| Prefer annotation-driven DI style | Spring AI |
| Prefer explicit, testable interfaces | LangChain4j |
Getting Started
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-open-ai-spring-boot-starter</artifactId>
<version>1.0.0</version>
</dependency>
Key Characteristics
| Property | Value |
|---|---|
| Status | 1.x stable |
| Requires | Java 11+ |
| Framework | None required (Spring, Quarkus, Micronaut, plain Java) |
| MCP support | Yes (tool calling) |