Skip to main content
The Burki JavaScript SDK is written in TypeScript and provides full type definitions for all models and methods. It works seamlessly in Node.js and browser environments.

Installation

npm install @burki.dev/sdk
Or with yarn:
yarn add @burki.dev/sdk
Requirements: Node.js 18+ or modern browser

Quick Start

import { BurkiClient } from '@burki.dev/sdk';

// Initialize the client
const client = new BurkiClient({ apiKey: 'your-api-key' });

// List all assistants
const assistants = await client.assistants.list();
for (const assistant of assistants) {
  console.log(`${assistant.id}: ${assistant.name}`);
}

// Create a new assistant
const assistant = await client.assistants.create({
  name: 'Support Bot',
  description: 'Customer support assistant',
  llmSettings: {
    model: 'gpt-4o-mini',
    temperature: 0.7,
    systemPrompt: 'You are a helpful customer support agent.'
  },
  ttsSettings: {
    provider: 'elevenlabs',
    voiceId: 'rachel'
  }
});

Configuration

Basic Configuration

const client = new BurkiClient({ apiKey: 'your-api-key' });

Custom Base URL

const client = new BurkiClient({
  apiKey: 'your-api-key',
  baseUrl: 'https://custom.burki.dev'
});

Timeout Settings

const client = new BurkiClient({
  apiKey: 'your-api-key',
  timeout: 60000 // 60 seconds in milliseconds
});

Using Environment Variables

const client = new BurkiClient({ 
  apiKey: process.env.BURKI_API_KEY! 
});

Resources

The JavaScript SDK provides the most comprehensive assistant management API.

List Assistants

// Basic list
const assistants = await client.assistants.list();

// With options
const activeAssistants = await client.assistants.list({
  activeOnly: true,
  includeStats: true,
  limit: 50
});

Get an Assistant

// By ID
const assistant = await client.assistants.get(123);

// By phone number
const assistant = await client.assistants.getByPhone('+14155551234');

Create an Assistant

const assistant = await client.assistants.create({
  name: 'My Bot',
  description: 'A helpful assistant',
  llmSettings: { 
    model: 'gpt-4o-mini',
    temperature: 0.7,
    systemPrompt: 'You are helpful.'
  },
  ttsSettings: {
    provider: 'elevenlabs',
    voiceId: 'rachel'
  }
});

Update an Assistant

const updated = await client.assistants.update(123, { 
  name: 'Updated Bot',
  description: 'Updated description'
});

Quick Status Update

// Activate
await client.assistants.updateStatus(123, true);

// Deactivate
await client.assistants.updateStatus(123, false);

Delete an Assistant

await client.assistants.delete(123);

Additional Methods

// Get assistant count
const count = await client.assistants.getCount(true); // Active only

// Export assistants
const csvBlob = await client.assistants.export({ format: 'csv' });

// Get cloned voices
const voices = await client.assistants.getClonedVoices({ 
  provider: 'elevenlabs' 
});

// Get available LLM providers
const providers = await client.assistants.getProviders();

// Get organization info
const orgInfo = await client.assistants.getOrganizationInfo();

Real-time Streaming

The JavaScript SDK uses async iterators for WebSocket streaming.

Live Transcript Streaming

const stream = client.realtime.liveTranscript('CA123...');
await stream.connect();

for await (const event of stream) {
  switch (event.type) {
    case 'transcript':
      console.log(`[${event.speaker}]: ${event.content}`);
      break;
    case 'call_status':
      console.log(`Call status: ${event.status}`);
      if (event.status === 'completed') {
        stream.disconnect();
      }
      break;
    case 'error':
      console.error(`Error: ${event.message}`);
      break;
  }
}

Campaign Progress Streaming

const stream = client.realtime.campaignProgress(123);
await stream.connect();

for await (const event of stream) {
  switch (event.type) {
    case 'progress':
      console.log(`Progress: ${event.completedContacts}/${event.totalContacts}`);
      break;
    case 'contact_completed':
      console.log(`Completed call to ${event.phoneNumber}`);
      break;
    case 'campaign_completed':
      console.log(`Campaign finished! Success rate: ${event.successRate}%`);
      stream.disconnect();
      break;
  }
}

Connection Management

const stream = client.realtime.liveTranscript('CA123...');

// Connect
await stream.connect();

// Send ping to keep connection alive
stream.sendPing();

// Request current status
stream.requestStatus();

// Disconnect when done
stream.disconnect();

TypeScript Support

The SDK provides full type definitions for all models and methods:
import type {
  Assistant,
  AssistantCreateParams,
  AssistantUpdateParams,
  Call,
  CallListParams,
  Campaign,
  CampaignCreateParams,
  PhoneNumber,
  PhoneNumberSearchParams,
  Tool,
  ToolCreateParams,
  Document,
  TranscriptEvent,
  CallStatusEvent,
  CampaignProgressEvent
} from '@burki.dev/sdk';

// Use types for better IDE support
const createParams: AssistantCreateParams = {
  name: 'My Bot',
  llmSettings: { model: 'gpt-4o-mini' }
};

const assistant: Assistant = await client.assistants.create(createParams);

Error Handling

The SDK provides typed exceptions for different error scenarios:
import {
  BurkiClient,
  AuthenticationError,
  NotFoundError,
  ValidationError,
  RateLimitError,
  ServerError,
  WebSocketError
} from '@burki.dev/sdk';

const client = new BurkiClient({ apiKey: 'your-api-key' });

try {
  const assistant = await client.assistants.get(999);
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.error('Invalid API key');
  } else if (error instanceof NotFoundError) {
    console.error('Assistant not found');
  } else if (error instanceof ValidationError) {
    console.error(`Validation error: ${error.message}`);
    console.error(`Field errors: ${JSON.stringify(error.errors)}`);
  } else if (error instanceof RateLimitError) {
    console.error(`Rate limited. Retry after ${error.retryAfter} seconds`);
  } else if (error instanceof ServerError) {
    console.error('Server error occurred');
  } else if (error instanceof WebSocketError) {
    console.error('WebSocket connection error');
  }
}

Exception Types

ExceptionDescription
AuthenticationErrorInvalid or missing API key
NotFoundErrorResource not found (404)
ValidationErrorInvalid request parameters (400)
RateLimitErrorToo many requests (429)
ServerErrorInternal server error (5xx)
WebSocketErrorWebSocket connection error

Complete Example

Here’s a complete example demonstrating the SDK’s capabilities:
import { BurkiClient, NotFoundError } from '@burki.dev/sdk';

async function main() {
  const client = new BurkiClient({ 
    apiKey: process.env.BURKI_API_KEY! 
  });

  // 1. Create an assistant
  const assistant = await client.assistants.create({
    name: 'Sales Assistant',
    description: 'Outbound sales assistant',
    llmSettings: {
      model: 'gpt-4o-mini',
      temperature: 0.8,
      systemPrompt: `You are a friendly sales representative for Acme Inc.
        Your goal is to schedule product demos with interested prospects.
        Be personable, handle objections gracefully, and focus on value.`
    },
    ttsSettings: {
      provider: 'elevenlabs',
      voiceId: 'adam'
    }
  });
  console.log(`Created assistant: ${assistant.name}`);

  // 2. Purchase and assign a phone number
  const available = await client.phoneNumbers.search({
    provider: 'twilio',
    countryCode: 'US',
    areaCode: '415'
  });

  if (available.length > 0) {
    const purchased = await client.phoneNumbers.purchase({
      phoneNumber: available[0].phoneNumber,
      provider: 'twilio',
      friendlyName: 'Sales Line'
    });
    
    await client.phoneNumbers.assign(purchased.id, { 
      assistantId: assistant.id 
    });
    console.log(`Assigned ${purchased.phoneNumber} to assistant`);
  }

  // 3. Upload product documentation
  const doc = await client.documents.uploadFromUrl({
    assistantId: assistant.id,
    url: 'https://acme.com/product-guide.pdf'
  });
  console.log(`Uploaded document: ${doc.filename}`);

  // 4. Create an outbound campaign
  const campaign = await client.campaigns.create({
    name: 'Q1 Outreach',
    assistantId: assistant.id,
    contacts: [
      { phoneNumber: '+14155551234', name: 'John Smith', variables: { company: 'TechCorp' }},
      { phoneNumber: '+14155555678', name: 'Jane Doe', variables: { company: 'StartupXYZ' }},
    ],
    settings: {
      maxConcurrentCalls: 2,
      callsPerMinute: 5
    }
  });
  console.log(`Created campaign: ${campaign.name}`);

  // 5. Start campaign and monitor progress
  await client.campaigns.start(campaign.id);
  console.log('Campaign started!');

  const stream = client.realtime.campaignProgress(campaign.id);
  await stream.connect();

  for await (const event of stream) {
    if (event.type === 'progress') {
      console.log(`Progress: ${event.completedContacts}/${event.totalContacts}`);
    } else if (event.type === 'contact_completed') {
      console.log(`Completed: ${event.phoneNumber} - ${event.outcome}`);
    } else if (event.type === 'campaign_completed') {
      console.log(`\nCampaign finished!`);
      console.log(`Success rate: ${event.successRate}%`);
      console.log(`Total calls: ${event.totalContacts}`);
      stream.disconnect();
      break;
    }
  }

  // 6. Export results
  const exportData = await client.calls.export({
    format: 'csv',
    assistantId: assistant.id
  });
  console.log('Exported call data');
}

main().catch(console.error);

Next Steps

Python SDK

Check out the Python SDK

Go SDK

Idiomatic Go SDK with channels

Real-time Streaming

Deep dive into WebSocket streaming

API Reference

Complete REST API documentation