Livepeer Python SDK
The official Python SDK for the Livepeer network. Submit AI and video compute jobs directly to orchestrators, use a remote signer for payment, and stream media and control data over Livepeer's trickle protocol.
Requirements
- Python 3.12 or newer
Installation
Install the stable release from PyPI:
python -m pip install livepeer-gateway
The import package is named livepeer_gateway:
from livepeer_gateway import StartJobRequest, start_lv2v
Development
Install the locked development dependencies with uv:
uv sync --locked --group test
Generate protobufs after installing the code-generation extra:
uv sync --extra dev
uv run generate-lp-rpc
Tests
Install the locked test dependencies and run the complete pytest suite:
uv sync --locked --group test
uv run --group test pytest
Pass a test file or node ID to pytest for a focused run:
uv run --group test pytest tests/test_live_runner.py
uv run --group test pytest tests/test_live_runner.py::TestLiveRunnerHelpers::test_parse_go_duration
Run the suite with the configured line and branch coverage:
uv run --group test pytest --cov=livepeer_gateway --cov-branch --cov-report=term-missing
Usage Examples
First install dependencies for example code
uv sync --extra examples
Get orchestrator info, offchain mode
uv run examples/get_orchestrator_info.py localhost:8935
On-chain mode with a remote signer
uv run examples/get_orchestrator_info.py --signer "<signer-host:port>"
# Use a custom discovery endpoint to filter orchestrators
uv run examples/get_orchestrator_info.py --signer "<signer-host:port>" '<discovery-host>/discover-orchestrators?cap=streamdiffusion-sdxl-v2v'
Get orchestrator info using a token encoding signer / discovery parameters
uv run examples/get_orchestrator_info.py --token "<base64-token>"
Write raw frames to a LiveVideoToVideo job
uv run examples/write_frames.py localhost:8935
Capture MacOS camera frames and publish via write_frame
uv run examples/camera_capture.py localhost:8935
Capture MacOS camera frames and subscribe to media output (stdout or file)
uv run examples/camera_capture.py localhost:8935 --output - | ffplay -fflags nobuffer -flags low_delay -probesize 32 -i -
uv run examples/camera_capture.py localhost:8935 --output out.ts
Read demuxed media output packets without decoding
async with job.media_output() as output:
async for packet in output.packets():
print(packet.kind, packet.stream_index, packet.pts_time, packet.size)
Composite camera input and decoded output side-by-side with PTS delta
uv sync --extra examples
uv run examples/in_out_composite.py localhost:8935
Subscribe to a LiveVideoToVideo trickle events channel
uv run examples/subscribe_events.py localhost:8935
Start a LiveVideoToVideo job using a token (base64 JSON)
import base64
import json
from livepeer_gateway.lv2v import StartJobRequest, start_lv2v
payload = {
"orchestrators": [
"https://orch-1.example.com:8935",
"https://orch-2.example.com:8935",
],
"signer": "https://signer.example.com",
"signer_headers": {"Authorization": "Bearer abcdef"},
"discovery": "https://discovery.example.com",
"discovery_headers": {"Authorization": "Bearer qwerty"},
}
token = base64.b64encode(json.dumps(payload).encode("utf-8")).decode("utf-8")
job = start_lv2v(
orch_url=None,
req=StartJobRequest(model_id="noop"),
token=token,
timeout=5.0, # timeout for the initial /live-video-to-video request
# signer_url="https://fallback-signer.example.com", # used only if token omits signer
)
Token schema (base64-encoded JSON object)
| Field | Type | Description |
|---|---|---|
orchestrators |
string[] (optional) |
Ordered orchestrator addresses to try before discovery |
signer |
string (optional) |
Signer base URL |
signer_headers |
{"key": "value"} (optional) |
Extra HTTP headers sent to all signer endpoints |
discovery |
string (optional) |
Discovery endpoint URL |
discovery_headers |
{"key": "value"} (optional) |
Extra HTTP headers sent to the discovery endpoint |
Token values take precedence over explicit keyword arguments. Explicit keyword arguments are used only for fields missing in the token.
For token payloads, orchestrators must be a JSON array of non-empty strings.
Comma-delimited string format is not supported in the token.
Selection/discovery precedence (highest -> lowest):
- token
orchestrators - explicit
orch_url - token
discovery - explicit
discovery_url - signer-derived discovery endpoint
signer_headers are sent with requests to the signer service. discovery_headers are only used when an explicit discovery_url is provided (and not when using the signer service as a discovery fallback).
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file livepeer_gateway-1.0.0.tar.gz.
File metadata
- Download URL: livepeer_gateway-1.0.0.tar.gz
- Upload date:
- Size: 222.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb7614d41459c44b2323bd9e14d908438758a5877a0666d32bae29b278b1c052
|
|
| MD5 |
72a85c217f02419601f28641b23d56ad
|
|
| BLAKE2b-256 |
f7aca4629bca2df5682955f4ae0902af983c935eabfa739f8f9faab41eacfd1a
|
Provenance
The following attestation bundles were made for livepeer_gateway-1.0.0.tar.gz:
Publisher:
publish-to-pypi.yml on livepeer/livepeer-python-gateway
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
livepeer_gateway-1.0.0.tar.gz -
Subject digest:
eb7614d41459c44b2323bd9e14d908438758a5877a0666d32bae29b278b1c052 - Sigstore transparency entry: 2438680665
- Sigstore integration time:
-
Permalink:
livepeer/livepeer-python-gateway@44df06157fcdb864e37d971e8caba86b2a7dc92e -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/livepeer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@44df06157fcdb864e37d971e8caba86b2a7dc92e -
Trigger Event:
push
-
Statement type:
File details
Details for the file livepeer_gateway-1.0.0-py3-none-any.whl.
File metadata
- Download URL: livepeer_gateway-1.0.0-py3-none-any.whl
- Upload date:
- Size: 102.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbcc96415014fdbf1c5806a4eb9da91bf5fa9e2281e10f5bf4e53f1b5a3a429e
|
|
| MD5 |
8d6f808cb25de03070cc442d15ac652e
|
|
| BLAKE2b-256 |
fccc33cc4c3b80aa6c4a961cf1ef29bf734a8843c08ee4322c16f26f92a37d8e
|
Provenance
The following attestation bundles were made for livepeer_gateway-1.0.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on livepeer/livepeer-python-gateway
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
livepeer_gateway-1.0.0-py3-none-any.whl -
Subject digest:
bbcc96415014fdbf1c5806a4eb9da91bf5fa9e2281e10f5bf4e53f1b5a3a429e - Sigstore transparency entry: 2438680852
- Sigstore integration time:
-
Permalink:
livepeer/livepeer-python-gateway@44df06157fcdb864e37d971e8caba86b2a7dc92e -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/livepeer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@44df06157fcdb864e37d971e8caba86b2a7dc92e -
Trigger Event:
push
-
Statement type: