Index of every page on this site: llms.txt
All skills
software-mansion-labs avatar

/python-server-sdk

@43cde80
Run it yourself

Python server SDK for Fishjam — backends that create rooms, mint peer tokens, receive server notifications, and run voice agents. Use when writing a Python backend (FastAPI, Flask, Starlette, aiohttp) that talks to Fishjam, decorates a notification handler, decodes a Fishjam webhook, builds an AI voice agent, or composes streams in Python. Trigger on: 'fishjam-server-sdk', 'pip install fishjam-server-sdk', 'from fishjam import', 'fishjam.FishjamClient', 'FishjamNotifier', 'on_server_notification', 'receive_binary', 'fishjam Agent', 'AgentSession', 'PeerOptions', 'RoomOptions', 'AgentOptions', 'AgentOutputOptions', 'OutgoingAudioTrackOptions', 'create_room', 'create_peer', 'create_agent', 'create_vapi_agent', 'create_livestream_streamer_token', 'create_moq_token', 'subscribe_peer', 'fastapi fishjam', 'flask fishjam', 'fishjam python', 'gemini fishjam python', 'CompositionClient', 'forward_room_tracks'. Python 3.10+. The REST client is synchronous; notifier and agent are async.

  • 10 files
  • 55.7 KB
  • Apache-2
  • Updated last month
  • GitHub
Use this Skill: https://skilld.dev/gh/software-mansion-labs/skills/python-server-sdk

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

selective-subscriptions.md

≈797 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Selective Subscriptions (Python)

By default, every peer is subscribed to every other peer (subscribe_mode='auto' on PeerOptions). For large or scene-controlled rooms, enable manual subscriptions: peers receive nothing until your backend explicitly subscribes them.

Use cases:

  • Audience-style rooms (50 listeners + 1 speaker): subscribe everyone to the speaker, no one to the audience members.
  • Spotlight / presenter mode.
  • Server-side AI agents that should only receive the active speaker's audio.
  • Privacy isolation between sub-groups.

Enabling

Manual mode is configured per peer in this SDK:

from fishjam import PeerOptions

peer, token = fishjam_client.create_peer(
    room.id,
    PeerOptions(subscribe_mode='manual'),
)

Once a peer is created with subscribe_mode='manual', it receives nothing until you explicitly subscribe it. Mix peers with different subscribe modes in the same room — each peer's policy is its own.

Subscribing a peer to all of another peer's tracks

fishjam_client.subscribe_peer(
    room_id=room.id,
    peer_id=subscriber_peer_id,
    target_peer_id=publisher_peer_id,
)

The subscriber receives every current and future track from the target. No unsubscribe API — to "unsubscribe", remove the publisher's tracks or design with explicit re-subscribe.

Subscribing to specific tracks only

fishjam_client.subscribe_tracks(
    room_id=room.id,
    peer_id=subscriber_peer_id,
    track_ids=[track_id_1, track_id_2],
)

Use when you want a peer's audio but not their video, the screen share but not the camera, etc.

Typical pattern: spotlight

# When a new peer connects, subscribe them to the current presenter only.
# (Handled in a webhook or notifier.)

async def on_peer_connected(room_id: str, peer_id: str, peer_type: str):
    if peer_id == presenter_peer_id:
        return  # presenter doesn't subscribe to listeners
    fishjam_client.subscribe_peer(
        room_id=room_id,
        peer_id=peer_id,
        target_peer_id=presenter_peer_id,
    )

Typical pattern: AI agent subscribed only to active speaker

# When VAD reports a new active speaker, switch the agent's subscription.

def switch_agent_to_speaker(new_speaker_peer_id: str):
    # `t.type_` is a TrackType enum from the generated OpenAPI client.
    # No public re-export exists today, so either compare against the string
    # value, or import from the private path (subject to change between SDK
    # releases):
    #   from fishjam._openapi_client.models.track_type import TrackType

    room = fishjam_client.get_room(room_id)
    speaker = next(p for p in room.peers if p.id == new_speaker_peer_id)
    audio_track = next(t for t in speaker.tracks if t.type_ == "audio")

    fishjam_client.subscribe_tracks(
        room_id=room_id,
        peer_id=agent_peer_id,
        track_ids=[audio_track.id],
    )

Sources

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 43cde80. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated last month

README badge

README badge for software-mansion-labs/skills/python-server-sdk