JavaScript SDK
JavaScript- und TypeScript-SDK für TypeSafe AI.
Schnellstart
Installiere das SDK (Node.js 20 oder neuer):
npm install @typesafe-ai/sdk
Setze TYPESAFE_API_KEY in deiner Umgebung und erstelle dann den Client und verwende ihn:
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);
Die Antworttypen werden aus deinen Fragen abgeleitet. Das Paket enthält ESM-, CommonJS- und TypeScript-Deklarationen.
Dokumentation
Erfahre in der TypeSafe-Dokumentation, was TypeSafe kann. Sieh dir den Client und die Typen des SDK an, um API-Optionen und Standardwerte zu erfahren.