npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@krosai/voice-sdk

v0.1.0

Published

Connect any WebRTC voice agent to phone numbers in minutes

Downloads

24

Readme

@krosai/voice-sdk

Connect any WebRTC voice agent to phone numbers in minutes. Turn your AI voice agent into a phone agent with just 10 lines of code.

Installation

npm install @krosai/voice-sdk

Quick Start

import { KrosAI } from '@krosai/voice-sdk';

// Initialize with your API key from https://app.krosai.com/developers
const krosai = new KrosAI({ apiKey: 'kros_live_...' });

// Connect your agent's audio to a phone number
const call = await krosai.call({
  phoneNumber: '+14155551234',
  audio: myAgentMediaStream, // Your agent's audio output
});

// Handle events
call.on('connected', () => {
  console.log('Call connected!');
});

call.on('remoteAudio', (stream) => {
  // Feed phone audio to your agent
  myAgent.setInputAudio(stream);
});

call.on('ended', (reason) => {
  console.log('Call ended:', reason);
});

// Control the call
call.mute();    // Mute your agent
call.unmute();  // Unmute your agent
call.hangup();  // End the call

Features

  • 10 lines to integrate - No SIP, no WebRTC complexity
  • Any WebRTC agent - Works with ElevenLabs, custom agents, any MediaStream
  • Full audio control - Mute, unmute, audio levels, remote stream access
  • Event-driven - Status changes, transcripts, errors
  • TypeScript-first - Full type definitions included

Integrations

ElevenLabs

import { KrosAI } from '@krosai/voice-sdk';
import { useConversation } from '@elevenlabs/react';

function PhoneAgent() {
  const krosai = new KrosAI({ apiKey: 'kros_live_...' });
  const conversation = useConversation({ agentId: 'your-agent-id' });

  async function connectToPhone(phoneNumber: string) {
    // Start ElevenLabs conversation
    await conversation.startSession();

    // Connect to phone
    const call = await krosai.call({
      phoneNumber,
      audio: conversation.getAudioStream(),
    });

    // Feed phone audio back to ElevenLabs
    conversation.setInputAudio(call.getRemoteStream());

    call.on('ended', () => conversation.endSession());
  }

  return (
    <button onClick={() => connectToPhone('+14155551234')}>
      Connect Agent to Phone
    </button>
  );
}

Custom MediaStream

import { KrosAI } from '@krosai/voice-sdk';

const krosai = new KrosAI({ apiKey: 'kros_live_...' });

// Get audio from any source
const audioContext = new AudioContext();
const destination = audioContext.createMediaStreamDestination();
const agentStream = destination.stream;

// Connect to phone
const call = await krosai.call({
  phoneNumber: '+14155551234',
  audio: agentStream,
});

// Get phone audio for your agent
const phoneAudio = call.getRemoteStream();

API Reference

KrosAI

Main SDK client.

const krosai = new KrosAI({
  apiKey: string,      // Required: Your KrosAI API key
  baseUrl?: string,    // Optional: API base URL
  debug?: boolean,     // Optional: Enable debug logging
});

krosai.call(options)

Initiate an outbound call.

const call = await krosai.call({
  phoneNumber: string,            // E.164 format (+14155551234)
  audio: MediaStream | AudioSource, // Your agent's audio
  metadata?: Record<string, string>, // Optional: Custom metadata
});

CallSession

Returned by call(). Provides call control and events.

Properties:

  • id: string - Unique call ID
  • phoneNumber: string - Phone number being called
  • status: CallStatus - Current call status
  • duration: number - Call duration in seconds
  • inputLevel: number - Your agent's audio level (0-1)
  • outputLevel: number - Phone audio level (0-1)
  • isMuted: boolean - Whether your agent is muted

Methods:

  • mute() - Mute your agent's audio
  • unmute() - Unmute your agent's audio
  • hangup() - End the call
  • getRemoteStream() - Get phone audio MediaStream

Events:

  • statusChange(status) - Call status changed
  • audioLevel(input, output) - Audio levels updated
  • remoteAudio(stream) - Phone audio stream available
  • transcript(text, isFinal) - Transcript received
  • error(error) - Error occurred
  • ended(reason) - Call ended

Call Status Flow

initializing → connecting → ringing → connected → ended
                    ↓           ↓          ↓
                 failed      failed     failed

Error Handling

import { KrosAIError } from '@krosai/voice-sdk';

try {
  const call = await krosai.call({ ... });
} catch (error) {
  if (error instanceof KrosAIError) {
    switch (error.code) {
      case 'INVALID_API_KEY':
        // Handle invalid API key
        break;
      case 'RATE_LIMIT_EXCEEDED':
        // Handle rate limit
        break;
      case 'INSUFFICIENT_BALANCE':
        // Handle low balance
        break;
      // ... other error codes
    }
  }
}

Getting an API Key

  1. Go to app.krosai.com/developers
  2. Click "Create API Key"
  3. Select the "Voice SDK" scope
  4. Copy your API key (starts with kros_live_ or kros_test_)

Requirements

  • Browser with WebRTC support
  • A KrosAI account with phone numbers
  • API key with voice:connect scope

Support

License

MIT