Technology RadarTechnology Radar
Trial

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.14.1 (May 11, 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 the upcoming Spring Boot 4 release, 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)

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.14.1 (May 11, 2026)
License Apache 2.0
Requires Java 11+
Provider Community (Red Hat + Microsoft backing)
GitHub langchain4j/langchain4j
Website docs.langchain4j.dev
Trial

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)