TL;DR

LangChain4j is an open-source Java library with 10,600+ stars that simplifies building LLM-powered applications in Java. It provides a unified API for 20+ LLM providers (OpenAI, Anthropic, Google, etc.) and 30+ vector databases, with first-class support for RAG, tool calling, agents, and the Model Context Protocol (MCP). If you’re building AI features in Java—especially in enterprise environments—this is your go-to framework.

Why it matters: Java dominates enterprise software, but most LLM tooling targets Python. LangChain4j bridges that gap with production-grade abstractions that integrate seamlessly with Spring Boot, Quarkus, Helidon, and Micronaut.

Who it’s for: Java developers building chatbots, AI assistants, document Q&A systems, or any application that needs LLM capabilities. Especially valuable for enterprises already invested in the JVM ecosystem.


The Java AI Gap (And How LangChain4j Fills It)

If you’ve been building AI applications, you’ve probably noticed something: almost everything targets Python. LangChain, LlamaIndex, Haystack—they’re all Python-first. JavaScript has its own ecosystem. But Java? Until LangChain4j, the options were sparse.

This matters because Java isn’t going anywhere. Banks, healthcare systems, government agencies, and Fortune 500 companies run on Java. When these organizations want to add LLM capabilities to their existing systems, they don’t want to rewrite everything in Python. They want something that fits into their Maven builds, works with their Spring Boot applications, and follows patterns their developers already understand.

LangChain4j emerged in early 2023 to solve exactly this problem. Created by Dmytro Liubarskyi (@dliubarskyi), it’s grown into a comprehensive framework with over 10,600 stars, nearly 2,000 forks, and an active community.

The v1.11.0 release just dropped yesterday (February 4, 2026) with streaming agent support, multimodal agents, MCP enhancements, and hybrid search for Elasticsearch and PgVector. The pace of development is impressive.


What LangChain4j Actually Does

At its core, LangChain4j provides three things:

1. Unified APIs for LLM Providers

Instead of learning the API quirks of every LLM provider, you learn one interface:

ChatModel model = OpenAiChatModel.builder()
    .apiKey(System.getenv("OPENAI_API_KEY"))
    .modelName("gpt-4o-mini")
    .build();

String answer = model.chat("Explain monads in one sentence");

Want to switch to Anthropic? Change the builder:

ChatModel model = AnthropicChatModel.builder()
    .apiKey(System.getenv("ANTHROPIC_API_KEY"))
    .modelName("claude-3-5-sonnet-20241022")
    .build();

// Same interface, different provider
String answer = model.chat("Explain monads in one sentence");

The library currently supports 20+ LLM providers including:

  • OpenAI (GPT-4, GPT-4o, o1, etc.)
  • Anthropic (Claude 3.5, Claude 3 Opus)
  • Google (Gemini, Vertex AI)
  • Amazon Bedrock
  • Azure OpenAI
  • Mistral AI
  • Ollama (for local models)
  • Hugging Face
  • And many more

2. Vector Store Integrations

RAG (Retrieval-Augmented Generation) requires embedding stores. LangChain4j integrates with 30+ vector databases:

  • Pinecone
  • Milvus
  • Chroma
  • PgVector (PostgreSQL)
  • Elasticsearch
  • Azure AI Search
  • Redis
  • Weaviate
  • Qdrant
  • And more

The same unified API pattern applies:

EmbeddingStore<TextSegment> store = PineconeEmbeddingStore.builder()
    .apiKey(System.getenv("PINECONE_API_KEY"))
    .index("my-index")
    .build();

// Or switch to PgVector
EmbeddingStore<TextSegment> store = PgVectorEmbeddingStore.builder()
    .host("localhost")
    .port(5432)
    .database("vectors")
    .build();

3. High-Level Abstractions

This is where LangChain4j really shines. Instead of manually wiring prompts, context, and memory, you define an interface:

interface Assistant {
    String chat(String message);
}

Assistant assistant = AiServices.builder(Assistant.class)
    .chatModel(chatModel)
    .chatMemory(MessageWindowChatMemory.withMaxMessages(10))
    .build();

String response = assistant.chat("Hello!");

The library handles prompt construction, memory management, and response parsing automatically.


Building RAG Applications

RAG is the killer feature for most enterprise LLM applications. You have documents, and you want an LLM to answer questions about them accurately. LangChain4j offers three approaches, each building on the last.

Easy RAG: Five Minutes to Working Q&A

If you just want to get something running, Easy RAG is remarkably simple:

<dependency>
    <groupId>dev.langchain4j</groupId>
    <artifactId>langchain4j-easy-rag</artifactId>
    <version>1.11.0-beta19</version>
</dependency>
// Load documents
List<Document> documents = FileSystemDocumentLoader.loadDocuments("/path/to/docs");

// Store in memory
InMemoryEmbeddingStore<TextSegment> store = new InMemoryEmbeddingStore<>();
EmbeddingStoreIngestor.ingest(documents, store);

// Build assistant
interface Assistant {
    String chat(String userMessage);
}

Assistant assistant = AiServices.builder(Assistant.class)
    .chatModel(chatModel)
    .chatMemory(MessageWindowChatMemory.withMaxMessages(10))
    .contentRetriever(EmbeddingStoreContentRetriever.from(store))
    .build();

// Ask questions
String answer = assistant.chat("What does our refund policy say?");

Under the hood, Easy RAG:

  • Uses Apache Tika to parse PDFs, Word docs, HTML, and more
  • Splits documents into 300-token chunks with 30-token overlap
  • Embeds using bge-small-en-v1.5—a local model that runs in-process via ONNX Runtime

No external embedding service required. It just works.

Naive RAG: More Control

When you need customization, drop down to the core APIs:

// Custom document parsing
DocumentParser parser = new ApachePdfBoxDocumentParser();
Document document = FileSystemDocumentLoader.loadDocument("/path/to/file.pdf", parser);

// Custom splitting
DocumentSplitter splitter = DocumentSplitters.recursive(500, 50);
List<TextSegment> segments = splitter.split(document);

// Custom embedding model
EmbeddingModel embeddingModel = OpenAiEmbeddingModel.builder()
    .apiKey(apiKey)
    .modelName("text-embedding-3-small")
    .build();

// Embed and store
List<Embedding> embeddings = embeddingModel.embedAll(segments).content();
embeddingStore.addAll(embeddings, segments);

Advanced RAG: Production-Grade Pipelines

For serious applications, LangChain4j provides modular components you can compose:

Query Transformation: Rewrite user queries for better retrieval

QueryTransformer transformer = CompressingQueryTransformer.builder()
    .chatModel(chatModel)
    .build();

Multiple Retrieval Sources: Search across different stores

ContentRetriever retriever1 = EmbeddingStoreContentRetriever.from(productDocs);
ContentRetriever retriever2 = EmbeddingStoreContentRetriever.from(supportDocs);

ContentAggregator aggregator = ReRankingContentAggregator.builder()
    .scoringModel(scoringModel)
    .build();

Hybrid Search: Combine semantic and keyword search

// New in v1.11.0 - hybrid search for Elasticsearch and PgVector
ElasticsearchContentRetriever retriever = ElasticsearchContentRetriever.builder()
    .client(client)
    .indexName("documents")
    .hybridSearch(true)
    .build();

Re-ranking: Improve result quality

ContentAggregator aggregator = ReRankingContentAggregator.builder()
    .scoringModel(CohereScorer.withApiKey(apiKey))
    .build();

Tool Calling and Function Execution

Modern LLMs can call functions—asking the application to execute code and return results. LangChain4j makes this trivial:

class Calculator {
    @Tool("Adds two numbers")
    public double add(double a, double b) {
        return a + b;
    }
    
    @Tool("Multiplies two numbers")
    public double multiply(double a, double b) {
        return a * b;
    }
}

interface MathAssistant {
    String chat(String userMessage);
}

MathAssistant assistant = AiServices.builder(MathAssistant.class)
    .chatModel(chatModel)
    .tools(new Calculator())
    .build();

// The LLM will automatically call the tools when needed
String response = assistant.chat("What is 15 * 7 plus 23?");

The @Tool annotation exposes methods to the LLM. When the model decides it needs to calculate something, LangChain4j handles the tool call, executes your code, and feeds the result back to the model.

MCP (Model Context Protocol) Support

The v1.11.0 release enhances MCP support—Anthropic’s protocol for connecting AI to external tools. You can now:

  • Inject context into MCP header providers
  • Add listeners for MCP events
  • Use the updated 2025-11-25 MCP specification
McpTransport transport = StdioMcpTransport.builder()
    .command("npx", "-y", "@modelcontextprotocol/server-filesystem")
    .build();

McpClient client = McpClient.builder()
    .transport(transport)
    .build();

// Use MCP tools with your assistant
Assistant assistant = AiServices.builder(Assistant.class)
    .chatModel(chatModel)
    .tools(McpToolProvider.from(client))
    .build();

Agents: Autonomous AI Workflows

The agentic capabilities in LangChain4j have matured significantly. The v1.11.0 release adds streaming support and multimodality for agents.

Simple Agent

interface ResearchAgent {
    @SystemMessage("You are a research assistant. Use the provided tools to find information.")
    String research(String topic);
}

ResearchAgent agent = AiServices.builder(ResearchAgent.class)
    .chatModel(chatModel)
    .tools(webSearchTool, wikipediaTool, calculatorTool)
    .build();

String findings = agent.research("Latest developments in quantum computing");

Streaming Agents (New in v1.11.0)

For long-running agent tasks, streaming provides real-time feedback:

interface StreamingAgent {
    TokenStream research(String topic);
}

StreamingAgent agent = AiServices.builder(StreamingAgent.class)
    .streamingChatModel(streamingChatModel)
    .tools(tools)
    .build();

agent.research("AI safety research")
    .onPartialResponse(partial -> System.out.print(partial))
    .onComplete(response -> System.out.println("\nDone!"))
    .onError(error -> error.printStackTrace())
    .start();

Multi-Agent Workflows

For complex tasks, you can orchestrate multiple specialized agents:

// Define specialized agents
ResearchAgent researcher = AiServices.create(ResearchAgent.class, ...);
WriterAgent writer = AiServices.create(WriterAgent.class, ...);
EditorAgent editor = AiServices.create(EditorAgent.class, ...);

// Orchestrate
String topic = "The future of renewable energy";
String research = researcher.gather(topic);
String draft = writer.write(research);
String finalArticle = editor.polish(draft);

The v1.11.0 release also adds observability—you can listen for tool executions in both AI Services and agents, making debugging and monitoring easier.


Framework Integration

LangChain4j integrates natively with Java’s most popular frameworks.

Spring Boot

@RestController
public class ChatController {
    
    @Autowired
    private Assistant assistant;
    
    @PostMapping("/chat")
    public String chat(@RequestBody String message) {
        return assistant.chat(message);
    }
}

@Configuration
public class AssistantConfig {
    
    @Bean
    public Assistant assistant(ChatModel chatModel, EmbeddingStore<TextSegment> store) {
        return AiServices.builder(Assistant.class)
            .chatModel(chatModel)
            .chatMemory(MessageWindowChatMemory.withMaxMessages(10))
            .contentRetriever(EmbeddingStoreContentRetriever.from(store))
            .build();
    }
}

Quarkus

The quarkus-langchain4j extension provides CDI integration:

@RegisterAiService
public interface Assistant {
    String chat(String message);
}

@Path("/chat")
public class ChatResource {
    
    @Inject
    Assistant assistant;
    
    @POST
    public String chat(String message) {
        return assistant.chat(message);
    }
}

Helidon and Micronaut

Both frameworks have official LangChain4j integrations with similar patterns.


What’s New in v1.11.0

The release from yesterday packs several major features:

Agentic Improvements

  • Streaming support for agents
  • Multimodal agent support (vision + text)
  • Tool execution listeners for observability

Search Enhancements

  • Hybrid search for Elasticsearch
  • Hybrid search for PgVector

Provider Updates

  • Gemini: Google Search tool and URL Context tool support
  • Mistral: Reasoning model support
  • Bedrock: Guardrails support

MCP Enhancements

  • Context injection into header providers
  • Listener support for MCP events
  • Updated to 2025-11-25 MCP specification

New Integrations

  • Apache HttpClient5 support
  • Amazon S3 Vectors embedding store
  • Microsoft Foundry migration (from Azure OpenAI)

Getting Started

Add the core dependency:

<dependency>
    <groupId>dev.langchain4j</groupId>
    <artifactId>langchain4j</artifactId>
    <version>1.11.0</version>
</dependency>

Add your LLM provider (e.g., OpenAI):

<dependency>
    <groupId>dev.langchain4j</groupId>
    <artifactId>langchain4j-open-ai</artifactId>
    <version>1.11.0</version>
</dependency>

For a BOM to manage versions:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>dev.langchain4j</groupId>
            <artifactId>langchain4j-bom</artifactId>
            <version>1.11.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Minimum JDK version: 17


When to Use LangChain4j

Use it when:

  • You’re building LLM features in a Java application
  • You need to integrate with existing Java/Spring/Quarkus systems
  • Enterprise requirements demand JVM-based solutions
  • You want unified APIs across multiple LLM providers
  • You need production-ready RAG with proper document handling

Consider alternatives when:

  • Your team is Python-first and there’s no Java constraint
  • You need cutting-edge experimental features (Python ecosystem often gets them first)
  • You’re building a greenfield project with no JVM requirements

The Ecosystem

LangChain4j isn’t just the core library. The ecosystem includes:


The Bigger Picture

LangChain4j matters because it makes AI accessible to the Java ecosystem. Enterprises don’t rewrite their core systems on a whim. They have decades of Java code, teams of Java developers, and processes built around the JVM.

When the CEO asks “can we add AI to our customer service portal?”—the answer with LangChain4j is yes, and it fits into your existing architecture. You don’t need to spin up a Python microservice, manage a new deployment pipeline, or retrain your team.

The library is mature, actively maintained, and backed by a strong community. With 10,600+ stars and nearly 2,000 forks, it’s not an experiment—it’s the de facto standard for Java LLM development.


If you’re a Java developer looking to build AI-powered applications, LangChain4j is where you start.