Chat and Language Models
The low-level ChatModel API: send messages to an LLM, read the response, and use text, images, audio, video and PDF as input.
Chat Memory
Keep the context of a conversation with ChatMemory: message window and token window eviction, and persistence in a ChatMemoryStore.
Model Parameters
Depending on the model and provider you choose, you can adjust numerous parameters that will define:
Response Streaming
Stream LLM responses token by token with StreamingChatModel and StreamingChatResponseHandler, using the low-level API.
AI Services
AI Services let you declare a plain Java interface and have LangChain4j implement it, with chat memory, tools, RAG and structured outputs.
Agents and Agentic AI
Build agentic AI applications in Java with the langchain4j-agentic module: workflows, supervisor agents, custom patterns, A2A and MCP.
Tools (Function Calling)
Let the LLM call your Java methods: declare tools with @Tool or programmatically, use them in AI Services, and control how tool calls run.
RAG (Retrieval-Augmented Generation)
Retrieval-Augmented Generation in LangChain4j: load, split, embed and store documents, then retrieve relevant content to ground LLM answers.
Structured Outputs
Get structured data from an LLM as Java objects using JSON schema, JSON mode or prompting, with ChatModel or with AI Services.
Guardrails
Check and fix what goes into and comes out of an LLM with input and output guardrails in AI Services: rewrite, fail, retry or reprompt.
Classification
Overview
Embedding (Vector) Stores
Documentation on embedding stores can be found here.
Building a Java MCP server
LangChain4j provides an MCP client (langchain4j-mcp) for connecting to MCP servers.
Image Models
More info coming soon
Micronaut Integration
Micronaut provides a Micronaut module for LangChain4j.
Quarkus Integration
Use LangChain4j in Quarkus with the Quarkus LangChain4j extension: declarative AI Services, configuration properties, native images and Dev UI.
Spring Boot Integration
Use LangChain4j with Spring Boot 3 and 4: starters for models and stores, declarative AI Services with @AiService, observability and testing.
Helidon Integration
Helidon provides a LangChain4j integration module that simplifies building AI-driven applications while leveraging Helidonβs programming model and style.
Kotlin Support
Kotlin is a statically-typed language targeting the JVM (and other platforms), enabling concise and elegant code with seamless interoperability with Java libraries.
Logging
LangChain4j uses SLF4J for logging,
JSON Codec
LangChain4j ships an internal JSON serializer (defaults to Jackson) that is used by "tools" and "structured output" functionalities.
Observability
Observe LLM applications built with LangChain4j: AI Service events, model and RAG listeners, Micrometer metrics and the Observation API.
Skills
The Skills API is experimental. APIs and behavior may still change in future releases.
Customizable HTTP Client
Some LangChain4j modules (including OpenAI, Ollama and the MCP Streamable HTTP transport) support
Testing
Test LangChain4j applications: unit tests with mock models, checks on what an AI Service did, judging answers with a model, and real-model tests.
Evaluation
Evaluation measures how good the answers of your application are: how often they are correct, based on the right
Payara Micro Integration
LangChain4j can be seamlessly integrated into a Payara Micro application, leveraging the standard features of Jakarta EE and MicroProfile for dependency injection and configuration.
Non-blocking and Reactive
Asynchronous and reactive support is experimental. The asynchronous and reactive APIs on this page are
Using Jackson 3
LangChain4j reads and writes JSON in a lot of places: the requests and responses it exchanges with
Decision Services
Decision Services are experimental and may change in future releases.
Decision Models
The DecisionModel API is experimental and may change in future releases.
Model Routing
Model routing is experimental and may change in future releases.
Model Context Protocol (MCP)
Connect to Model Context Protocol (MCP) servers over Streamable HTTP or stdio and use their tools, resources and prompts in LangChain4j.