Production-Grade AI for JVM Backends.
Clean interfaces. Structured data. Native observability. The library built for production-grade Java and Kotlin backends.
@AiService
interface ReviewAnalyzer {
@Operation("Analyze the sentiment of this review and extract key topics.")
suspend fun analyze(text: String): Analysis
}
data class Analysis(
val sentiment: Sentiment,
val topics: List<String>,
val requiresFollowup: Boolean
)@AiService
public interface ReviewAnalyzer {
@Operation(
prompt = "Analyze the sentiment of this review and extract key topics."
)
Analysis analyze(String text);
}
public record Analysis(
Sentiment sentiment,
List<String> topics,
boolean requiresFollowup
) {}Define your contract, Tramai handles the rest: prompt construction, model routing, and type-safe parsing.
Choose Your Path
Tramai is modular. Start where you are and grow as needed.
Spring Boot
Native integration with Spring Boot 3.x. Auto-configuration and Spring-style AI services.
Standalone
Zero-dependency core for CLI apps or any JVM project. Clean, builder-based configuration.
Local AI
Privacy-first processing with Ollama. Run powerful models locally without API keys.
Modules
Providers
Guides
JVM Ready
Providers: OpenAI, Anthropic, Gemini, DeepSeek, Ollama, Bedrock, Azure OpenAI, and more
AI as a 4th Software Layer
TramAI adds @AiService as a first-class architectural layer alongside your controllers, services, and repositories. Same rigor. Same injection model. Same testability.
How Tramai Compares
Honest comparison vs LangChain4j and Spring AI. No marketing — just facts.
| Feature | Tramai | LangChain4j | Spring AI |
|---|---|---|---|
| Type Safety | Typed @AiService interfaces, data class return types | Prompt templates, string-based chains | String-in/String-out or ChatClient |
| Structured Output | Automatic JSON schema from data classes, parse-and-retry | Manual schema definition | StructuredOutputConverter |
| Testing | tramai-testing module, deterministic mock providers, no network | Mock providers available | Mock models available |
| Observability | Native OpenTelemetry spans/metrics for every AI call | OpenTelemetry via callbacks | Micrometer integration |
| Framework Lock-in | Framework-agnostic core, thin adapters | Spring-optional but Java-first | Spring-specific |
| Deployment | Standalone or Spring Boot, Native Image ready | Standalone or Spring Boot | Spring Boot only |
| Learning Curve | Low — define an interface, annotate, call | Moderate — chains, prompts, memory | Low if you know Spring |
