Java SDK
A typed JVM client for the EvalGuard /api/v1 surface — evals, security scans, traces, firewall, cost, compliance and prompts — plus a LangChain4j content filter.
Group ai.evalguard, artifact evalguard-sdk, v1.1.0.
Security — upgrade if you are on 1.0.8 or earlier
Versions 1.0.0–1.0.8 fail open: a malformed or truncated verdict was treated as “allowed” instead of raising. Fixed in 1.1.0 (GHSA-p2r9-6ppq-5hq9), which requires an explicit verdict and raises when one is absent. Upgrade before relying on the client to block anything.
Status — live on Maven Central
The core Java client and the LangChain4j content filter are published to Maven Central as ai.evalguard:evalguard-sdk (source at packages/java-sdk). The LangChain4j chat-model listener and the Spring AI adapters (auto-configuration / interceptor / guardrail advisor) are experimental and currently excluded from the published build — they were written against API versions that have since drifted and are being reconciled. For production JVM use today, the REST API works from any language.
Install
Add the dependency from Maven Central:
<dependency>
<groupId>ai.evalguard</groupId>
<artifactId>evalguard-sdk</artifactId>
<version>1.1.0</version>
</dependency>Maven Central is the only path you need. If you hold a monorepo read grant, you can also build the artifact into your local repo from source:
# requires monorepo read access (sales@evalguard.ai)
git clone https://github.com/EvalGuardAi/evalguard
cd evalguard/packages/java-sdk
mvn -B clean install # -> ai.evalguard:evalguard-sdk:1.1.1 in ~/.m2 (unpublished)Quick start
Build a client from an API key, then call the typed methods. Every call throws EvalGuardException on a non-2xx response.
import ai.evalguard.EvalGuardClient;
import ai.evalguard.EvalGuardClient.SecurityScanRequest;
import ai.evalguard.EvalGuardClient.FirewallCheckRequest;
import java.util.List;
var client = EvalGuardClient.builder(System.getenv("EVALGUARD_API_KEY"))
.build();
// Run a red-team security scan (projectId, model, prompt + attackTypes required)
var req = new SecurityScanRequest();
req.setProjectId(projectId);
req.setModel("gpt-4");
req.setPrompt(userPrompt);
req.setAttackTypes(List.of("prompt-injection"));
var scan = client.runSecurityScan(req);
System.out.println("safety score: " + scan.getScore());
// Real-time firewall check on an inbound prompt
var firewallReq = new FirewallCheckRequest();
firewallReq.setInput(userPrompt);
var verdict = client.checkFirewall(firewallReq);
if (verdict.isBlocked()) {
throw new IllegalStateException(
"blocked by firewall: " + verdict.getCategory() + " " + verdict.getHits());
}LangChain4j content filter
Drop EvalGuardContentFilter into a LangChain4j pipeline to guardrail model I/O against your EvalGuard firewall rules.
import ai.evalguard.langchain4j.EvalGuardContentFilter;
var filter = new EvalGuardContentFilter(client, projectId);
// Reject or flag inputs/outputs that violate your firewall policy
// before they reach (or leave) the model.
var safeInput = filter.filterInput(userMessage);Method reference
The published client exposes typed methods across these areas:
Evaluations
runEval()getEval()listEvals()Security
runSecurityScan()getSecurityScan()listSecurityScans()Traces
createTrace()getTrace()listTraces()searchTraces()Firewall
checkFirewall()listFirewallRules()createFirewallRule()Monitoring
getMonitoringAlerts()getMonitoringDrift()Cost / FinOps
getCost()getCostForecast()getCostSavings()Compliance
checkCompliance()listComplianceFrameworks()Prompts
createPrompt()getPrompt()listPrompts()updatePrompt()Prompt deployments & environments
listEnvironments()createEnvironment()removeEnvironment()setPromptDeployment()removePromptDeployment()