Jev Pink Book
6 / 8
Practices6

Lesson 6 · Your First Production API Call

模块Practices预计学习15 分钟难度

🎯 What You'll Learn

  • Execute an end-to-end API call with Node.js/Fetch
  • Parse structured answers and confidence values
  • Wire decisions directly into code logic

API Architecture

Code Example

javascript
const res = await fetch("https://api.typesafe.ai/v1/systemone", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.TYPESAFE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "jev-latest",
    state: "My monthly subscription was charged twice on my credit card.",
    questions: {
      is_urgent: { type: "noul", instructions: "Does this require immediate attention?" },
      department: {
        type: "choice",
        instructions: "Which department?",
        criteria: {
          billing: "Invoices, payments, refunds",
          technical: "System bugs, API errors",
          sales: "Upgrade, quotes"
        }
      }
    }
  })
});
const data = await res.json();
console.log(data.answers);

Integrating with Your Workflow

javascript
const { is_urgent, department } = data.answers;

if (is_urgent.noul > 0.8) {
  escalateToHuman(ticket);
} else if (department.confidence > 0.9) {
  routeTo(department.choice, ticket);
} else {
  reviewWithLLM(ticket);
}

📌 Takeaway

Jev computes the judgment; you control the if-else branching.

学完后记得保存进度

完成状态只保存在当前浏览器,不会上传你的学习记录。

Lesson 6 · Your First Production API Call | Jev Pink Book | 超级峰 AI 课堂