Chanl

SDK Overview

TypeScript SDK for building, testing, and monitoring AI agents

The Chanl SDK gives you programmatic access to the platform API: build agent capabilities, test them with simulated conversations, and monitor quality in production. For embedding chat or voice on your website, use the sibling package @chanl/widget-sdk.

Packages

PackageInstallPurpose
@chanl/sdknpm install @chanl/sdkServer-side platform API (agents, tools, scenarios, …)
@chanl/widget-sdknpm install @chanl/widget-sdkBrowser embed script, React hooks, voice
@chanl/clinpm install -g @chanl/cliCommand-line interface

Installation (@chanl/sdk)

npm install @chanl/sdk

Setup

import { Chanl } from '@chanl/sdk';

const chanl = new Chanl({
  apiKey: process.env.CHANL_API_KEY,
});

Store your API key in environment variables. Never commit it to source control.

What you can do

The SDK maps to the three pillars of the Chanl platform.

Build

Give your agents tools, knowledge, and the ability to hold conversations.

// Create a tool your agent can call mid-conversation
const tool = await chanl.tools.create({
  name: 'lookup_order',
  description: 'Look up order details by order number',
  parameters: {
    type: 'object',
    properties: {
      order_id: { type: 'string', description: 'The order number' },
    },
    required: ['order_id'],
  },
  handlerUrl: 'https://api.yourstore.com/orders/lookup',
});

// Add documents to the knowledge base
const entry = await chanl.knowledge.create({
  title: 'Return Policy',
  source: 'text',
  content: 'Returns accepted within 30 days of purchase...',
});

// Test your agent with a chat session
const session = await chanl.chat.createSession('agent_abc123');
const response = await chanl.chat.sendMessage(
  session.sessionId,
  'What is your return policy?'
);

Test

Import calls and evaluate them against quality scorecards.

// Import a call transcript for analysis
const imported = await chanl.calls.import({
  transcript: `
    Agent: Thank you for calling Acme Support, this is Sarah.
    Customer: Hi, my order arrived damaged.
    Agent: I'm sorry to hear that. Let me process a replacement right away.
    Customer: That would be great, thanks!
  `,
  analysisFields: ['sentiment', 'topics', 'quality'],
});

// Evaluate the call against a scorecard
const evaluation = await chanl.scorecard.evaluate(
  imported.callId,
  { scorecardId: 'scorecard_abc123' }
);

console.log('Score:', evaluation.score + '%');
console.log('Passed:', evaluation.passed);

Monitor

Query calls, review results, and track quality over time.

// List recent calls with filters
const { calls } = await chanl.calls.list({
  status: 'ended',
  direction: 'inbound',
  startDate: '2026-01-01',
  endDate: '2026-01-31',
  limit: 50,
});

// Get evaluation results for a specific call
const { results } = await chanl.scorecard.getResults(callId);

results.forEach((result) => {
  console.log(`${result.scorecardName}: ${result.score}%`);
  result.criteriaResults.forEach((cr) => {
    console.log(`  ${cr.passed ? 'PASS' : 'FAIL'} ${cr.name}: ${cr.score}%`);
  });
});

SDK modules

ModuleDescriptionPhase
chanl.toolsCreate and manage tools agents can callBuild
chanl.toolsetsGroup tools into reusable collectionsBuild
chanl.knowledgeIngest documents, search with hybrid queriesBuild
chanl.chatTest agents with text-based conversationsBuild
chanl.promptsManage versioned prompt templatesBuild
chanl.callsImport, list, query, and delete callsTest
chanl.scorecardCreate scorecards and evaluate callsTest
chanl.agentsSync and manage AI agentsMonitor
chanl.mcpMCP server configurationBuild
@chanl/widget-sdkEmbed chat/voice on your siteConnect

See the Widget SDK reference and Chat widget guide.

Error handling

The SDK provides typed errors so you can handle each failure case precisely.

import {
  ChanlError,
  ValidationError,
  NotFoundError,
  AuthenticationError,
  RateLimitError,
} from '@chanl/sdk';

try {
  const call = await chanl.calls.get('call_123');
} catch (error) {
  if (error instanceof NotFoundError) {
    console.log('Call not found:', error.message);
  } else if (error instanceof ValidationError) {
    console.log('Validation failed:', error.details);
  } else if (error instanceof AuthenticationError) {
    console.log('Auth error - check your API key');
  } else if (error instanceof RateLimitError) {
    console.log('Rate limited, retry after:', error.retryAfter);
  } else if (error instanceof ChanlError) {
    console.log('API error:', error.code, error.message);
  }
}

TypeScript types

Full type definitions ship with the package. Your IDE gets autocompletion and compile-time safety out of the box.

import type {
  Call,
  CallImportOptions,
  Scorecard,
  ScorecardResult,
  Tool,
  Toolset,
  KnowledgeEntry,
  KnowledgeSearchResult,
  ChatSessionResponse,
  ChatMessageResponse,
} from '@chanl/sdk';

Next steps

On this page