AI4J
一款JavaSDK用于快速接入AI大模型应用,整合多平台大模型,如OpenAi、智谱Zhipu(ChatGLM)、深度求索DeepSeek、月之暗面Moonshot(Kimi)、腾讯混元Hunyuan、零一万物(01)等等,提供统一的输入输出(对齐OpenAi)消除差异化,优化函数调用(Tool Call),优化RAG调用、支持向量数据库(Pinecone)、内置联网增强,并且支持JDK1.8,为用户提供快速整合AI的能力。
What is AI4J?
AI4J is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to 一款javasdk用于快速接入ai大模型应用,整合多平台大模型,如openai、智谱zhipu(chatglm)、深度求索deepseek、月之暗面moonshot(kimi)、腾讯混元hunyuan、零一万物(01)等等,提供统一的输入输出(对齐openai)消除差异化,优化函数调用(tool call),优化rag调用、支持向量数据库(pinecone)、内置联网增强,并且支持jdk1.8,为...
一款JavaSDK用于快速接入AI大模型应用,整合多平台大模型,如OpenAi、智谱Zhipu(ChatGLM)、深度求索DeepSeek、月之暗面Moonshot(Kimi)、腾讯混元Hunyuan、零一万物(01)等等,提供统一的输入输出(对齐OpenAi)消除差异化,优化函数调用(Tool Call),优化RAG调用、支持向量数据库(Pinecone)、内置联网增强,并且支持JDK1.8,为用户提供快速整合AI的能力。
This server falls under the Coding Agents category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- 一款JavaSDK用于快速接入AI大模型应用,整合多平台大模型,如OpenAi、智谱Zhipu(ChatGLM)、深度求
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx ai4jConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use AI4J
AI4J is a comprehensive Java SDK for AI application development that supports JDK 8+ and provides a unified interface to 10+ LLM providers including OpenAI, DeepSeek, Zhipu (ChatGLM), Moonshot (Kimi), Tencent Hunyuan, Ollama, and MiniMax. Beyond basic chat completions, it delivers a full agentic runtime with MCP support, RAG pipelines, a unified VectorStore abstraction (Pinecone, Qdrant, pgvector, Milvus), ChatMemory, a Coding Agent CLI/TUI, and AgentFlow integration with Dify, Coze, and n8n. Java teams use it to add production-grade AI capabilities to existing Spring Boot or plain Java applications without migrating to Java 17+.
Prerequisites
- JDK 8 or later (JDK 11+ recommended for best compatibility)
- Maven or Gradle build tool
- API keys for your chosen LLM providers (e.g., OPENAI_API_KEY, DEEPSEEK_API_KEY)
- Optional: Ollama running locally for offline inference
Add the ai4j dependency to your project
Add the core ai4j artifact from Maven Central to your pom.xml or build.gradle. Check the latest version at https://search.maven.org/artifact/io.github.lnyo-cly/ai4j.
<!-- Maven pom.xml -->
<dependency>
<groupId>io.github.lnyo-cly</groupId>
<artifactId>ai4j</artifactId>
<version>LATEST</version>
</dependency>Configure your LLM provider
Create an AI client instance pointing at your chosen provider. The example below uses OpenAI; swap the provider enum and API key for DeepSeek, Moonshot, Ollama, etc.
// Java example
AiConfig config = AiConfig.builder()
.provider(Provider.OPENAI)
.apiKey(System.getenv("OPENAI_API_KEY"))
.build();
AiClient client = new AiClient(config);Send a chat completion request
Use the unified ChatCompletions API. The same code works across all supported providers by changing only the provider enum.
ChatRequest request = ChatRequest.builder()
.model("gpt-4o")
.message(Role.USER, "Explain MCP in one paragraph")
.build();
ChatResponse response = client.chatCompletions(request);
System.out.println(response.getContent());Enable MCP tool support
AI4J includes a built-in MCP gateway. Register an MCP server and the SDK will route tool calls through it automatically during agent inference.
// Register an MCP server endpoint
client.addMcpServer("my-tools", "http://localhost:3000/mcp");Add the Spring Boot starter for Spring projects
For Spring Boot applications, add the starter artifact to get auto-configuration of AI clients via application.properties.
<dependency>
<groupId>io.github.lnyo-cly</groupId>
<artifactId>ai4j-spring-boot-starter</artifactId>
<version>LATEST</version>
</dependency>AI4J Examples
Client configuration
Claude Desktop MCP configuration for the ai4j server using npx.
{
"mcpServers": {
"ai4j": {
"command": "npx",
"args": ["ai4j"],
"env": {
"OPENAI_API_KEY": "sk-..."
}
}
}
}Prompts to try
Prompts for exploring AI4J capabilities through an AI assistant.
- "Show me how to set up a RAG pipeline with Qdrant using ai4j"
- "Write a Java example that calls DeepSeek with streaming output using ai4j"
- "How do I configure ChatMemory for multi-turn conversations in ai4j?"
- "Create a Spring Boot service that exposes an MCP-compatible endpoint using ai4j"Troubleshooting AI4J
ClassNotFoundException or dependency conflicts with JDK 8
AI4J targets JDK 8 but some optional modules require newer APIs. Ensure you import only the modules you need (ai4j core vs ai4j-agent vs ai4j-spring-boot-starter) and check the Maven BOM (ai4j-bom) for version alignment.
API calls return 401 Unauthorized
Verify the API key is set correctly for your provider. For OpenAI-compatible providers like DeepSeek, confirm the base URL is also set in the AiConfig builder. Environment variable names are provider-specific — check the documentation for DEEPSEEK_API_KEY vs OPENAI_API_KEY.
MCP tool calls time out during agent execution
Check that your MCP server is running and reachable at the registered URL. Increase the client timeout in AiConfig if your tools perform long operations. Ensure the MCP endpoint returns valid JSON-RPC 2.0 responses.
Frequently Asked Questions about AI4J
What is AI4J?
AI4J is a Model Context Protocol (MCP) server that 一款javasdk用于快速接入ai大模型应用,整合多平台大模型,如openai、智谱zhipu(chatglm)、深度求索deepseek、月之暗面moonshot(kimi)、腾讯混元hunyuan、零一万物(01)等等,提供统一的输入输出(对齐openai)消除差异化,优化函数调用(tool call),优化rag调用、支持向量数据库(pinecone)、内置联网增强,并且支持jdk1.8,为用户提供快速整合ai的能力。 It connects AI assistants to external tools and data sources through a standardized interface.
How do I install AI4J?
Follow the installation instructions on the AI4J GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with AI4J?
AI4J works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is AI4J free to use?
Yes, AI4J is open source and available under the Apache-2.0 license. You can use it freely in both personal and commercial projects.
AI4J Alternatives — Similar Coding Agents Servers
Looking for alternatives to AI4J? Here are other popular coding agents servers you can use with Claude, Cursor, and VS Code.
Dify
★ 142.2kProduction-ready platform for agentic workflow development.
Ruflo
★ 54.0k🌊 The leading agent orchestration platform for Claude. Deploy intelligent multi-agent swarms, coordinate autonomous workflows, and build conversational AI systems. Features enterprise-grade architecture, self-learning swarm intelligence, RAG integrat
Goose
★ 45.7kan open source, extensible AI agent that goes beyond code suggestions - install, execute, edit, and test with any LLM
Antigravity Awesome Skills
★ 38.3kInstallable GitHub library of 1,400+ agentic skills for Claude Code, Cursor, Codex CLI, Gemini CLI, Antigravity, and more. Includes installer CLI, bundles, workflows, and official/community skill collections.
AgentScope
★ 25.5kBuild and run agents you can see, understand and trust.
Serena
★ 24.5kA coding agent toolkit that provides IDE-like semantic code retrieval and editing tools, enabling LLMs to efficiently navigate and modify codebases using symbol-level operations instead of basic file reading and string replacements.
Browse More Coding Agents MCP Servers
Explore all coding agents servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up AI4J in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use AI4J?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.