ai4j — Java AI Agentic SDK

A unified LLM SDK for JDK 8+ covering Tool Calling, MCP, A2A, RAG, Agent Runtime, and a built-in Coding Agent.

Source repo
LnYo-Cly/ai4j
Stars
★ 436
Last updated
11d ago
License
Apache-2.0
Primary language
Java

At a glance

How it runs
Library / SDKCLIFramework
Works with
Universal · cross-platformOpenAI API · Claude API
Cost
Free software; you pay for model usage
Setup effort
Low · running in minutes
You'll need
JDK 8+Shell / CLINetwork accessMCP Server
Typical use
Teams with legacy Java 8 applications that want to call multiple LLM providers (OpenAI, DeepSeek, DashScope, etc.) through one unified API without rewriting integration code.
Not a fit if
  • Teams on Python/Node stacks that cannot adopt a Java SDK
  • Teams unwilling to obtain and pay for separate platform API keys

What does this agent do, and when should you use it?

ai4j (GitHub: LnYo-Cly/ai4j) is a Java AI Agentic SDK targeting JDK 8+, published on Maven Central as io.github.lnyo-cly:ai4j (version 2.4.2) under the Apache-2.0 license. It unifies access to many model platforms through a PlatformType abstraction — OpenAI/compatible APIs, Anthropic, DashScope, Doubao, DeepSeek, Moonshot, Zhipu, Hunyuan, Lingyi, Ollama, MiniMax, Baichuan, and more — with the README demonstrating calls via AiService, IChatService, and ChatCompletion. Beyond chat, it ships Tool Calling, MCP, the A2A protocol, RAG (Rerank via Jina/Ollama/Doubao and VectorStore via Pinecone/Qdrant/pgvector/Milvus/Redis), AgentFlow integration (Dify/Coze/n8n), and an Agent Runtime. The project also includes a built-in Coding Agent available as a CLI, TUI, or ACP interface. Switching providers requires only changing PlatformType and the corresponding Config, making it a fit for teams building AI features on Java 8 or newer runtimes.

After adding the ai4j dependency, developers configure platform credentials via Configuration (e.g., OpenAiConfig.setApiKey), obtain a service with AiService.getChatService(PlatformType.OPENAI), build a ChatCompletion request with a model (e.g., gpt-4o-mini) and ChatMessage, call chatCompletion(request), and read the result from ChatCompletionResponse. Switching to DashScope, DeepSeek, Ollama, or others means swapping PlatformType and Config only. The SDK additionally provides Tool Calling (function calling), MCP integration, A2A protocol support, a RAG pipeline (Rerank via Jina/Ollama/Doubao; vector stores Pinecone/Qdrant/pgvector/Milvus/Redis), AgentFlow connections (Dify/Coze/n8n), an Agent Runtime, and a built-in Coding Agent exposed through CLI / TUI / ACP.

  1. Teams with legacy Java 8 applications that want to call multiple LLM providers (OpenAI, DeepSeek, DashScope, etc.) through one unified API without rewriting integration code.
  2. Developers building retrieval-augmented Q&A using the built-in RAG support with Pinecone, Qdrant, pgvector, Milvus, or Redis as the vector store.
  3. Backend engineers who need models to invoke local functions (Tool Calling) or reach external tool ecosystems via MCP.
  4. Architects implementing multi-agent interoperability via the A2A protocol or connecting to AgentFlow platforms like Dify, Coze, or n8n.
  5. Terminal-oriented developers who can immediately use the built-in Coding Agent through its CLI, TUI, or ACP interfaces.

How do you install or deploy this agent?

Gradle: implementation 'io.github.lnyo-cly:ai4j:2.4.2'; Maven: <dependency><groupId>io.github.lnyo-cly</groupId><artifactId>ai4j</artifactId><version>2.4.2</version></dependency>. Requires JDK 8 or later. Documentation: https://lnyo-cly.github.io/ai4j/

How do you use this agent?

1) Set the OPENAI_API_KEY environment variable (or the key for your chosen platform); 2) create an OpenAiConfig with setApiKey and place it in a Configuration; 3) get an IChatService via new AiService(configuration).getChatService(PlatformType.OPENAI); 4) build a request with ChatCompletion.builder().model("gpt-4o-mini").message(ChatMessage.withUser("...")) .build(); 5) call chatCompletion(request) and read the text from response.getChoices(). A complete runnable example is provided in the README.

What are this agent's strengths and limitations?

Pros
  • Provider switching requires only swapping PlatformType and Config, reducing vendor lock-in across a dozen or more model platforms.
  • Broad capability surface: Tool Calling, MCP, A2A, RAG, Rerank, vector stores, and AgentFlow integration are all bundled in one SDK.
  • Runs on JDK 8+, a rarity among AI SDKs, making it suitable for legacy Java runtimes that cannot be upgraded.
  • Includes a built-in Coding Agent (CLI/TUI/ACP) so you get a terminal coding assistant out of the box.
Limitations
  • Teams outside the Java ecosystem (e.g., Python/Node stacks) cannot use it directly; adopting it means rewriting integrations in Java.
  • RAG, vector store, and AgentFlow features depend on external services (Pinecone, Milvus, Redis, Dify, etc.), adding deployment and operational overhead.
  • Platform API keys must be obtained and paid for separately; model costs depend on the providers you connect.
  • Beyond the README and docs site, production case studies or benchmarks are not evidenced in the source; verify fit before adoption.

How does this agent compare with similar options?

The README does not name competitors directly, but its positioning (unified Java 8+ LLM access with agentic capabilities) overlaps with Java AI frameworks like LangChain4j and Spring AI; teams already on Spring Boot can weigh ai4j's spring-boot-related integrations accordingly.

Key facts side by side with the most closely related agents.

Agent Source review Form / cost Stars Updated Language Full support on
ai4j — Java AI Agentic SDK This agent 52 · Major gaps Library / SDKFree + model costs ★ 436 11d ago Java OpenAI API · Claude API
ReachAI Enterprise Agent Platform 60 · Some gaps Self-hosted serviceFree + model costs ★ 946 1d ago Java OpenAI API
RAGLight 63 · Some gaps CLIFree + model costs ★ 673 8d ago Python OpenAI API
Agentica 63 · Some gaps CLIFree + model costs ★ 357 today Python OpenAI API · Claude API

How does FollowAgents rate this agent?

FollowAgents source review · FARS-2.1
Major gaps
52/ 100 5-point scale 2.6 / 5
This review covers the source as of Sep 09, 2026. The project has shipped 3 stable release(s) since, which have not been re-reviewed. The score and verdict describe the reviewed version only. Recent releases ↓
Trust 11/29
Reliability 6/14
Adaptability 9/18
Convention 13/18
Effectiveness 9/13
Verifiability 4/8
Why each dimension lost points
Trust11 / 29 · 1.9/5

Evidence: SECURITY.md explicitly warns against hard-coded keys, asks for input validation, and requires reviewing CLI extension plugins before --enable; README example reads the API key from an env var; attribution is clear (Maven Central coordinates, docs link, full Apache-2.0 text). Deductions: no mechanistic least-privilege evidence (sandbox appears only in test YAMLs with no documented permission model); no documented user-confirmation gate for tool calls; data-flow transparency is only generic advice; no dependency list or vulnerability-scanning process in evidence; external effects of the Coding Agent on the local workspace are only warned about, not guarded; no rollback/recovery documentation at all.

Reliability6 / 14 · 2.1/5

Evidence: invalid-* test resources show negative tests for blueprint validation (compact ratio, sandbox without provider, maxTurns=0), supporting self-consistency; Maven badge matches version 2.4.2. Deductions: no documentation of retry/timeout/fallback for provider availability; no direct evidence of error-message quality or diagnosability.

Adaptability9 / 18 · 2.5/5

Evidence: README clearly targets Java developers on JDK 8+, lists 13+ platforms plus Rerank, AgentFlow, VectorStore, and CLI/TUI/ACP; the platform-swap example shows good environment fit. Deductions: capability boundaries are not stated (which platforms support MCP/RAG, etc.); trigger precision (tool selection/routing behavior) undocumented; feature-map content not present in the evidence.

Convention13 / 18 · 3.6/5

Evidence: install notes are complete (Gradle/Maven, first-request example, docs site, CHANGELOG/CONTRIBUTING links); LICENSE is the full Apache-2.0 text (full marks); information architecture is CI-enforced (docs-build.yml guards directory structure, orphan dirs, i18n shadowing); maintenance responsibility is defined by SECURITY.md support windows and response timelines. Deductions: no dedicated known-limitations document; naming stability inferred from the io.github.lnyocly package without a compatibility commitment; the CHANGELOG itself is not in the evidence.

Effectiveness9 / 13 · 3.5/5

Evidence: a complete, copyable 30-second first-request example with sample output; unified multi-platform abstraction lowers integration cost. Deductions: no executed run verifies the claims (static review); marginal value over competing Java SDKs is asserted without comparison evidence.

Verifiability4 / 8 · 2.5/5

Evidence: README claims carry traceable links (docs site, feature map, CHANGELOG); facts (JDK 8+, Apache-2.0, Maven coordinates) are cleanly separated from inference. Deductions: limited cross-source corroboration — functional claims (13+ platforms, MCP, RAG) cannot be verified against code or tests within this evidence, and the sample output is orchestrated, not executed.

Risks and how to mitigate them
  • Not found in source: rollback or recovery pathBack up first, or work on a git branch or snapshot, so its changes can be undone.
  • Publisher identity is unverified and this is a low-confidence static review; no code was executed and functional claims (multi-platform, MCP, RAG, Coding Agent) are unverified.
  • The Coding Agent CLI executes tools against the local workspace; review extension plugins before enabling with --enable, and run in a sandbox or restricted environment.
  • Never hard-code API keys in source or committed configuration; always inject via environment variables or a secrets manager.
  • Validate and sanitize user input before wiring it into Tool Call or MCP payloads — the SDK provides reminders, not enforced guards.
  • Audit the dependency manifest and run your own supply-chain checks (SBOM/vulnerability scanning); no dependency-security process appears in the evidence.
  • Only the two most recent minor releases (2.4.x/2.3.x) receive security fixes; upgrade older deployments.
Evidence confidence: Low Reviewed Sep 09, 2026 Reviewed revision 20d111d8bd8e New commits since this review; the score may not cover them
See the full review method →

Recent releases

Latest entries from the project's GitHub Releases. Notes are quoted from upstream as written, not rewritten or tested by FollowAgents.

  1. v2.8.1
    Release notes excerpt
    ai4j 2.8.1 RAG capability expansion, new vector stores, starter wiring fixes, harness presets — plus the CLI fat-jar move to GitHub Releases. Highlights - New vector stores: ElasticsearchVectorStore (ES _bulk/knn/_delete_by_query, lazy dense_vector index; live-verified on ES 9.1.9) and ChromaVectorStore (v2 REST, where dataset scoping; live-verified on Chroma 0.6.3). InMemoryVectorStore gains persistToFile/loadFromFile (atomic via temp file + move). …
    View on GitHub ↗
  2. v2.8.0
    Release notes excerpt
    ai4j-sdk 2.8.0 Highlights - MinerU cloud document parsing in core ai4j (io.github.lnyocly.ai4j.document.mineru): MinerUService covers the authenticated v4 precise API (URL tasks, batch tasks, presigned local-file upload, result-zip extraction of full.md + content_list.json + images) and the token-free v1 lite API (IP rate-limited, Markdown only). MinerUDocumentParser adapts to the DocumentParser SPI via explicit construction; MinerUDocumentLoader feeds parsed Markdown into the RAG ingestion pipeline for local files and remote URLs. …
    View on GitHub ↗
  3. v2.5.0
    Release notes excerpt
    <!-- Release notes generated using configuration in .github/release.yml at v2.5.0 --> Full Changelog: https://github.com/LnYo-Cly/ai4j/compare/v2.4.2...v2.5.0
    View on GitHub ↗

FAQ

What runtime does ai4j require?
JDK 8 or later, plus an API key for the model platform you use (e.g., OPENAI_API_KEY).
How much code changes when switching providers?
Per the README, only PlatformType and the corresponding Config change; the rest of the calling code stays the same.
Does it support vector search and RAG?
Yes — built-in RAG with Rerank via Jina, Ollama, or Doubao, and vector stores Pinecone, Qdrant, pgvector, Milvus, and Redis.
Which protocols and workflow platforms are supported?
MCP and the A2A protocol are supported; AgentFlow integrates with Dify, Coze, and n8n.
License and availability?
Apache-2.0, available from Maven Central as io.github.lnyo-cly:ai4j:2.4.2.
View on GitHub ↗ Install ↓

Compare agents like this one

The same FARS review applied across the shortlist this agent qualifies for.

Related agents