@@ -126,6 +126,66 @@ However, it's likely that in your scenario you'll want to use the [Selective Sub
126126
127127</Tabs >
128128
129+ ### Multiple Agents in a Room
130+
131+ You can create multiple agents inside a single room by creating agents with the same room ID multiple times.
132+ Each agent operates independently, with its own set of tracks and callbacks.
133+
134+ <Tabs groupId = " language" >
135+ <TabItem value = " ts" label = " TypeScript" >
136+
137+ ``` ts
138+ import { FishjamClient } from ' @fishjam-cloud/js-server-sdk' ;
139+
140+ const fishjamId = ' ' ;
141+ const managementToken = ' ' ;
142+ const fishjamClient = new FishjamClient ({ fishjamId , managementToken });
143+ const room = await fishjamClient .createRoom ();
144+
145+ import type { AgentCallbacks , PeerOptions } from ' @fishjam-cloud/js-server-sdk' ;
146+
147+ const agentOptions = {
148+ subscribeMode: ' auto' ,
149+ output: { audioFormat: ' pcm16' , audioSampleRate: 16000 }
150+ } satisfies PeerOptions ;
151+
152+ const agentCallbacks = {
153+ onError: console .error ,
154+ onClose : (code , reason ) => console .log (' Agent closed' , code , reason )
155+ } satisfies AgentCallbacks ;
156+
157+ // ---cut---
158+ const agentCallbacks1 = {
159+ onError: console .error ,
160+ onClose : (code , reason ) => console .log (' Agent 1 closed' , code , reason )
161+ } satisfies AgentCallbacks ;
162+
163+ const agentCallbacks2 = {
164+ onError: console .error ,
165+ onClose : (code , reason ) => console .log (' Agent 2 closed' , code , reason )
166+ } satisfies AgentCallbacks ;
167+
168+ const { agent : agent1 } = await fishjamClient .createAgent (room .id , agentOptions , agentCallbacks1 );
169+ const { agent : agent2 } = await fishjamClient .createAgent (room .id , agentOptions , agentCallbacks2 );
170+ ```
171+
172+ </TabItem >
173+
174+ <TabItem value = " python" label = " Python" >
175+
176+ ``` python
177+ from fishjam import FishjamClient
178+
179+ fishjam_client = FishjamClient(fishjam_id, management_token)
180+
181+ agent1 = fishjam_client.create_agent(room_id)
182+ agent2 = fishjam_client.create_agent(room_id)
183+ ```
184+
185+ </TabItem >
186+
187+ </Tabs >
188+
129189### Making the Agent speak
130190
131191Apart from just listening, agents can also send audio data to peers.
0 commit comments