Unofficial Java SDK for turning application state into typed Jev judgments through TypeSafe, OpenRouter, Vercel AI Gateway, or Cloudflare. Define Choice, Noul, and Score questions in Java, submit them together, and receive typed results instead of parsing generated text.
Jev Java requires Java 17 or newer. The plain SDK uses JDK HttpClient and Jackson 2; Spring is optional. This project is not affiliated with TypeSafe AI, Vercel, or OpenAI.
If Jev Java helps your project, consider giving it a star on GitHub ⭐.
Version 0.5.0 extends the experimental image and Box APIs to OpenRouter and Cloudflare, and adds opt-in image state support for Vercel decision-model v4. The core image API first appeared for direct TypeSafe in 0.4.0. See the image guide for provider-specific setup and limits.
Version 0.3.0 added OpenAI Decisions: text/image inputs, typed string/boolean
choices, scoring, per-question refusals and request-level safety identifiers.
The existing Jev question and record interfaces remain available; see the
OpenAI guide for both APIs and their boundaries.
Version 0.6.0 added OpenAI Decisions GA support: JSON input, conversation/tool
history, multipart questions and prompt-cache controls.
Version 0.7.0 syncs upstream provider contracts (checked 2026-11-28): adds
TypeSafe listModels() (GET /v1/models), opt-in TypeSafe long-context support
(TypeSafe-Danger-Zone-Long-Context: true) and TypeSafeRequestOptions,
optional question instructions and one-sided Noul criteria, OpenRouter refusal
failure handling, Vercel decision-model v4 maxOutputTokens and reasoning
options, and OpenAI generic blank/repeated Score label preservation; see
release notes.
Choose the module that matches your application:
| Artifact | Use it for |
|---|---|
jev-typesafe |
Plain Java client for TypeSafe's public Jev API |
jev-cloudflare |
Cloudflare AI access to typesafe/jev |
jev-openrouter |
Plain Java client for OpenRouter's alpha Decisions API |
jev-openai |
OpenAI Decisions: native text/images and typed Jev compatibility |
jev-vercel |
Plain Java adapter for Vercel AI Gateway's experimental evaluation protocol |
jev-spring-boot-starter |
Spring Boot auto-configuration with the default JDK transport |
jev-spring-webflux |
Optional WebClient transport and lazy Reactor facade |
For direct TypeSafe access:
<dependency>
<groupId>io.github.gudcks0305</groupId>
<artifactId>jev-typesafe</artifactId>
<version>0.7.0</version>
</dependency>Use jev-openrouter for OpenRouter or jev-cloudflare for Cloudflare. For
Vercel AI Gateway, use jev-typesafe with its documented
TypeSafe-compatible endpoint, or jev-vercel
for the existing evaluation-model v4 adapter. Each provider module brings in
jev-core; do not add it separately.
Gradle Kotlin DSL:
repositories { mavenCentral() }
dependencies {
implementation("io.github.gudcks0305:jev-typesafe:0.7.0")
}Record mapping is built into jev-core, included by every provider module.
Annotations compile to native questions; one evaluation fills the complete record.
Boolean thresholds are required explicitly, and the original evaluation remains
available alongside the mapped value.
Set TYPESAFE_API_KEY before running this direct-TypeSafe example.
import io.github.gudcks0305.jev.schema.JevBoolean;
import io.github.gudcks0305.jev.schema.JevChoice;
import io.github.gudcks0305.jev.schema.JevProbability;
import io.github.gudcks0305.jev.typesafe.TypeSafeJevClient;
public final class RecordQuickstart {
enum Team { BILLING, TECHNICAL }
record Ticket(
@JevChoice("Which team should handle this customer request?") Team team,
@JevBoolean(value = "Does the customer need help today?", threshold = .8) boolean urgent,
@JevProbability("Is the customer asking for a refund?") double refundProbability) {}
public static void main(String[] args) {
try (var client = TypeSafeJevClient.builder().build()) {
var result = client.evaluate("I was charged twice. Please refund me today.", Ticket.class);
Ticket ticket = result.value();
System.out.println(ticket.team());
System.out.println(result.evaluation().answers()); // probabilities/confidence retained
}
}
}Compile explicitly with JevSchema.of(Ticket.class) to validate configuration at
startup and reuse the schema. The same Class/schema overloads are available on
evaluateAsync and ReactorJevClient.evaluate, with cancellation propagation.
| Record field | Annotation | Mapping |
|---|---|---|
boolean / Boolean |
@JevBoolean(value=..., threshold=...) |
Noul probability compared with the explicit threshold |
double / Double |
@JevProbability(...) |
Raw yes probability |
| enum | @JevChoice(...) |
One enum constant |
Optional<Enum> |
@JevChoice(...) |
Enum or explicit no-match choice |
double / Double |
@JevScore(value=..., levels={...}) |
Raw weighted level index, never silently rounded |
List<Enum> / Set<Enum> |
@JevLabels(value=..., threshold=...) |
Independent Noul question per enum constant |
| nested record | annotate its leaf fields | Flattened questions, reconstructed nested record |
@JevLabel can describe enum constants. Free-text fields, generic/recursive
records and incompatible annotations fail before HTTP. This layer does not
generate prose, invoke tools, or fall back to another model. See
record schemas for complete semantics and examples.
Set the key for your provider:
export TYPESAFE_API_KEY=...
# or: export OPENROUTER_API_KEY=...
# or: export AI_GATEWAY_API_KEY=...One evaluate call can batch different typed questions:
import io.github.gudcks0305.jev.ChoiceQuestion;
import io.github.gudcks0305.jev.JevClient;
import io.github.gudcks0305.jev.NoulQuestion;
import io.github.gudcks0305.jev.ScoreQuestion;
import io.github.gudcks0305.jev.typesafe.TypeSafeJevClient;
import java.util.List;
public final class Quickstart {
enum Department { BILLING, TECHNICAL, SALES }
public static void main(String[] args) {
var route = ChoiceQuestion.of(
"route", "Which department should handle this?", Department.class);
var urgent = NoulQuestion.of(
"urgent", "Does this require an urgent response?");
var severity = ScoreQuestion.of(
"severity", "How severe is the problem?",
List.of("No problem", "Minor problem", "Major problem"));
try (JevClient client = TypeSafeJevClient.builder().build()) {
var result = client.evaluate(
"I was charged twice and need a refund today.",
route, urgent, severity);
Department department = result.answer(route).choice();
double urgentProbability = result.answer(urgent).probability();
boolean escalate = result.answer(urgent).atLeast(0.90);
double severityIndex = result.answer(severity).score();
System.out.printf("%s urgent=%.2f escalate=%s severity=%.2f%n",
department, urgentProbability, escalate, severityIndex);
}
}
}NoulAnswer.probability() is the probability of true; the application owns its threshold. A Score is a weighted zero-based level index, so three levels span 0–2. ChoiceAnswer.probabilities(), ScoreAnswer.probabilities(), and their confidence() values preserve provider data; a missing distribution or confidence remains absent rather than being invented.
String choices can include plain or structured descriptions:
import io.github.gudcks0305.jev.ChoiceQuestion;
import java.util.Map;
final class StringChoiceExample {
static final ChoiceQuestion<String> ROUTE = ChoiceQuestion.of(
"route", "Choose a team", Map.of(
"billing", "Payments and refunds",
"technical", Map.of("handles", "Bugs and outages")));
}Enum labels use Enum.name(). Add enum descriptions with withDescriptions(Map.of(...)). Keep the exact question instance passed to evaluate; result.answer(question) checks its identity to preserve the generic answer type.
evaluateAsync(state, questions...) returns a cancellable CompletableFuture<Evaluation>. Reuse clients and close them when the application stops. Use blocking evaluate() only from blocking code.
ChoiceQuestion.of(id, ...) and ScoreQuestion.of(id, levels) also accept omitted instructions when criteria alone define the judgment, and NoulQuestion.ofCriteria(id, yes, no) creates criteria-only yes/no questions (including one-sided null criteria) for TypeSafe, OpenRouter, Cloudflare, and Vercel DECISION_V4.
With TypeSafeJevClient, call listModels() / listModelsAsync() for GET /v1/models, enable TypeSafeJevClient.builder().longContext(true) or pass TypeSafeRequestOptions per call for TypeSafe-Danger-Zone-Long-Context: true (262k context) or per-request model selection:
import io.github.gudcks0305.jev.NoulQuestion;
import io.github.gudcks0305.jev.typesafe.TypeSafeJevClient;
import io.github.gudcks0305.jev.typesafe.TypeSafeModelList;
import io.github.gudcks0305.jev.typesafe.TypeSafeRequestOptions;
try (var client = TypeSafeJevClient.builder().build()) {
TypeSafeModelList models = client.listModels();
var clause = NoulQuestion.of("termination", "Can either party terminate early?");
var result = client.evaluate("Long contract text...",
TypeSafeRequestOptions.withLongContext(), clause);
System.out.println(models.models().size() + ": " + result.answer(clause).probability());
}VercelJevClient.builder().build() keeps the evaluation-model v4 protocol by
default. Opt into decision-model v4 with
.protocol(VercelJevClient.Protocol.DECISION_V4) to send image state, optional
.maxOutputTokens(...), or .reasoning(...) through Vercel Gateway. Default
models remain jev-latest for direct TypeSafe (now resolving to jev-1.14.0,
checked 2026-11-28) and typesafe-ai/jev for Vercel. Vercel also offers a
public TypeSafe-compatible route usable with TypeSafeJevClient; see the
Vercel guide for its explicit key, model, and URL.
TypeSafe image APIs since 0.4.0; OpenRouter, Cloudflare, and Vercel decision-model v4 support since 0.5.0. These APIs remain experimental; existing model defaults and the Vercel evaluation-model v4 protocol stay unchanged.
TypeSafe, OpenRouter, and Cloudflare clients accept JevInput with PNG/JPEG
images. They support image references in state, instructions, and criteria, and
support BoxQuestion with Jev 1.14. Pin .model("jev-1.14.0") for TypeSafe,
.model("typesafe/jev-1.14") for OpenRouter, or
.model("typesafe/jev-1.14.0") for Cloudflare. Defaults remain unchanged.
Vercel image input requires VercelJevClient.Protocol.DECISION_V4 and a
VercelDecisionInput state built from .text(...), .json(...), and
.image(...). It supports images in state only, and does not support Box. The
default Vercel evaluation-model v4 protocol remains unchanged. TypeSafe labels
image and Box features experimental. See images and Box for
a Java example, limits, and protocol boundaries.
OpenRouterJevClient uses OPENROUTER_API_KEY, model typesafe/jev-1.13, and
https://openrouter.ai/api/alpha/decisions. This is the alpha Decisions API,
not Chat Completions. Choose jev-openrouter for plain Java or set
jev.provider=openrouter with the Spring Boot starter. JDK and WebClient
transports are both supported.
import io.github.gudcks0305.jev.NoulQuestion;
import io.github.gudcks0305.jev.openrouter.OpenRouterJevClient;
public final class OpenRouterQuickstart {
public static void main(String[] args) {
var question = NoulQuestion.of("refund", "Is the customer requesting a refund?");
try (var client = OpenRouterJevClient.builder().build()) {
var result = client.evaluate("Please refund the duplicate charge.", question);
System.out.println(result.answer(question).probability());
}
}
}For proxies, .baseUrl(URI) changes the origin/path prefix and still appends the
provider's endpoint suffix. .endpoint(URI) instead uses the complete URL
exactly as supplied, including its path and optional query. Do not configure
both. These options do not change the selected
provider's authentication or wire format.
| Client | Default model | Path appended to baseUrl |
|---|---|---|
TypeSafeJevClient |
jev-latest |
/v1/systemone |
OpenRouterJevClient |
typesafe/jev-1.13 |
/api/alpha/decisions |
VercelJevClient (default EVALUATION_V4) |
typesafe-ai/jev |
/v4/ai/evaluation-model |
VercelJevClient (DECISION_V4) |
typesafe-ai/jev |
/v4/ai/decision-model |
CloudflareJevClient |
typesafe/jev |
/accounts/{accountId}/ai/run (default base includes /client/v4) |
Example Spring configuration for an OpenRouter-compatible proxy:
jev:
provider: openrouter
transport: webclient
endpoint: "https://proxy.example.com/evaluate?api-version=1"OpenRouter may omit probability distributions, confidence, legend, model, and
usage metadata. Missing values stay absent (score legends can fall back to the
request's levels). Returned id, provider, and usage.cost remain available
in rawResponse(). OpenRouter criteria support strings/objects/arrays; choice
descriptions may be null, score levels may not, and Noul criteria support
one-sided or omitted instructions; any refusal answer fails the whole
evaluation with JevException.Kind.REFUSAL. OpenRouter also exposes a
TypeSafe-compatible POST https://openrouter.ai/api/v1/systemone route usable
with TypeSafeJevClient.builder().baseUrl(URI.create("https://openrouter.ai/api"))
(checked 2026-11-28).
Use the jev-cloudflare dependency and
io.github.gudcks0305.jev.cloudflare.CloudflareJevClient.builder().build().
Set CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID, or provide .apiKey(...)
and .accountId(...). The default URL is
https://api.cloudflare.com/client/v4/accounts/{accountId}/ai/run, and the
adapter sends {model, input: {state, questions}} with model typesafe/jev.
With the starter, select jev.provider=cloudflare; optional jev.account-id
overrides the environment. A full jev.endpoint/.endpoint(...) override does
not require an account ID. Cloudflare requires an API token with Account →
Workers AI → Read permission, including for this third-party model, and
sufficient AI credits. Official Cloudflare contract.
The starter includes five provider adapters and defaults to TypeSafe over JDK HttpClient:
<dependency>
<groupId>io.github.gudcks0305</groupId>
<artifactId>jev-spring-boot-starter</artifactId>
<version>0.7.0</version>
</dependency>jev:
provider: typesafe # or openrouter / vercel / cloudflare / openai
transport: jdk
timeout: 30s
max-retries: 2Inject JevClient into blocking services. The starter reads TYPESAFE_API_KEY, OPENROUTER_API_KEY, AI_GATEWAY_API_KEY, or CLOUDFLARE_API_TOKEN when jev.api-key is absent, performs no network call during startup, backs off when the application defines its own JevClient, and can be disabled with jev.enabled=false.
The base starter does not pull in WebFlux. Add the optional module and select its transport:
<dependency>
<groupId>io.github.gudcks0305</groupId>
<artifactId>jev-spring-webflux</artifactId>
<version>0.7.0</version>
</dependency>jev:
provider: typesafe
transport: webclientThe starter now exposes a lazy ReactorJevClient:
import io.github.gudcks0305.jev.ChoiceQuestion;
import io.github.gudcks0305.jev.webflux.ReactorJevClient;
import reactor.core.publisher.Mono;
final class RoutingService {
enum Department { BILLING, TECHNICAL, SALES }
private final ReactorJevClient jev;
RoutingService(ReactorJevClient jev) {
this.jev = jev;
}
Mono<Department> route(String message) {
var question = ChoiceQuestion.of(
"route", "Which department should handle this?", Department.class);
return jev.evaluate(message, question)
.map(result -> result.answer(question).choice());
}
}Each subscription starts one request, and cancellation reaches the underlying future, HTTP request, and pending retry delay. The SDK does not call .block().
For a command-line or other non-web Boot application, set spring.main.web-application-type=none when adding WebFlux.
To retain application filters, observability, connector, and connection-pool settings, expose the WebClient you want Jev to use. Mark it primary when multiple clients exist:
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.web.reactive.function.client.WebClient;
@Configuration
class JevWebClientConfiguration {
@Bean
@Primary
WebClient jevWebClient(WebClient.Builder builder) {
return builder.build();
}
}Auto-configuration chooses a unique/primary WebClient, then a unique/primary WebClient.Builder, then a default builder. The SDK does not shut down caller-supplied WebClient connector resources.
Outside Spring Boot, wire the transport explicitly:
import io.github.gudcks0305.jev.JevClient;
import io.github.gudcks0305.jev.typesafe.TypeSafeJevClient;
import io.github.gudcks0305.jev.webflux.ReactorJevClient;
import io.github.gudcks0305.jev.webflux.WebClientJevTransport;
import java.time.Duration;
import org.springframework.web.reactive.function.client.WebClient;
public final class JevClients implements AutoCloseable {
private final WebClientJevTransport transport;
private final JevClient client;
private final ReactorJevClient reactive;
public JevClients() {
WebClient webClient = WebClient.builder().build();
transport = new WebClientJevTransport(
webClient, Duration.ofSeconds(30), 2);
client = TypeSafeJevClient.builder().transport(transport).build();
reactive = new ReactorJevClient(client);
}
public ReactorJevClient reactive() {
return reactive;
}
@Override
public void close() {
client.close();
transport.close();
}
}ReactorJevClient does not own its delegate. Close client and transport during shutdown, then close any connector resources your application owns. When a transport is injected, it owns timeout/retry policy; builder .timeout() and .maxRetries() apply only to the default JDK transport.
| Property | Default | Meaning |
|---|---|---|
jev.enabled |
true |
Enable auto-configuration |
jev.provider |
typesafe |
typesafe, openrouter, vercel, cloudflare, or openai |
jev.vercel-protocol |
evaluation-v4 |
For Vercel: opt into decision-v4 for image state parts |
jev.long-context |
false |
For TypeSafe: opt into TypeSafe-Danger-Zone-Long-Context: true |
jev.vercel-max-output-tokens |
unset | For Vercel decision-v4: positive maxOutputTokens override |
jev.vercel-reasoning |
unset | For Vercel decision-v4: provider-default, none, minimal, low, medium, high, xhigh, or max |
jev.transport |
jdk |
jdk or webclient |
jev.api-key |
provider environment variable | Explicit key override |
jev.model |
provider default | Model ID |
jev.base-url |
provider origin | Custom origin/path prefix; provider endpoint suffix is appended |
jev.account-id |
CLOUDFLARE_ACCOUNT_ID |
Cloudflare account; unnecessary with a full endpoint override |
jev.endpoint |
unset | Full request URL, including path/query; mutually exclusive with jev.base-url |
jev.timeout |
30s |
Total deadline across attempts and retry delays |
jev.max-retries |
2 |
Retries after the first attempt, from 0 to 10 |
JevException.kind() separates authentication, validation, rate limiting, server/HTTP, connection, timeout, protocol, and closed-client failures. statusCode() is the HTTP status, or 0 when none is available. Error messages exclude response bodies and credentials by default.
The OpenAI compatibility adapter adds REFUSAL: one refused question fails the
whole evaluation without returning partial answers or substituting a value.
Since 0.6.0, it also accepts JSON state and structured instructions, including
@JevLabels; 0.5.0 retains the earlier text-only limits.
OpenRouter and Vercel decision-model v4 also fail the whole evaluation with
JevException.Kind.REFUSAL when any question is refused. Vercel images belong
in explicit state parts; Box is unsupported on Vercel.
Only explicit 429, 529, 502, 503, and 504 responses retry. Connection failures and ambiguous timeouts do not automatically retry because the service may already have processed and billed the request. There is no automatic provider fallback.
The SDK preserves missing probabilities, confidence, and token counts as missing. It does not normalize scores or probability distributions. Provider metadata, warnings, and rounding information remain available through Evaluation.rawResponse(). Typed output prevents schema mismatch; it does not guarantee a correct judgment. Validate thresholds against your own labeled data.
Netlify AI Gateway serves Jev through TypeSafe's API, so use jev-typesafe or the
Spring starter with jev.provider=typesafe. Pass Netlify's TYPESAFE_BASE_URL
to the existing client; it already reads TYPESAFE_API_KEY. See the
Netlify AI Gateway configuration guide for Java
and Spring examples, runtime limits, and validation status.
Venice and AI/ML API document TypeSafe-shaped Jev Decisions endpoints. Use
the existing TypeSafe client with an explicit key, model, and complete
endpoint. See the Venice guide and
AI/ML API guide for Java and Spring examples, contract
limits, and verification status. Successful live inference through either
endpoint has not been verified.
Additional services publish TypeSafe-shaped APIs. The following guides use
jev-typesafe and explicit credentials, model IDs, and complete endpoints;
they do not add provider modules or Spring jev.provider values.
| Service | Model | Guide |
|---|---|---|
| DigitalOcean | Jev | Configuration and account limits |
| OpenCode Zen | Jev | Paid and temporary free routes |
| LLM Gateway | Jev | System One endpoint |
| Eden AI | Jev | Alpha Decisions endpoint |
| Upstage | Solar Decide (a different model, beta) | Contract and limits |
| Liquid AI | d1 (a different model) | Contract and limits |
These are documented compatibility routes, not verified live Java inference. Solar Decide and d1 share question shapes with Jev but are independent models: evaluate their judgments and thresholds separately. See validation evidence for the exact offline fixture coverage. Vercel's public TypeSafe-compatible route is documented separately from its v4 adapter.
TypeSafe direct calls have been exercised with the JDK transport, WebClient transport, and Spring Boot auto-configuration. OpenRouter and Cloudflare use official contracts and local HTTP tests; live inference has not been verified because their credentials were unavailable. A Vercel decision-model v4 image request returned HTTP 403 without a successful inference result; the reason is unknown, so successful live inference is unverified. See provider contracts and protocol limits and validation evidence.
The test matrix covers Java 17, 21, and 25 with Spring Boot 3.5.16 and 4.1.1. Offline tests use local servers and fakes and require no API keys. Java examples in this README are compiled with --release 17.
The source build runs offline tests and installs the modules locally. The optional live example requires your provider environment key and can make billable requests:
git clone https://github.com/gudcks0305/jev-java.git
cd jev-java
./mvnw install
./mvnw -q -pl examples exec:java \
-Dexec.mainClass=io.github.gudcks0305.jev.examples.Quickstart \
-Dexec.args=typesafeUse RecordExample, WebClientExample, or SpringBootExample for those integration paths. Passing openrouter, vercel, or cloudflare selects that provider; Vercel uses evaluation-model v4 by default. Quickstart, RecordExample, and WebClientExample also accept openai with OPENAI_API_KEY. A Vercel decision-model v4 request returned HTTP 403 without a successful inference result, so live success is unverified.