langchain4j-spring
Spring Boot starters for LangChain4j
Spring Boot starters for LangChain4j, the Java library for building applications and agents with large language models (LLMs). The integration starters configure LangChain4j models and stores from your application.properties. The langchain4j starter lets you declare AI Services as Spring beans with @AiService, wired with your model, chat memory, tool and content retriever beans. Every starter comes in two variants. Add one of these suffixes to the prefix in the table below:
Summary extracted from the README.
LangChain4j for Spring Boot
Spring Boot starters for LangChain4j, the Java library for building applications and agents with large language models (LLMs).
The integration starters configure LangChain4j models and stores from your application.properties.
The langchain4j starter lets you declare AI Services as Spring beans with @AiService, wired with your model,
chat memory, tool and content retriever beans.
Spring Boot versions
Every starter comes in two variants. Add one of these suffixes to the prefix in the table below:
-spring-boot4-starterfor Spring Boot 4 (4.0 or newer)-spring-boot-starterfor Spring Boot 3 (3.5 or newer)
Both variants need Java 17 or newer, and are released together with the same version.
Starters
| Prefix | What it provides |
|---|---|
langchain4j |
Declarative AI Services (@AiService); add it next to an integration starter |
langchain4j-anthropic |
Anthropic chat models |
langchain4j-azure-open-ai |
Azure OpenAI models |
langchain4j-google-ai-gemini |
Google AI Gemini models |
langchain4j-mistral-ai |
Mistral AI models |
langchain4j-ollama |
Ollama models |
langchain4j-open-ai |
OpenAI models (properties langchain4j.open-ai.*) |
langchain4j-open-ai-official |
OpenAI models, using the official OpenAI Java SDK (properties langchain4j.open-ai-official.*) |
langchain4j-vertex-ai-gemini |
Google Vertex AI Gemini models |
langchain4j-voyage-ai |
Voyage AI embedding and scoring models |
langchain4j-azure-ai-search |
Azure AI Search embedding store and content retriever |
langchain4j-azure-cosmos-mongo-vcore |
Azure Cosmos DB for MongoDB vCore embedding store (deprecated, use langchain4j-azure-documentdb) |
langchain4j-azure-cosmos-nosql |
Azure Cosmos DB for NoSQL embedding store |
langchain4j-azure-documentdb |
Azure DocumentDB embedding store |
langchain4j-elasticsearch |
Elasticsearch embedding store |
langchain4j-milvus |
Milvus embedding store |
For example, the starter for OpenAI on Spring Boot 4 is dev.langchain4j:langchain4j-open-ai-spring-boot4-starter.
All starters have the group ID dev.langchain4j, and their versions end with -beta and a number.
The documentation shows the current versions.
To leave out the versions, import dev.langchain4j:langchain4j-bom in your <dependencyManagement>: it manages
all starters.
This repository also contains:
langchain4j-http-client-spring-restclient(Spring Boot 3) andlangchain4j-http-client-spring-boot4-restclient(Spring Boot 4): an HTTP client for LangChain4j based on Spring'sRestClient, andWebClientfor non-blocking calls. The OpenAI, Mistral AI and Ollama starters already use it.langchain4j-reactor: lets AI Service methods return Project Reactor types (Flux,Mono).
Starters for community integrations are in the langchain4j-community repository.
Get help and report issues
Ask on Discord or in GitHub Discussions. Please submit issues and feature requests here.