Skip to content
Beam Docs
Media

Server-side Participants

Bots, recorders, transcribers and AI voice agents join calls and stages from Go or Python with the same tokens as browsers.

A server process can take part in a call or a stage exactly like a browser: it gets a media token from your backend, joins through the directory, connects to the same SFU, receives participant and speaker events, and decrypts and encrypts frames with the same SFrame keys. Use it for:

  • transcription and captions: subscribe to every microphone and send text back through your own channel;
  • live translation and AI voice agents: listen to a speaker and publish synthesized audio as a participant;
  • recorders and moderation: receive the tracks and store or inspect them.

Nothing is special about such a participant on Beam's side: it is one identity with its own token, billed like any participant.


Packages

LanguagePackageWebRTC stack
Gogithub.com/Beam-Network/beam-sdk-public/sdks/go/media/participantPion
Pythonbeam-network-sdk[media-rtc], module beam_network_sdk.media.participantaiortc

Both receive encoded frames, or decoded PCM audio and I420 video, and publish either. Raw codecs in Go are optional cgo packages (codec/opus, codec/vp8).

A voice agent in Python

import asyncio, os
from beam_network_sdk.media import CustomerKeyProvider
from beam_network_sdk.media.participant import (
    AudioFrameData, AudioOptions, Participant, ParticipantConfig, SubscriptionFilter, static_token,
)

async def main(token: str) -> None:
    tokens = static_token(token)
    participant = await Participant.connect(ParticipantConfig(
        directory_url=os.environ["BEAM_MEDIA_DIRECTORY_URL"],
        token=tokens,
        # e2ee sessions with key_provider "customer": your backend's key URL.
        key_provider=CustomerKeyProvider(os.environ["BEAM_MEDIA_KEY_URL"], tokens),
    ))
    speaker = (await participant.publish(audio=AudioOptions())).audio

    @participant.on("audio_frame")
    async def heard(frame: AudioFrameData) -> None:
        reply = await my_agent.listen(frame.info.identity, frame.pcm, frame.sample_rate)  # your pipeline
        if reply is not None:
            await speaker.write_pcm(reply, sample_rate=24000, channels=1)

    participant.subscribe_all(SubscriptionFilter(kinds=("audio",)))
    await participant.wait_closed()

asyncio.run(main(token_from_your_backend()))

A recorder in Go

import "github.com/Beam-Network/beam-sdk-public/sdks/go/media/participant"

tokens := participant.StaticToken(token)
bot, err := participant.Connect(ctx, participant.Config{
	DirectoryURL: os.Getenv("BEAM_MEDIA_DIRECTORY_URL"),
	Token:        tokens,
	KeyProvider:  participant.CustomerKeyURL(os.Getenv("BEAM_MEDIA_KEY_URL"), tokens, nil),
	Handlers: participant.Handlers{
		OnEncodedFrame: func(frame participant.EncodedFrame) {
			writeFrame(frame) // Opus / VP8 frames, already decrypted
		},
	},
})
if err != nil {
	return err
}
defer bot.Close()
bot.SubscribeAll(participant.SubscriptionFilter{})
<-bot.Done()

The beam-sdk repository has complete examples: transcription, live translation, a voice agent and a recorder, each also packaged as a Beam action for a GPU Worker.


Rules that apply

  • Token: mint a publish token for an agent that speaks, a subscribe token for one that only listens. Give it an identity that says what it is (for example bot-transcriber) and a name participants will see.
  • Encryption: in an e2ee session the process needs the key document like any participant, from your key endpoint, and gets its own sender pair. Your backend should give server participants keys only for sessions they are meant to join; they then see the plaintext, by design.
  • Codecs: publish Opus audio, and VP8 video in end-to-end encrypted sessions.
  • Where it runs: on your own servers, or as a Beam action on a GPU Worker when it needs a model. Either way it reaches the session through the directory, not through a private path.

Decentralized distributed bandwidth infrastructure.

On this page