learn / api

Jev API: request, response, and fallback

A practical boundary for calling Jev without leaking provider details into the rest of your application.

Model the request as a decision contract

The state supplies evidence and each named question declares the answer type and criteria. Keep business thresholds out of prose: your application should own the threshold that decides whether to act, review, or fall back.

Keep credentials and provider details on the server

API keys, provider endpoints, model IDs, retries, and usage accounting belong at the server edge. A browser should call your route, not a model provider directly, so providers can change without rewriting product components.

Normalize before returning data to the client

Validate that the expected answer exists, coerce provider-specific usage fields into your own shape, and return an explicit unavailable or fallback state on errors. Do not let a network error look like a confident business decision.

Log the cases that cross the boundary

Store task version, model, latency, confidence, selected answer, and whether fallback was used. Those records become the fixture set for improving criteria and checking later model changes.

server / typescript
const decision = await jev.evaluate({
  state: ticket,
  questions: {
    routing: {
      type: "choice",
      instructions: "Route this ticket",
      criteria: { shipping: "Delivery issue", other: "Anything else" }
    }
  }
})

Build the next layer