semvec/pypi-packages huggingface dataset:
streamstraight-python 0.1.0
Python server SDK for streaming data into Streamstraight.
License: MIT
Requires Python: >=3.10
Keywords: streaming, socket.io, websockets, sdk, llm, streamstraight

# Streamstraight Python SDK

`streamstraight-python` 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

```bash
uv add streamstraight-python
```

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

## Usage

```python
import asyncio
from streamstraight_python 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

```python
from streamstraight_python import fetch_client_token

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