Pipecat Base Transport for RealTime WebSocket APIs Package
npm install @pipecat-ai/websocket-transport
!NPM Version
Websocket transport package for use with @pipecat-ai/client-js.
``bash copy`
npm install \
@pipecat-ai/client-js \
@pipecat-ai/websocket-transport
The WebSocketTransport class provides a Websocket transport layer establishing a connection with Pipecat WebSocketTransport. It handles audio device management and real-time communication between client and bot.
- 🎤 Microphone input handling
- 🤖 Bot participant tracking
- 💬 Real-time messaging
`javascript
import { PipecatClient } from "@pipecat-ai/client-js";
import { WebSocketTransport } from "@pipecat-ai/websocket-transport";
const pcClient = new PipecatClient({
transport: new WebSocketTransport(),
enableMic: true, // Default microphone on
callbacks: {
// Event handlers
},
});
pcClient.connect({
ws_url: 'https://your.websocket/endpoint'
});
// OR...
pcClient.connect({
endpoint: 'https://your-server/connect', // endpoint to return ws_url
});
``
The transport can be in one of these states:
- "initializing"
- "initialized"
- "connecting"
- "connected"
- "ready"
- "disconnecting"
- "error"
The transport implements the various Pipecat event handlers. Check out the docs or samples for more info.
The transport includes error handling for:
- Connection failures
- Device errors