Jev Academy

Pattern

Confidence gates: act, review, or escalate

The answer tells you what to do. Confidence tells you how sure you can be before you act. High confidence: act. Middle: have someone review. Low: escalate to a human.

curl

bash
curl -X POST https://api.typesafe.ai/v1/systemone \
  -H "Authorization: Bearer $TYPESAFE_API_KEY" \
  -H "Content-Type: application/json" \
  -d @- <<'EOF'
{
  "state": {"subject": "Charge dispute", "body": "I think this might be a duplicate but I'm not sure."},
  "model": "jev-latest",
  "questions": {
    "intent": {
      "type": "choice",
      "instructions": "Primary intent of this message",
      "criteria": {
        "refund": "Wants money back",
        "status": "Asking for status only",
        "other": "Something else"
      }
    }
  }
}
EOF

JavaScript

js
const key = process.env.TYPESAFE_API_KEY;
if (!key) throw new Error("TYPESAFE_API_KEY is not set");

const res = await fetch("https://api.typesafe.ai/v1/systemone", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${key}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    state: {
      subject: "Charge dispute",
      body: "I think this might be a duplicate but I'm not sure.",
    },
    model: "jev-latest",
    questions: {
      intent: {
        type: "choice",
        instructions: "Primary intent of this message",
        criteria: {
          refund: "Wants money back",
          status: "Asking for status only",
          other: "Something else",
        },
      },
    },
  }),
});

if (!res.ok) throw new Error(`HTTP ${res.status}`);
const { choice, confidence } = (await res.json()).answers.intent;

// Thresholds are yours — tune in code, not in a prompt.
const ACTION_THRESHOLD = 0.7;
if (confidence >= ACTION_THRESHOLD) {
  console.log("act", choice);
} else {
  console.log("review", { choice, confidence });
}

Notes

  • The answer tells you what. Confidence tells you whether to act on it. See the docs page 'Confidence-gated routing'.
  • Set your own thresholds in your app code. Pick them based on how much risk you can take.

Sources

← All labsBrowse use cases →