Skip to content

Commit 7652216

Browse files
mshehrozsajjadnbsp
andauthored
Add Beyond Presence (Bey) plugin (#759)
Co-authored-by: aoife cassidy <[email protected]>
1 parent 5358bb8 commit 7652216

File tree

14 files changed

+520
-0
lines changed

14 files changed

+520
-0
lines changed

.changeset/add-bey-plugin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@livekit/agents-plugin-bey': major
3+
---
4+
5+
Add Beyond Presence (Bey) plugin for LiveKit agents

examples/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"dependencies": {
2424
"@livekit/agents": "workspace:*",
2525
"@livekit/agents-plugin-anam": "workspace:*",
26+
"@livekit/agents-plugin-bey": "workspace:*",
2627
"@livekit/agents-plugin-cartesia": "workspace:*",
2728
"@livekit/agents-plugin-deepgram": "workspace:*",
2829
"@livekit/agents-plugin-elevenlabs": "workspace:*",

examples/src/bey_avatar.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// SPDX-FileCopyrightText: 2025 LiveKit, Inc.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
import { type JobContext, WorkerOptions, cli, defineAgent, metrics, voice } from '@livekit/agents';
5+
import * as bey from '@livekit/agents-plugin-bey';
6+
import * as openai from '@livekit/agents-plugin-openai';
7+
import { fileURLToPath } from 'node:url';
8+
9+
export default defineAgent({
10+
entry: async (ctx: JobContext) => {
11+
const agent = new voice.Agent({
12+
instructions: 'You are a helpful assistant. Speak clearly and concisely.',
13+
});
14+
15+
const session = new voice.AgentSession({
16+
llm: new openai.realtime.RealtimeModel({
17+
voice: 'alloy',
18+
}),
19+
});
20+
21+
await ctx.connect();
22+
23+
await session.start({
24+
agent,
25+
room: ctx.room,
26+
});
27+
28+
const avatarId = process.env.BEY_AVATAR_ID;
29+
30+
const avatar = new bey.AvatarSession({
31+
avatarId: avatarId || undefined,
32+
});
33+
await avatar.start(session, ctx.room);
34+
35+
const usageCollector = new metrics.UsageCollector();
36+
37+
session.on(voice.AgentSessionEventTypes.MetricsCollected, (ev) => {
38+
metrics.logMetrics(ev.metrics);
39+
usageCollector.collect(ev.metrics);
40+
});
41+
42+
session.generateReply({
43+
instructions: 'Greet the user briefly and confirm you are ready.',
44+
});
45+
},
46+
});
47+
48+
cli.runApp(new WorkerOptions({ agent: fileURLToPath(import.meta.url) }));

plugins/bey/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# @livekit/agents-plugin-bey
2+
3+
## 0.0.1
4+
5+
### Major Changes
6+
7+
- Add Beyond Presence (Bey) plugin for LiveKit agents
8+
9+
### Patch Changes
10+
11+
- Updated dependencies:
12+
- @livekit/agents@1.0.9

plugins/bey/README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2025 LiveKit, Inc.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
-->
6+
7+
# Beyond Presence plugin for LiveKit Agents
8+
9+
Support for [Beyond Presence](https://docs.bey.dev) virtual avatars.
10+
11+
See [https://docs.livekit.io/agents/integrations/avatar/bey/](https://docs.livekit.io/agents/integrations/avatar/bey/) for more information.
12+
13+
## Installation
14+
15+
```bash
16+
npm install @livekit/agents-plugin-bey
17+
```
18+
19+
or
20+
21+
```bash
22+
pnpm add @livekit/agents-plugin-bey
23+
```
24+
25+
## Pre-requisites
26+
27+
Create a developer API key from the [creator dashboard](https://app.bey.chat) and set the `BEY_API_KEY` environment variable with it:
28+
29+
```bash
30+
export BEY_API_KEY=<your-bey-api-key>
31+
```
32+
33+
## Usage
34+
35+
```typescript
36+
import { AvatarSession } from '@livekit/agents-plugin-bey';
37+
import { AgentSession } from '@livekit/agents';
38+
39+
// Create an avatar session
40+
const avatarSession = new AvatarSession({
41+
avatarId: 'your-avatar-id', // optional, defaults to stock avatar
42+
apiKey: process.env.BEY_API_KEY, // optional if set via env var
43+
});
44+
45+
// Start the avatar in your agent
46+
await avatarSession.start(agentSession, room, {
47+
livekitUrl: process.env.LIVEKIT_URL,
48+
livekitApiKey: process.env.LIVEKIT_API_KEY,
49+
livekitApiSecret: process.env.LIVEKIT_API_SECRET,
50+
});
51+
```
52+
53+
## API
54+
55+
### `AvatarSession`
56+
57+
Creates a new Beyond Presence avatar session.
58+
59+
#### Constructor Options
60+
61+
- `avatarId?: string` - The avatar ID to use. Defaults to stock avatar.
62+
- `apiUrl?: string` - The Bey API URL. Defaults to `https://api.bey.dev`.
63+
- `apiKey?: string` - Your Bey API key. Can also be set via `BEY_API_KEY` environment variable.
64+
- `avatarParticipantIdentity?: string` - The identity for the avatar participant. Defaults to `'bey-avatar-agent'`.
65+
- `avatarParticipantName?: string` - The name for the avatar participant. Defaults to `'bey-avatar-agent'`.
66+
- `connOptions?: APIConnectOptions` - Connection options for retry logic.
67+
68+
#### Methods
69+
70+
##### `start(agentSession: AgentSession, room: Room, options?: StartOptions): Promise<void>`
71+
72+
Starts the avatar session and connects it to the room.
73+
74+
**Options:**
75+
- `livekitUrl?: string` - The LiveKit server URL. Can also be set via `LIVEKIT_URL` environment variable.
76+
- `livekitApiKey?: string` - Your LiveKit API key. Can also be set via `LIVEKIT_API_KEY` environment variable.
77+
- `livekitApiSecret?: string` - Your LiveKit API secret. Can also be set via `LIVEKIT_API_SECRET` environment variable.
78+
79+
## License
80+
81+
Apache 2.0

plugins/bey/package.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "@livekit/agents-plugin-bey",
3+
"version": "0.0.1",
4+
"description": "Beyond Presence plugin for LiveKit Node Agents",
5+
"main": "dist/index.js",
6+
"require": "dist/index.cjs",
7+
"types": "dist/index.d.ts",
8+
"exports": {
9+
"import": {
10+
"types": "./dist/index.d.ts",
11+
"default": "./dist/index.js"
12+
},
13+
"require": {
14+
"types": "./dist/index.d.cts",
15+
"default": "./dist/index.cjs"
16+
}
17+
},
18+
"author": "LiveKit",
19+
"type": "module",
20+
"repository": "[email protected]:livekit/agents-js.git",
21+
"license": "Apache-2.0",
22+
"files": [
23+
"dist",
24+
"src",
25+
"README.md"
26+
],
27+
"scripts": {
28+
"build": "tsup --onSuccess \"pnpm build:types\"",
29+
"build:types": "tsc --declaration --emitDeclarationOnly && node ../../scripts/copyDeclarationOutput.js",
30+
"clean": "rm -rf dist",
31+
"clean:build": "pnpm clean && pnpm build",
32+
"lint": "eslint -f unix \"src/**/*.{ts,js}\"",
33+
"api:check": "api-extractor run --typescript-compiler-folder ../../node_modules/typescript",
34+
"api:update": "api-extractor run --local --typescript-compiler-folder ../../node_modules/typescript --verbose"
35+
},
36+
"devDependencies": {
37+
"@livekit/agents": "workspace:*",
38+
"@livekit/rtc-node": "^0.13.12",
39+
"@microsoft/api-extractor": "^7.35.0",
40+
"pino": "^8.19.0",
41+
"tsup": "^8.3.5",
42+
"typescript": "^5.0.0"
43+
},
44+
"dependencies": {
45+
"livekit-server-sdk": "^2.13.3"
46+
},
47+
"peerDependencies": {
48+
"@livekit/agents": "workspace:*",
49+
"@livekit/rtc-node": "^0.13.12"
50+
}
51+
}

0 commit comments

Comments
 (0)