AI4J

v1.0.0Coding Agentsstable

一款JavaSDK用于快速接入AI大模型应用,整合多平台大模型,如OpenAi、智谱Zhipu(ChatGLM)、深度求索DeepSeek、月之暗面Moonshot(Kimi)、腾讯混元Hunyuan、零一万物(01)等等,提供统一的输入输出(对齐OpenAi)消除差异化,优化函数调用(Tool Call),优化RAG调用、支持向量数据库(Pinecone)、内置联网增强,并且支持JDK1.8,为用户提供快速整合AI的能力。

agentchatglmchatgptcoding-agentdeepseek
Share:
410
Stars
0
Downloads
0
Weekly
0/5

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

Multi-platform LLM integration
OpenAI, DeepSeek, Moonshot access
Java AI development
LnYo-Cly

Maintainer

LicenseApache-2.0
Languagejava
Versionv1.0.0
UpdatedMay 21, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx ai4j

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

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
1

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>
2

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);
3

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());
4

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");
5

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.

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.

Quick Config Preview

{ "mcpServers": { "ai4j": { "command": "npx", "args": ["-y", "ai4j"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

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.

33,000+ ServersFree & Open SourceStep-by-Step Guides