langchain4j /langchain4j
LangChain4j is an idiomatic, open-source Java library for building LLM-powered applications on the JVM. It offers a unified API over popular LLM providers and vector stores, and makes implementing tool calling (including MCP support), agents and RAG easy. It integrates seamlessly with enterprise Java frameworks like Quarkus and Spring Boot.
★ 13,454⑂ 2,716👁 119⑃ 4,054● 2,814▤ 102
+3
Daily
+27
Weekly
13,454
stars
2,716
forks
119
watchers
4,054
prs
2,814
issues
102
releases
README
LangChain4j: idiomatic, open-source Java library for building LLM-powered applications on the JVM Introduction Welcome! The goal of LangChain4j is to simplify integrating LLMs into Java applications. Here's how: 1. Unified APIs: LLM providers (like OpenAI or Google Vertex AI) and embedding (vector) stores (such as Pinecone or Milvus) use proprietary APIs. LangChain4j offers a unified API to avoid the need for learning and implementing specific APIs for each of them. To experiment with different LLMs or embedding stores, you can easily switch between them without the need to rewrite your code. LangChain4j currently supports 20+ popular LLM providers and 30+ embedding stores. 2. Comprehensive Toolbox: Since early 2023, the community has been building numerous LLM-powered applications, identifying common abstractions, patterns, and techniques. LangChain4j has refined these into practical code. Our toolbox includes tools ranging from low-level prompt templating, chat memory management, and function calling to high-level patterns like Agents and RAG. For each abstraction, we provide an interface along with multiple ready-to-use implementations based on common techniques. Whether you're building a chatbot or developing a RAG with a complete pipeline from data ingestion to retrieval, LangChain4j offers a wide variety of options. 3. Numerous Examples: These examples showcase how to begin creating various LLM-powered applications, providing inspiration and enabling you to start building quickly. LangChain4j began development in early 2023 amid the ChatGPT hype. We noticed a lack of Java counterparts to the numerous Python and JavaScript LLM libraries and frameworks, and we had to fix that! Despite the name, LangChain4j is not a Java port of LangChain (Python) — it is built for Java, not ported to it. It is an idiomatic Java library designed from the ground up around Java conventions: type safety, POJOs, annotations, interfaces, dependency injection, fluent APIs, and first-class integrations with Quarkus, Spring Boot, Helidon, and Micronaut. Its API, internals, and release cycle are independent of the Python LangChain project. We actively monitor community developments, aiming to quickly incorporate new techniques and integrations, ensuring you stay up-to-date. The library is under active development. While some features are still being worked on, the core functionality is in place, allowing you to start building LLM-powered apps now! Documentation Documentation can be found here. The documentation chatbot (experimental) can be found here. Getting Started Getting started guide can be found here. Code Examples Please see examples of how LangChain4j can be used in langchain4j-examples repo: - Examples in plain Java - Examples with Quarkus (uses quarkus-langchain4j dependency) - Example with Spring Boot - Examples with Helidon (uses io.helidon.integrations.langchain4j dependency) - Examples
Top issues
#2328Langfuse: implement tracing47 comments · 2024-12-23#2157[BUG] image content seems totally broken on langchain4j<=0.36.1 for anthropic24 comments · 2024-11-21#4918[BUG] SpringRestClient silently uses Apache HttpClient 5, causing streaming tokens to arrive in bursts instead of real-time19 comments · 2026-04-14#3248[FEATURE] LangChain4j Common Guardrails Library19 comments · 2025-06-23#1848[BUG] JsonEOFException : Unexpected end-of-input | AzureOpenAiStreamingChatModel18 comments · 2024-09-27#4770Setup Checkstyle for Static Code Analysis and Maintain consistency over the codebase.17 comments · 2026-03-24#4559[BUG] [FEATURE] Add halfvec and sparsevec support to PGVectorEmbeddingStore17 comments · 2026-02-09#4316[BUG] When using OutputGuardrails the return will not output like streaming17 comments · 2025-12-31
Discussions
#7270An info-only MCP tool view in LangChain4j: inspect an API before exposing its execution tool0 comments · 2026-11-24#7223Testing LangChain4j text streaming and auth errors against a local coding agent0 comments · 2026-11-21#7030Output guardrails for tool results (indirect prompt injection)5 comments · 2026-11-08#6640Non-intrusive tool-call tracing for LangChain4j agents — live SSE traces with zero instrumentation in the tools0 comments · 2026-10-10#6544Dark Data Forensics Vault — Zero-Budget, 100% Air-Gapped Multi-AI Java 21 Stack with In-Process ONNX & Ollama0 comments · 2026-09-29#6514Opt-in CachingEmbeddingModel decorator0 comments · 2026-09-26#6513RAG evaluators (answer relevancy, faithfulness) as a reusable API0 comments · 2026-09-26#6479Showcasing langchain4j-security-extension: Deterministic Tool Interception, Hard Aborts, and Multi-Tenant RAG0 comments · 2026-09-21
Latest release
1.24.1 and 1.24.1-beta34 1.24.1 2026-11-27What's Changed Avoid deep regex recursion on long inputs in the prompt injection guardrail and the Azure ACA sessions tool (backport of 7245 to 1.24.x) by @dliubarskyi Pass media URLs to the provider instead of downloading them (backport of 7267 to 1.24.x) by @dliubarskyi Limit the text extracted by the Apache Tika and PDFBox document parsers (backport of 7271 to 1.24.x) by @dliubarskyi Apache PDFBox document parser: a page with more characters than maxCharacters fails early (backport of 7300 to 1.24.x) by @dliubarskyi Limit the size, nesting and parse time of SQL metadata filters (b