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.2-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.2-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.2-cp313-cp313-macosx_11_0_arm64.whl (3.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

livekit_gateway-0.1.2-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.2-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.2-cp312-cp312-macosx_11_0_arm64.whl (3.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

livekit_gateway-0.1.2-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.2-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.2-cp311-cp311-macosx_11_0_arm64.whl (3.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

livekit_gateway-0.1.2-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.2-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.2-cp310-cp310-macosx_11_0_arm64.whl (3.0 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

livekit_gateway-0.1.2-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.2-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.2-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.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ee53318d6f23b5bb6630624d39a2425293d62d6dad8f7911adaac685d70a2af8
MD5 4be33be1057c3164a3a19f11613ed8a8
BLAKE2b-256 9ed7f2b00581d4d5d3f38e3b47e9a26022c51da97dc792aa717dc8045f281ec8

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.2-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.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d7af8e933635c29d44386ba3fbffe7ebf3b55a99b1aa005050a5acf304de8560
MD5 85bf4126449403402adfb063c653b39a
BLAKE2b-256 082e742ee5b65470f198125ae27ea5b7e0140e9e71b89874d166abf8704353d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.2-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.2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1951b5f70d3ad9684c234bffd8845c85cf1d1635d4969a2830177996f89ccab2
MD5 d810eeff47512579ce5b4105a333668d
BLAKE2b-256 ebd673f4845b6c00c6412496cc4560c1c21539e09ace6680050a04d5ba02f528

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.2-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.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 55321a12b01b41f3bfc3f6f95e93be035f3be2cee61a54af1541db33e38de7e1
MD5 6aed219c41131d80751a4c04d276439e
BLAKE2b-256 ed97c82d6cb4ab842e4d36fd1926ac752c8499dff9c92b9110a62d65a26453f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.2-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.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c33defa3f4e56eb17557c0ba302cbe89a35383e441c93876ed542d93416b600c
MD5 f4bd9d46384213c433cd893e6b3cb459
BLAKE2b-256 726a069bdd6dd574e756d1c46bead18e3aa5e7ae9329d972dd612aeb1283500c

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.2-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.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 07563bfcf37a04a29ad42fee84ab3b9b7882510a1b1d2999dcca0e1e3e597d86
MD5 9ab28e2e0395cce231c0b163acd431fd
BLAKE2b-256 a2b4d3e42f2a3a74fec302b5c72cab4722d10bde5b19dbc8648c6358262ce133

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.2-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.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9fa6f145716620b25a2b4d3c2889504e13c327bc4dbfa2493db9395a8f5e1617
MD5 957dfffcfc32ddb819418eb1b72d91c1
BLAKE2b-256 739fc976f264eec9b5f43484d8bf39d9b00b100fc16019085de87ea189c62c91

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.2-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.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 aa273c31b530fb00b81bb7ccc262136f0d7cc90a84120c96f80975e03d9f514f
MD5 cfbe1a758348b214fe5f0c8057aa3f8a
BLAKE2b-256 1e15a629437509fc0486b6f1f197e73e99589249043e559a75e3cb783044f172

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.2-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.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 579857398666acf25ad2cf13458f311d5ec09972c5c2e7420c5386e5f3bc06af
MD5 830b2eab86da257c873de687970135ca
BLAKE2b-256 30910d681fee25f4ca617df49790e597c014f082e1c223c6aeea51f00531c95a

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.2-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.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7e3c9c39cd269cdeaed473dc61a9423a6fa500966a8b342544dfd24d85d6479d
MD5 b4468bdb88743d8500c27079a761505b
BLAKE2b-256 b89e99e80239139ff6b18cc6f9522fd9c9bc9336c48f781f1d7dcf114f1a545f

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.2-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.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 30dca26d7f0268cbb28e359411ef6056cc6ad809d6a4310d799d1809b7dd14c1
MD5 06fe93bafb11c42f3b75bd9550f631be
BLAKE2b-256 6f1cd88744b479ff51060c6e83d90279e9b0c836034c57ad852cee2a93ba7f5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.2-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.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 33298e9484dc639a706c4de6843ee346db53bb0a4b198a333d8d14c76b0163a1
MD5 94bdaba902b249ed8bb5b0184ed527eb
BLAKE2b-256 ed5f1a4a3eb07779693b5b36ab6f80729b779605dd6901b4ef4ebc802176806c

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.2-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.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6820d66f9e62cdce84fc557bcd8e61f79f48d9d4d49cc5c9ac27e8d54c762ce6
MD5 e98d9322bdb5fae88d562d8a92b6b0e2
BLAKE2b-256 8d59529dadda52805a7a5ebefae3fd5a368b6c29c6e661d4c6bb163fbef59ba8

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.2-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.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2dd41ff7526baee74d100aa01c09b61647c1e927bb03d3474fef5e11c6d0d035
MD5 33bde94ae8dc4df244e582689dac27da
BLAKE2b-256 7038a729470e41879cc59fbb857169d66280247ab7d5c2689aab414e9d154216

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.2-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.2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for livekit_gateway-0.1.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0af9538bbc645bd26275e606e24ea9e914b15ac2c3ae908a7334fc144e0a839d
MD5 ac5b8f471fab4ffa9819f3f8f4797c4a
BLAKE2b-256 92a648c04799962b46603c4972af344158b0227637901d9c3aeeb266d1ef69fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_gateway-0.1.2-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