文件導航

JavaScript SDK

TypeSafe AI 的 JavaScript 與 TypeScript SDK。

快速開始

安裝 SDK(需要 Node.js 20 或更新版本):

npm install @typesafe-ai/sdk

在環境裡設定 TYPESAFE_API_KEY,然後建立並使用客戶端:

import { choice, TypeSafeClient } from "@typesafe-ai/sdk";

const client = new TypeSafeClient();
const response = await client.systemOne({
  state: { document: "I was charged twice. Please fix this ASAP." },
  questions: {
    category: choice("What is this ticket about?", {
      billing: null,
      technical: null,
      other: null,
    }),
  },
});

console.log(response.answers.category.choice);

答案型別會從你的問題推斷出來。該包包含 ESM、CommonJS 和 TypeScript 宣告。

文件

在 TypeSafe 文件裡瞭解 TypeSafe 能做什麼。 關於 API 選項和預設值,見 SDK 的客戶端和型別。