Favicon of LangChain4j

LangChain4j

A Java library connects JVM apps to local models through Ollama, with RAG, tool calling and cloud provider support. Open source under Apache 2.0.

Screenshot of LangChain4j website

LangChain4j is a Java library for building chatbots, assistants and AI agents that use local models through Ollama. It runs within JVM applications, while Ollama handles model inference on your hardware using a CPU or GPU. You can also connect to OpenAI or Google Vertex AI, in which case model requests go to the remote provider.

Its shared model and vector store interfaces reduce the provider-specific code developers need to write. That makes it useful for teams comparing local and cloud models or changing their document storage backend. Supported vector stores include Milvus and Pinecone.

The library covers retrieval-augmented generation (RAG), including document ingestion and retrieval, so applications can use relevant material when generating answers. Chat memory, prompt templates and output parsing handle conversation context and model responses. Tool calling lets models invoke Java application functions, and MCP support connects agents to external tools.

Java conventions shape the API: type safety, annotations and dependency injection fit into existing application code. Framework integrations include Spring Boot, Quarkus, Helidon and Micronaut. Developers can use lower-level interfaces or the library's higher-level agent and retrieval patterns.

The license is Apache 2.0. LangChain4j is an independent Java project with its own API and release cycle, separate from Python LangChain.

Similar to LangChain4j