Skip to main content

Python server SDK for streaming data into Streamstraight.

Project description

Streamstraight Python SDK

streamstraight-server mirrors the @streamstraight/server Node SDK for producers who prefer Python. It connects to Streamstraight over Socket.IO, manages chunk acknowledgements, and exposes helpers for minting client JWTs.

Quickstart

uv add streamstraight-server

For local development inside this monorepo, run uv sync --all-extras from packages/python.

Usage

import asyncio
from streamstraight_server import streamstraight_server

async def main() -> None:
    server = await streamstraight_server(
        {"api_key": "YOUR_STREAMSTRAIGHT_API_KEY"},
        {"stream_id": "your-stream-id"},
    )

    async def generate():
        # Replace with your LLM or other async generator
        yield {"content": "first chunk"}
        yield {"content": "second chunk"}

    await server.stream(generate())

asyncio.run(main())

Mint a client JWT for your browser client

from streamstraight_server import fetch_client_token

token = await fetch_client_token({"api_key": "YOUR_STREAMSTRAIGHT_API_KEY"})

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamstraight_server-0.1.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamstraight_server-0.1.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file streamstraight_server-0.1.0.tar.gz.

File metadata

  • Download URL: streamstraight_server-0.1.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for streamstraight_server-0.1.0.tar.gz
Algorithm Hash digest
SHA256 08fbf5cfddea2317232e0610270f87c16853e6e3d76a9a82df3655292da61829
MD5 c61dbc500036daf557d2681bfe44f9c8
BLAKE2b-256 4f7a44e7478dc42969fe4125b04c34553b941c22ec93ecdd0dc7378ca842d68b

See more details on using hashes here.

File details

Details for the file streamstraight_server-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamstraight_server-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 489940918ad4d417a24f657b9904e5c746c4ed721bec98ea291491974322fcce
MD5 911a4baf552cd15b98d3378f6278e856
BLAKE2b-256 785f65aa91104b0ac5d0657f2334e7ac888224f0020f043b8bbcfd044d704549

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page