Skip to main content

Plivo audio-stream transport for livekit-agents — drop-in liblivekit_ffi.{so,dylib}

Project description

livekit-gateway

A LiveKit agents ↔ Plivo audio-stream bridge. Regular livekit-agents runs unchanged; calls land on Plivo numbers and route through this gateway via audio stream instead of a LiveKit SFU.

  livekit-gateway architecture  

Install

pip install livekit-gateway

Wheel includes prebuilt artifacts for macosx_arm64 (Apple Silicon) and manylinux2014_{x86_64,aarch64}. Intel Macs aren't covered by prebuilt wheels and need to build from source.

Quick start

# my_agent.py — stock livekit-agents, no modifications
import livekit_gateway     # MUST come before any livekit import

from livekit.agents import AgentServer, AgentSession, JobContext, JobProcess, cli
from livekit.plugins import deepgram, openai, silero


def prewarm(proc: JobProcess) -> None:
    # Loaded once per idle child, reused across all calls that child handles.
    # Without this, every call rebuilds Silero / Deepgram / OpenAI clients
    # on the hot path (~200-300 ms per call).
    proc.userdata["vad"] = silero.VAD.load()
    proc.userdata["stt"] = deepgram.STT(model="nova-3", language="en")
    proc.userdata["llm"] = openai.LLM(model="gpt-4o-mini")
    proc.userdata["tts"] = openai.TTS(model="tts-1", voice="alloy")


# `num_idle_processes` is the size of livekit-agents' warm child pool.
# Each idle child is a Python interpreter that has already run `prewarm`
# above; when a call lands, one is picked off the pool instantly (no
# fork + import + plugin-load on the hot path). Set this to your
# expected concurrent-call peak; on a small box, 2 is a fine start.
server = AgentServer(num_idle_processes=2)
server.setup_fnc = prewarm


@server.rtc_session()
async def entrypoint(ctx: JobContext):
    # `LIVEKIT_URL` is auto-set to the local gateway WS by `import
    # livekit_gateway` above (dev mode) or supplied by env (production —
    # `ws://<gateway-host>:7880`). You don't dial Plivo from here; Plivo
    # dials the gateway's answer URL and the gateway dispatches this
    # entrypoint with the call's metadata already populated in
    # `ctx.room`.
    session = AgentSession(
        stt=ctx.proc.userdata["stt"],
        llm=ctx.proc.userdata["llm"],
        tts=ctx.proc.userdata["tts"],
        vad=ctx.proc.userdata["vad"],
    )
    await ctx.connect()
    await session.start(agent=..., room=ctx.room)


if __name__ == "__main__":
    cli.run_app(server)
python my_agent.py dev

That's it. import livekit_gateway auto-spawns the gateway subprocess if it isn't already running, sets LIVEKIT_URL to point at it, and tears it down when Python exits. Plivo webhook + agent worker registration + audio relay all happen behind the scenes.

Plivo side still needs one-time setup — see Plivo configuration below.

Production

Run the gateway as a long-lived service and the agent in start mode (warm pool, not dev's cold fork):

livekit-gateway                                                                   # terminal 1
LKG_NO_AUTO_GATEWAY=1 LIVEKIT_URL=ws://localhost:7880 python my_agent.py start    # terminal 2

Run the gateway under systemd (or any supervisor) so it survives agent restarts and existing calls don't drop. Multi-host scaling: run one gateway per host with the agent registering at it; if you point N agent workers at one gateway, the gateway round-robins jobs across the least-loaded ones.

Configure

All non-secret gateway settings live in config.toml at the repo root (or wherever $LKG_CONFIG_PATH points). Every key is documented inline in that file — [server] for ports + public host, [http] for endpoint paths, [stream] for every Plivo <Stream> attribute, [call_insights] for the per-call observability summary. Secrets (PLIVO_AUTH_ID, PLIVO_AUTH_TOKEN) are env-only.

Plivo configuration

Two URLs to set on your Plivo Application (Plivo Console → Voice → XML Applications). Both point at the same public hostname; only the paths differ, and both paths are configurable via [http] in config.toml.

  • Answer URLhttps://<your-gateway>/answer ([http] answer_path, default /answer). When a call lands, Plivo POSTs the call's form fields here (CallUUID, From, To, Direction, AccountSID) and the gateway replies with a <Stream> XML pointing back at the WSS audio endpoint with those fields appended as query params.
  • Hangup URL / Status Callback URLhttps://<your-gateway>/status ([http] status_path, default /status). Plivo POSTs call lifecycle events here (hangup, stream start/stop, etc.); the gateway uses these to close out the matching session cleanly.

Releasing

PyPI wheels ship from CI; nothing is built locally for release. The flow mirrors agent-transport's:

  1. Bump the version in:

    • python/pyproject.toml (version under [project])
    • python/livekit_gateway/__init__.py (__version__)

    Use the bump-version skill — it asks for the target version, confirms, and edits both files in one pass.

  2. Open a PR with only the version bump. Do not mix release bumps with feature changes.

  3. Apply label release-python-sdk to the PR.

  4. Merge to main. CI takes it from there:

    • Build Python (.github/workflows/build-python.yml) builds wheels for macosx_arm64 and manylinux2014_{x86_64,aarch64}.
    • Publish Python (.github/workflows/publish-python.yml) downloads them, publishes to PyPI via the trusted publisher (OIDC, no token), and creates a python-vX.Y.Z GitHub Release with notes auto-built from PRs labelled core or python since the previous tag.

The PyPI description is sourced from python/README.md, which the Build Python workflow rewrites from the repo-root README.md before each cibuildwheel run. So edit only the root README; CI keeps them in sync. (python/README.md is kept in the tree because pyproject.toml's readme = pointer resolves relative to that directory — without the file, local pip install -e ./python would fail.)

The Rust workspace version in Cargo.toml is decoupled — nothing publishes those crates user-facing, so bumping is cosmetic. Leave it unless you have a reason.

Prerequisites (one-time)

  • PyPI: trusted publisher for livekit-gateway pointing at publish-python.yml (no environment configured — the workflow doesn't claim one). See https://docs.pypi.org/trusted-publishers/.
  • GitHub: label release-python-sdk.

Release notes

The publish workflow filters PRs since the last python-v* tag down to those labelled core or python, then prepends them as the release body. Apply one of those labels on feature/fix PRs you want surfaced in the changelog. Release-bump PRs themselves should only carry release-python-sdk (no python / core — otherwise the bump PR title shows up in its own notes).

License

MIT.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

livekit_gateway-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

livekit_gateway-0.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

livekit_gateway-0.1.1-cp313-cp313-macosx_11_0_arm64.whl (3.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

livekit_gateway-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

livekit_gateway-0.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

livekit_gateway-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (3.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

livekit_gateway-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

livekit_gateway-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

livekit_gateway-0.1.1-cp311-cp311-macosx_11_0_arm64.whl (3.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

livekit_gateway-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

livekit_gateway-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

livekit_gateway-0.1.1-cp310-cp310-macosx_11_0_arm64.whl (3.0 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

livekit_gateway-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

livekit_gateway-0.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

livekit_gateway-0.1.1-cp39-cp39-macosx_11_0_arm64.whl (3.0 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file livekit_gateway-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f1a093f26ca947489f2105133eaf1ba2861d0b1d0e874f1207986c448e743cc2
MD5 3b31a6021fcb659bf1a26f9abc2f28ce
BLAKE2b-256 51f46458cb86d8fb5a9ffbc437f32baa1df77185f9ad6e8cd0ff9da21d5e37b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-python.yml on plivo-labs/livekit-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file livekit_gateway-0.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3fcd064f895a96654dd3df53a4c0e335dbf11649f505d4b20300f9fd0facc6d8
MD5 f60445c82be4da031cb22e41b8b8ccde
BLAKE2b-256 2f1d25e82739f9746ce308a635ea28db04535f978724504ba6a2ccf8cfbe6333

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-python.yml on plivo-labs/livekit-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file livekit_gateway-0.1.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 65d46b151513eb3347f533c2d3e85806e07539d8b4ef56eaa42e4a5598b697b8
MD5 5e4e4107893e9a049ace323a26e5ea83
BLAKE2b-256 2c7e4a548b98f1d4034acc185e5a6d557b269afd6e9c65a6353c0d6361306c33

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish-python.yml on plivo-labs/livekit-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file livekit_gateway-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f1ab38ac9a3e2fe5f7f8f7aecc55c923dcbdb0c7de9df76116e8ae985efbdbfc
MD5 a056f3598778d00a9ec71462e7d38b9b
BLAKE2b-256 ef92fbb9648e7432df90c78021886972f049fb6657d38cab8a65dcd861288136

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-python.yml on plivo-labs/livekit-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file livekit_gateway-0.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 221fd83dc471b3d205e6aff610f3319755e202af3f6431258c913436035111fd
MD5 8417a9e9ae0433b30c2cf8e50d0405e8
BLAKE2b-256 b303250496278effb88bbd46baa7feb50c9ae2dd66045305fa0dd7b6c66a73bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-python.yml on plivo-labs/livekit-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file livekit_gateway-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 36c1bf167a93713e6ada526c2f34715dc1d045b0fa1db3bb5839fed0574147b2
MD5 2a2768915078d0d3e76501de6d077050
BLAKE2b-256 0d36b92d7acd5d381546d90248c7cfa7163a3faa84110b37f2bd822476191a93

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish-python.yml on plivo-labs/livekit-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file livekit_gateway-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 154d854e8b566ce7f72d33fd07f7d4cb7e195c62a7e2a8fcaab1de00817c15b3
MD5 93be3b6a2f2af81b70f58cba197dc641
BLAKE2b-256 6b50c745efa97be50a86e1e6b4e0104f9a48969280ad14b7c51f4203f26e58a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-python.yml on plivo-labs/livekit-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file livekit_gateway-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 11bd1a3786438a9366b7249c85ccf6b2e54d57e19bd3bf280e2fd3236946341a
MD5 b0758ea2002fca4fece13bad96cfb495
BLAKE2b-256 d06fe177c2f10731ea632e8dc18b10d407945cca80b75a0639cc29312c5125c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-python.yml on plivo-labs/livekit-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file livekit_gateway-0.1.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ab998db0b59fee8042915b4706ab93dd60e7d8122a61ef2675dd4edb55db7aa8
MD5 6761ec32b9eff25f2f790a42bf79db3b
BLAKE2b-256 9453d91fefcdf7e19054b9f88270d3edd0258b481328e59d28e0f001bd3a6dd0

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.1-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish-python.yml on plivo-labs/livekit-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file livekit_gateway-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aae56031d08785713ff1e0ed42edd5f6d4121b018d9f7f37991811a21cb8eeec
MD5 c1651b76026ddc7a67cdd6e0b324e045
BLAKE2b-256 4d1cd3a1525a058924ee74d908f6899d03d3ff4e0c2b7a80ae0df1cf294237de

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-python.yml on plivo-labs/livekit-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file livekit_gateway-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b66b9b7166afdee9a3f635b64fe0148a81e8886b5006a258ab017d167ccd1fc9
MD5 c56056e365d84783f1995b8ecf975daa
BLAKE2b-256 34044bc2ebb2e2a0618f88b6ab507b101d3bb0c9f10c90e318581f95c1486189

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-python.yml on plivo-labs/livekit-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file livekit_gateway-0.1.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f67449e1b8c15805cfb94f2121b390865d9b31061c4b9ade4bd0ed16d8642318
MD5 4952e0301abd45ebc42374d0f728be5d
BLAKE2b-256 69837dd0b0b164a22f8384e5b1b5a85c2aa631f5d1548efa1a0449d2dfc367fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.1-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: publish-python.yml on plivo-labs/livekit-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file livekit_gateway-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 322c217330eed3f2e5eff7e3bc9b378a4374606f6a3cf0bd2362a45718750c54
MD5 49676ce733424f546343e089661f88ea
BLAKE2b-256 8987972a311dd7cc3abe9c147dc64ed58e15bee61dba570bb8f24baf53037a10

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-python.yml on plivo-labs/livekit-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file livekit_gateway-0.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ee8143dd60077ff93e2d98dcf2760b1a5a668642032ee55f5bd5687f2df2917c
MD5 e089359f16e925abfd4327fc1d78ae39
BLAKE2b-256 635a714e631cdb20cd3d7836d5f733ed8555d08cb82848323257317b447e4a18

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-python.yml on plivo-labs/livekit-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file livekit_gateway-0.1.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0f78e77ad29c02c99f2ca27a8aff1b4b8aee72dea3c771027da4df2b414624d0
MD5 9485dfe40dbae99008543e787f61898e
BLAKE2b-256 eabfaeb673c78da0de2cd8c29be3f573a7053d310e295d2156c4a06eb0315f01

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.1-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: publish-python.yml on plivo-labs/livekit-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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