
Langchain4j Spring Boot Integration
Wire LangChain4j chat, embedding, and streaming models into Spring Boot via application.yml for OpenAI, Azure OpenAI, and Anthropic.
Overview
LangChain4j Spring Boot Integration is an agent skill for the Build phase that documents property-based LangChain4j configuration for OpenAI, Azure OpenAI, and Anthropic in Spring Boot applications.
Install
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill langchain4j-spring-boot-integrationWhat is this skill?
- Property blocks for langchain4j.open-ai, azure-open-ai, and anthropic chat and embedding models
- Streaming chat model configuration alongside non-streaming chat and embeddings
- Timeouts, retries, max-tokens, temperature, and request/response logging toggles
- Azure deployment-name and service-version fields separate from OpenAI model-name keys
- Environment-variable placeholders for API keys and organization IDs
Adoption & trust: 1.2k installs on skills.sh; 271 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You have a Spring Boot service but lack a consistent YAML reference for multiple LLM providers, embeddings, streaming, and resilient HTTP settings.
Who is it for?
Java solo builders integrating LangChain4j 0.x-style Spring Boot autoconfig for multi-provider LLM backends.
Skip if: Non-Spring stacks, pure frontend agents, or teams that only need Python LangChain—not JVM.
When should I use this skill?
Adding or tuning LangChain4j providers in a Spring Boot app via application.yml or advanced setup patterns.
What do I get? / Deliverables
You get ready-to-adapt application.yml sections and env-var patterns so chat, embedding, and streaming beans can be enabled in your build without guessing property keys.
- application.yml fragments for chat, embedding, and streaming models
- Documented env-var contract for keys and organization IDs
Recommended Skills
Journey fit
LLM provider wiring is core product build work when you ship a Java backend that calls models—not a launch or growth task. Integrations subphase is the canonical shelf for third-party AI APIs and Spring property-based client setup.
How it compares
Configuration reference skill for Spring property wiring—not an MCP server or a deployed model host.
Common Questions / FAQ
Who is langchain4j-spring-boot-integration for?
Solo and indie developers building Spring Boot APIs or agents who want LangChain4j provider blocks without reading every starter README.
When should I use langchain4j-spring-boot-integration?
During Build integrations when you add OpenAI, Azure OpenAI, or Anthropic models, embeddings, or streaming to an existing or new Spring Boot project.
Is langchain4j-spring-boot-integration safe to install?
Check the Security Audits panel on this Prism page; never commit real API keys—use env placeholders as shown in the skill examples.
SKILL.md
READMESKILL.md - Langchain4j Spring Boot Integration
# LangChain4j Spring Boot Integration - Configuration Guide Detailed configuration options and advanced setup patterns for LangChain4j with Spring Boot. ## Property-Based Configuration ### Core Configuration Properties **application.yml** ```yaml langchain4j: # OpenAI Configuration open-ai: chat-model: api-key: ${OPENAI_API_KEY} model-name: gpt-4o-mini temperature: 0.7 max-tokens: 1000 log-requests: true log-responses: true timeout: PT60S max-retries: 3 organization: ${OPENAI_ORGANIZATION:} embedding-model: api-key: ${OPENAI_API_KEY} model-name: text-embedding-3-small dimensions: 1536 timeout: PT60S streaming-chat-model: api-key: ${OPENAI_API_KEY} model-name: gpt-4o-mini temperature: 0.7 max-tokens: 2000 # Azure OpenAI Configuration azure-open-ai: chat-model: endpoint: ${AZURE_OPENAI_ENDPOINT} api-key: ${AZURE_OPENAI_KEY} deployment-name: gpt-4o service-version: 2024-02-15-preview temperature: 0.7 max-tokens: 1000 log-requests-and-responses: true embedding-model: endpoint: ${AZURE_OPENAI_ENDPOINT} api-key: ${AZURE_OPENAI_KEY} deployment-name: text-embedding-3-small dimensions: 1536 # Anthropic Configuration anthropic: chat-model: api-key: ${ANTHROPIC_API_KEY} model-name: claude-3-5-sonnet-20241022 max-tokens: 4000 temperature: 0.7 streaming-chat-model: api-key: ${ANTHROPIC_API_KEY} model-name: claude-3-5-sonnet-20241022 # Ollama Configuration ollama: chat-model: base-url: http://localhost:11434 model-name: llama3.1 temperature: 0.8 timeout: PT60S # Memory Configuration memory: store-type: in-memory # in-memory, postgresql, mysql, mongodb max-messages: 20 window-size: 10 # Vector Store Configuration vector-store: type: in-memory # in-memory, pinecone, weaviate, qdrant, postgresql pinecone: api-key: ${PINECONE_API_KEY} index-name: my-index namespace: production qdrant: host: localhost port: 6333 collection-name: documents weaviate: host: localhost port: 8080 collection-name: Documents postgresql: table: document_embeddings dimension: 1536 ``` ### Spring Profiles Configuration **application-dev.yml** ```yaml langchain4j: open-ai: chat-model: api-key: ${OPENAI_API_KEY_DEV} model-name: gpt-4o-mini temperature: 0.8 # Higher temperature for experimentation log-requests: true log-responses: true vector-store: type: in-memory ``` **application-prod.yml** ```yaml langchain4j: open-ai: chat-model: api-key: ${OPENAI_API_KEY_PROD} model-name: gpt-4o temperature: 0.3 # Lower temperature for consistency log-requests: false log-responses: false vector-store: type: pinecone pinecone: api-key: ${PINECONE_API_KEY_PROD} index-name: production-knowledge-base ``` ## Manual Bean Configuration ### Advanced Chat Model Configuration ```java @Configuration @Profile("custom-openai") public class CustomOpenAiConfiguration { @Bean @Primary public ChatModel customOpenAiChatModel( @Value("${custom.openai.api.key}") String apiKey, @Value("${custom.openai.model}") String model, @Value("${custom.openai.temperature}") Double temperature) { OpenAiChatModelBuilder builder = OpenAiChatModel.builder() .apiKey(apiKey) .modelName(model) .temperature(temperature); if (Boolean.TRUE.equals(env.getProperty("custom.openai.log-requests", Boolean.class))) { builder.logRequests(true); } if (Boolean.TRUE.equals(env.getProperty("custom.openai.log-responses", Boolean.class))) { builder.logResponses(true); } retur