Skip to content

System One AI SDK (npm) for typed decisions.

Use the System One AI SDK (npm) to add structured decisions with one evaluate() call. Define choices, scoring rubrics, and yes/no questions, then use typed answers in your application.

Open source · TypeScript · Node.js

Install the SDK
npm install @system-one-ai/core@0.8.0 @system-one-ai/adapter-system-one@0.7.0 @system-one-ai/transport-fetch@0.8.0
decision.ts
import { createSystemOne, choice } from '@system-one-ai/core';import { systemOneAdapter } from '@system-one-ai/adapter-system-one';import { createFetchTransport } from '@system-one-ai/transport-fetch';const client = createSystemOne({  adapter: systemOneAdapter,  transport: createFetchTransport(),  baseURL: process.env.SYSTEM_ONE_BASE_URL!,  apiKey: process.env.SYSTEM_ONE_API_KEY!,  maxRetries: 0,});const result = await client.evaluate({  state: { message: 'I was charged twice.' },  questions: {    team: choice('Who should handle this?', {      billing: 'Payments and refunds',      support: 'Technical issues',    }),  },});result.answers.team.choice; // 'billing' | 'support'

Connect a model service

Install core, the service adapter, and a transport. Configure systemOneAdapter and createFetchTransport() for System One API. Keep credentials in your server environment.

SDK documentation
.env
SYSTEM_ONE_BASE_URL=https://api.typesafe.ai/v1SYSTEM_ONE_API_KEY=YOUR_TYPESAFE_API_KEY

One interface for structured decisions

Types from question to answer

Choice results retain your option names as TypeScript literal types. Scores and yes/no probabilities return as numbers.

Connect your provider

Use System One API directly. An optional Vercel AI SDK adapter connects other supported model services.

Control request behavior

Configure timeouts and retries, cancel with AbortSignal, and handle typed errors in your application.

Connect to System One API

Use your System One API key to call the hosted service. Test inputs in the Playground and review request usage in the console.