Skip to main content

appsocom (Python)

Python server SDK for Appsocom Live: mint join tokens, manage rooms and participants, moderate and verify webhooks. Python 3.9+, standard library only.

pip install appsocom
import os
from appsocom import SfuKit, SfuKitError, verify_webhook

kit = SfuKit("https://api.appsocom.dev", os.environ["APPSOCOM_API_KEY"])  # project API key from the console

tok = kit.create_token("class-1", "u_7", name="Ada", role="student", metadata={"seat": 3})
tok["token"], tok["expiresAt"]

kit.set_role("class-1", "u_9", "student")             # promote an observer
kit.mute("class-1", "*", ["mic"], lock=True)          # mute everyone, keep them muted
kit.set_room_metadata("class-1", {"topic": "Fractions"})
kit.set_track_permissions("class-1", "u_7", {"allowAll": False, "allow": [{"userId": "u_1"}]})
kit.remove_participant("class-1", "u_8", ban=True)

Errors raise SfuKitError with .status and .body.

Webhooks (Flask):

@app.post("/appsocom-webhooks")
def hook():
    event = verify_webhook(os.environ["APPSOCOM_WEBHOOK_SECRET"], request.get_data(), request.headers.get("X-SfuKit-Signature"))
    if event is None:
        return "", 401
    print(event["event"], event["roomId"])
    return "", 204

AI assistant

Tell the assistant about your app once, mint a token for each signed-in person, and answer its tool calls at your toolsUrl:

from appsocom import AssistantToolError, assistant_tools

kit.set_assistant_config({
    "name": "Ada",
    "toolsUrl": "https://app.example/assistant-tools",
    "tools": [{"name": "list_students", "description": "Students in a class", "parameters": {"type": "object", "properties": {"cls": {"type": "string"}}}}],
    "appMap": [{"label": "Fees", "path": "/fees", "aliases": ["bursary"]}],
})
tok = kit.create_assistant_token(user.id, name=user.name, role=user.role, metadata={"school": user.school_id})
# give tok["token"] to the browser (@appsocom/react <AssistantPanel>)

def list_students(args, call):  # runs as the person who asked
    if call["role"] != "teacher":
        raise AssistantToolError("Only teachers can list students.")  # the model sees this message
    return db.students(call["metadata"]["school"], args["cls"])

tools = assistant_tools(os.environ["APPSOCOM_WEBHOOK_SECRET"], {"list_students": list_students})

@app.post("/assistant-tools")
def assistant_tools_route():
    status, body = tools.handle(request.get_data(), request.headers.get("X-SfuKit-Signature"))
    return body, status, {"Content-Type": "application/json"}

handle() refuses bad or stale signatures with 401, answers {"result": ...} ("done" when a tool returns None) or {"error": ...}, and hides any exception other than AssistantToolError as "The tool failed." (pass on_error= to see it). Also: get_assistant_config, delete_assistant_conversation(user_id, conversation_id), verify_assistant_tool_call.

AI Tasks, Speech and Videos

# AI Tasks: one Claude call from your server (a ready-made task, or your own prompt)
marked = kit.ai_task("mark", {"question": q, "answer": a, "rubric": rubric, "maxScore": 10}, user=student_id)
marked["json"]["score"], marked["usage"]["credits"]
draft = kit.ai_complete("Write a two-line welcome for new parents.", tier="standard")
data = kit.ai_complete("List the dates in this letter: ...", json={"type": "object", "properties": {"dates": {"type": "array"}}})
with kit.ai_stream("Tell a short story.") as story:
    for piece in story:
        print(piece, end="")
    story.usage  # model, tokens, cost, credits

# Speech
audio = kit.text_to_speech("Well done!", language="en")                  # mp3 bytes
link = kit.text_to_speech_url("Ẹ káàárọ̀", language="yo", expires_in=3600)  # link["url"] plays without your key
heard = kit.speech_to_text(recording_bytes, content_type="audio/webm", language="ha")  # heard["text"]

# Videos: an upload link for a browser, or send a file from your server
upload = kit.create_video_upload(3600, name="Lesson 1", upload_length=size)
kit.upload_video_file(upload, open("lesson.mp4", "rb"))
links = kit.video_playback(upload["videoId"])  # links["hls"], links["iframe"], links["thumbnail"]

ai_complete and ai_task return the API's answer as a dict (text, json, usage); a call the kit refuses (daily limit, no credit) raises SfuKitError with the status, and ai_stream raises it at once. Settings and reports: get_ai_settings, set_ai_settings, get_ai_usage(days), get_ai_audit(day, user), get_speech_usage, set_speech_daily_budget, get_video_usage. Videos: copy_video, list_videos, get_video, update_video, delete_video. See AI Tasks, Speech and Videos.

All methods: create_token, get_room, list_participants, update_room, set_room_metadata, lock_room, close_room, update_participant, set_permissions, set_role, set_participant_metadata, set_track_permissions, remove_participant, unban, mute, admit, post_chat, lower_hands, get_attendance, get_attendance_csv, clear_attendance, start_breakouts, end_breakouts, move_to_group, set_assistant_config, get_assistant_config, create_assistant_token, delete_assistant_conversation, ai_complete, ai_task, ai_stream, get_ai_settings, set_ai_settings, get_ai_usage, get_ai_audit, text_to_speech, text_to_speech_url, speech_to_text, get_speech_usage, set_speech_daily_budget, create_video_upload, upload_video_file, copy_video, list_videos, get_video, update_video, delete_video, video_playback, get_video_usage, health, request(). Standalone: sign_token, verify_webhook, sign_webhook, assistant_tools, verify_assistant_tool_call.

Self-hosting your own deployment instead? Point url at it and pass its admin key; the optional jwt_secret signs tokens locally without an HTTP call.

Docs: docs.appsocom.dev · License: MIT

Metadata

Release files for appsocom 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for appsocom 0.10.0
File Size Uploaded Provenance Actions
appsocom-0.10.0.tar.gz 30.2 kB With provenance Details for appsocom-0.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for appsocom 0.10.0
File Interpreter ABI Platform Actions
appsocom-0.10.0-py3-none-any.whl Python 3 none any Details for appsocom-0.10.0-py3-none-any.whl

Total release size: 51.1 kB

Release files / appsocom-0.10.0.tar.gz

Download URL appsocom-0.10.0.tar.gz
Size 30.2 kB
Tags Source
SHA-256 checksum
How to use checksums
09c90e2413d812cabb3580c6c9750235db9e075be85aa86653985f21bf431eaf
BLAKE2b-256 checksum
How to use checksums
0ee2a9a3f364a1528b96145caa01788589cdaec5265ad5fbe269a02670750b92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / appsocom-0.10.0-py3-none-any.whl

Download URL appsocom-0.10.0-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
126266153c6b6fff812e7ea97e307f2669363dd5548425cc54115c914295b9a7
BLAKE2b-256 checksum
How to use checksums
b770f402f58c61a1ba6f479b53e5b65875a08780a86e1d2acb5001f26d42a887
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Security for appsocom 0.10.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for appsocom-0.10.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page