Skip to content

Agentle4j Logo

Agentle4j

The Modern Java Library for OpenAI Responses API

Java License Maven Central

Type-safe, streaming-enabled, production-ready AI integration for Java

Get Started API Reference


✨ 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

<dependency>
    <groupId>io.github.paragon-intelligence</groupId>
    <artifactId>agentle4j</artifactId>
    <version>0.1.0</version>
</dependency>
implementation 'io.github.paragon-intelligence:agentle4j:0.1.0'

πŸ“š 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