Skip to main content

TypeScript SDK

A TypeScript client for the Alice evaluate API. One client instance serves many applications because appId is passed per request. Built for Node.js sandboxes such as Cognigy extensions and serverless functions.

Status: Generally available · Evaluates: Prompts, Responses · Vendor: Alice

Prompts, responses and images. Session and user ids in the context.

Setup​

npm install @alice-io/wonderfence-ts-sdk

Configuration: ALICE_API_KEY, appId

Example​

import { WonderFenceV2Client, AnalysisContext } from '@alice-io/wonderfence-ts-sdk';

const client = new WonderFenceV2Client({ apiKey: 'your-api-key' });
const appId = '550e8400-e29b-41d4-a716-446655440000'; // UUID from the Application Inventory page

const context: AnalysisContext = { sessionId: 'session-123', userId: 'user-456' };

const promptResult = await client.evaluatePrompt(appId, context, 'Your prompt text');
const responseResult = await client.evaluateResponse(appId, context, 'Response text');

// Release pooled HTTP sockets on shutdown
client.close();

Good to know​

Provide either text or an image per call, not both. Retries use exponential backoff; set maxRetries: 0 in environments that allow one outbound request per execution.