본문으로 건너뛰기
Jev

Jev TypeScript

Node 18+ / edge runtimes with global fetch. Keep keys server-side — never ship jv_live_ to the browser.

TypeScript
type DecideResponse = {
  answers?: Record<string, unknown>;
  usage?: { input_tokens?: number };
};

export async function callJev(state: string): Promise<DecideResponse> {
  const res = await fetch("https://jevtypesafe.org/api/v1/decide", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.JEV_API_KEY}`, // jv_live_...
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      state,
      questions: {
        topic: {
          type: "choice",
          instructions: "Route this message",
          criteria: {
            billing: "payments and refunds",
            bug: "product broken",
            account: "login or access",
          },
        },
        escalate: {
          type: "noul",
          instructions: "Should a human take this now?",
        },
      },
    }),
  });
  if (!res.ok) throw new Error(`Jev failed: ${res.status}`);
  return res.json() as Promise<DecideResponse>;
}
Jev TypeScript | Hosted Decide Client Example