
Agentle4j¶
The Modern Java Library for OpenAI Responses API
Type-safe, streaming-enabled, production-ready AI integration for Java
β¨ Key Features¶
-
Agent Framework
Complete agent system with tools, guardrails, memory, and handoffs
-
Type-safe API
Full OpenAI Responses API with Java records
-
Real-time Streaming
Virtual thread-based streaming with callbacks
-
Structured Outputs
Strongly-typed JSON responses
-
Function Calling
Auto-generated JSON schemas from Java classes
-
OpenTelemetry
Built-in observability with spans/metrics
β‘ Performance¶
Agent Instantiation Benchmark¶
Measures time to create an agent instance (not API calls). Lower is better.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AGENT INSTANTIATION BENCHMARK (lower = better) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Framework β Time (ΞΌs) β Memory (KiB) β Language
ββββββββββββββββββΌβββββββββββββΌββββββββββββββββΌβββββββββββββββββββββ
π Agentle4j β 0.50 β 0.39 β Java 21+ (this lib)
AGNO β 3.00 β 6.60 β Python
PydanticAI β 170.00 β 28.71 β Python
CrewAI β 210.00 β 65.65 β Python
LangGraph β 1,587.00 β 161.43 β Python
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Important Caveats
- Cross-language comparisons are inherently unfair. Java's JVM provides different performance characteristics than Python's interpreter.
- This benchmark only measures agent instantiation time, not actual LLM inference or end-to-end latency.
- We haven't benchmarked against LangChain4J or Spring AI yetβcontributions welcome!
- Real-world performance depends heavily on network latency, model choice, and payload size.
Java Alternatives¶
| Library | Focus | Notes |
|---|---|---|
| Agentle4j | Agents-first, OpenAI Responses API | This library |
| LangChain4J | General-purpose, many integrations | Mature ecosystem |
| Spring AI | Spring ecosystem integration | Production-ready |
π Quick Example¶
import com.paragon.responses.Responder;
import com.paragon.responses.payload.CreateResponsePayload;
// Create a responder
Responder responder = Responder.builder()
.openRouter()
.apiKey("your-api-key")
.build();
// Build your request
var payload = CreateResponsePayload.builder()
.model("openai/gpt-4o-mini")
.addDeveloperMessage("You are a helpful assistant.")
.addUserMessage("Hello!")
.build();
// Get the response
Response response = responder.respond(payload).join();
System.out.println(response.outputText());
π¦ Installation¶
π Documentation¶
| Section | Description |
|---|---|
| Installation | Detailed setup instructions |
| Getting Started | Quick start guide |
| Guides | In-depth feature guides |
| API Reference | Auto-generated Javadoc |
| Examples | Code samples |
π€ Contributing¶
We welcome contributions! Please see our GitHub repository for more information.
Made with β€οΈ by Paragon Intelligence