TypeScript SDK
Install and use the Ctrl AI TypeScript SDK.
The TypeScript SDK is coming soon. This page documents the planned API.
Installation
npm install @ctrlai/sdkQuick Start
import { CtrlAI } from '@ctrlai/sdk';
const client = new CtrlAI({
apiKey: 'ctrlai_pk_...',
baseUrl: 'https://app.ctrlai.com', // or your self-hosted URL
});
// Run an inference query
const result = await client.inference.query({
query: 'What is the credit risk for this applicant?',
});
console.log(result.response);
console.log(result.coveragePercent); // e.g., 83
console.log(result.trustSummary); // { verified: 2, expertReviewed: 3, ... }Available Methods
Inference
// Run a query
client.inference.query({ query, domainId?, jurisdiction? })
// Resume a multi-turn session
client.inference.query({ sessionId, additionalInputs })
// Save a response segment as a unit
client.inference.saveAsUnit({ segmentText, domainId })
// Submit feedback on a claim
client.inference.feedback({ inferenceLogId, segmentIndex, feedback })Units
// List units with filters
client.units.list({ status?, unitType?, domainId?, limit?, offset? })
// Get a unit by ID
client.units.get(id)
// Create a unit
client.units.create({ name, unitType, domainId, ... })
// Update a unit
client.units.update(id, { name?, description?, ... })
// Verify a unit
client.units.verify(id, { action, elementReviews?, comment? })Workflows
// List workflows
client.workflows.list({ domainId?, limit?, offset? })
// Get a workflow
client.workflows.get(slug)
// Create a workflow
client.workflows.create({ name, domainId, units })
// AI-assisted composition
client.workflows.compose({ description, domainId })Organizations
// List orgs
client.orgs.list()
// Create an org
client.orgs.create({ name, slug })
// Manage members
client.orgs.members.list(slug)
client.orgs.members.invite(slug, { email, role })
// Manage API keys
client.orgs.apiKeys.list(slug)
client.orgs.apiKeys.create(slug, { name })
client.orgs.apiKeys.revoke(slug, keyId)