Repolode
langchain4j

langchain4j/langchain4j

A Java library giving JVM applications one unified API for LLM providers and vector stores, with tool calling, agents and RAG.

Stars
13,371
Forks
2,667
Open issues
1,035
Last commit
yesterday

What is it?

LangChain4j is an open-source Java library for building applications that use large language models. It provides a single interface over many LLM providers and embedding (vector) stores, so switching between a hosted model or vector database does not require rewriting application code.

The library includes building blocks for common LLM application patterns: prompt templating, chat memory management, tool calling (including MCP support), agents, and retrieval-augmented generation (RAG) with pipelines from data ingestion through retrieval. Each abstraction comes with interfaces and multiple ready-to-use implementations.

LangChain4j is written for Java conventions rather than ported from the Python LangChain project. It uses interfaces, POJOs, annotations and fluent APIs, and offers integrations with Quarkus, Spring Boot, Helidon and Micronaut.

Key features

  • 01Unified API across 20+ LLM providers and 30+ embedding stores.
  • 02Tool calling with MCP support.
  • 03Agents and RAG building blocks.
  • 04Chat memory and prompt templating utilities.
  • 05Integrations with Quarkus, Spring Boot, Helidon and Micronaut.

Use cases

  • Adding LLM chat or completion features to an existing Spring Boot or Quarkus service.
  • Building a RAG question-answering system over internal documents in Java.
  • Giving a Java LLM agent access to custom tools or MCP servers.
  • Swapping between OpenAI, Anthropic or local Ollama models without rewriting code.

Quick start

  1. 1

    Read the getting started guide in the documentation

  2. 2

    Browse the example projects for plain Java, Spring Boot, Quarkus, Helidon, or Micronaut

Things to know

  • The library is under active development, and some features are still being worked on.

In collections

Topics

FAQ

What is langchain4j?
A Java library giving JVM applications one unified API for LLM providers and vector stores, with tool calling, agents and RAG. LangChain4j is an open-source Java library for building applications that use large language models. It provides a single interface over many LLM providers and embedding (vector) stores, so switching between a hosted model or vector database does not require rewriting application code.
Is langchain4j free to use? What license does it have?
langchain4j is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is langchain4j still maintained?
Actively maintained. The last commit to langchain4j was on Nov 6, 2026.
What can I use langchain4j for?
Adding LLM chat or completion features to an existing Spring Boot or Quarkus service. Building a RAG question-answering system over internal documents in Java. Giving a Java LLM agent access to custom tools or MCP servers. Swapping between OpenAI, Anthropic or local Ollama models without rewriting code.
How do I install langchain4j?
Read the getting started guide in the documentation Browse the example projects for plain Java, Spring Boot, Quarkus, Helidon, or Micronaut
Where can I get langchain4j?
The source code and installation instructions are on GitHub: https://github.com/langchain4j/langchain4j

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects