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.

gemini-integration.md

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

Gemini Live Integration (Python)

Source: fishjam/integrations/gemini.py in fishjam-server-sdk.

The integration is shipped as an optional extra — install with:

pip install 'fishjam-server-sdk[gemini]'

Importing without the extra raises an ImportError directing you to install it.

What the helper provides

A singleton instance GeminiIntegration:

from fishjam.integrations.gemini import GeminiIntegration

With these members:

Member What it is
GeminiIntegration.create_client(api_key=..., http_options=..., ...) Returns a configured google.genai.Client with an x-goog-api-client: fishjam-python-server-sdk/<version> header injected. Mirrors genai.Client(...) constructor args.
GeminiIntegration.GEMINI_INPUT_AUDIO_SETTINGS AgentOutputOptions(audio_format='pcm16', audio_sample_rate=16000) — pass to AgentOptions.output so other peers' audio is downmixed for Gemini.
GeminiIntegration.GEMINI_OUTPUT_AUDIO_SETTINGS OutgoingAudioTrackOptions(encoding=TRACK_ENCODING_PCM16, sample_rate=24000, channels=1) — pass to session.add_track(...) so Gemini's TTS output flows back into the room.
GeminiIntegration.GEMINI_AUDIO_MIME_TYPE 'audio/pcm;rate=16000' — attach to audio chunks sent to Gemini.

End-to-end pattern

import asyncio
import os
from fishjam import AgentOptions, FishjamClient
from fishjam.integrations.gemini import GeminiIntegration
from fishjam.events._protos.fishjam import AgentResponseTrackData as IncomingTrackData
from google.genai import types

fishjam_client = FishjamClient(fishjam_id=..., management_token=...)
genai_client = GeminiIntegration.create_client(api_key=os.environ['GEMINI_API_KEY'])

async def spawn_gemini_agent(room_id: str):
    agent = fishjam_client.create_agent(
        room_id,
        AgentOptions(output=GeminiIntegration.GEMINI_INPUT_AUDIO_SETTINGS),
    )

    async with agent.connect() as session:
        # Gemini -> Fishjam track
        gemini_track = await session.add_track(GeminiIntegration.GEMINI_OUTPUT_AUDIO_SETTINGS)

        # Open Gemini Live session
        async with genai_client.aio.live.connect(
            model='gemini-2.5-flash-native-audio-preview-12-2025',
            config=types.LiveConnectConfig(
                response_modalities=[types.Modality.AUDIO],
                system_instruction='You are a helpful assistant.',
            ),
        ) as gemini_session:

            async def fishjam_to_gemini():
                async for msg in session.receive():
                    if isinstance(msg, IncomingTrackData):
                        await gemini_session.send_realtime_input(
                            audio=types.Blob(
                                data=msg.data,
                                mime_type=GeminiIntegration.GEMINI_AUDIO_MIME_TYPE,
                            )
                        )

            async def gemini_to_fishjam():
                async for response in gemini_session.receive():
                    if response.data:
                        await gemini_track.send_chunk(response.data)

            await asyncio.gather(fishjam_to_gemini(), gemini_to_fishjam())

asyncio.run(spawn_gemini_agent('room-123'))

When to use the helper

  • Use for the canonical 16kHz-in / 24kHz-out Gemini Live flow. Saves you from picking codec parameters wrong.
  • Skip if you want a different model, different audio formats, or only text — import google.genai directly.

Multimodal: image capture for visual prompting

await session.capture_image(track_id=peer_video_track_id)
# response arrives as IncomingTrackImage via session.receive()
# forward to Gemini as a `types.Blob` with mime_type='image/jpeg'

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