TypeSafe JavaScript SDK
npm install @typesafe-ai/sdk
Requires Node.js 20 or newer. ESM, CommonJS, and TypeScript declarations ship in the package.
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);
The client reads TYPESAFE_API_KEY. To send traffic through Vercel AI Gateway instead, Vercel documents constructing the client with apiKey: process.env.AI_GATEWAY_API_KEY and baseURL: 'https://ai-gateway.vercel.sh/typesafe'.
Helpers such as choice(), noul(), and score() live in the same package. Prefer them over hand-rolled JSON if you want inferred answer types.
Sources
Public TypeSafe or adjacent documentation only. No private claims.