Favicon of LangChain4j

LangChain4j

Open-source Java library for LLM apps on the JVM, with Ollama support, tool calling, RAG, and integrations for Spring Boot and Quarkus.

Screenshot of LangChain4j website

LangChain4j is an Apache 2.0 open-source Java library for developers building chatbots, assistants and AI agents in JVM applications. It connects application code to local LLM backends such as Ollama as well as cloud providers such as OpenAI and Google Vertex AI. Where model requests go depends on the backend you choose.

Its shared API covers both models and vector stores, so developers can change providers without rewriting each provider integration. Supported stores include Milvus and Pinecone. For applications that answer questions using their own documents, its retrieval-augmented generation (RAG) capabilities cover data ingestion through retrieval.

Tool calling lets models invoke Java code, with MCP support for connecting tools. The library also handles prompt templates, conversation memory and parsing model output. These building blocks suit teams that need an assistant to work with application functions or retrieved information, beyond generating a text response.

The design follows Java conventions, including type safety, POJOs, annotations and dependency injection. Framework integrations include Quarkus, Spring Boot, Helidon and Micronaut. Despite its name, LangChain4j is an independent Java project with its own API and release cycle, rather than a port of Python LangChain.

Similar to LangChain4j