Skip to content

Python API

Use Python to drive a RemoteMedia pipeline or to implement a node inside one. For local execution, the client calls the native runtime through FFI. For remote operation, the control client attaches to a running session, including a session routed through Scaling Entry.

Choose your role

Role Public entry point Runs where?
Execute one local request remotemedia.execute_pipeline_with_input(...) Native host in your application process; nodes may use workers
Keep a local stream open remotemedia.runtime.create_streaming_session(...) Local runtime session
Control an existing local session remotemedia.control.attach_inproc(session) In-process control attach
Control an existing remote session remotemedia.control.attach(address, session_id=...) gRPC service or Scaling Entry admin listener
Add processing behavior MultiprocessNode, NodeConfig, RuntimeData Host-managed Python worker
Compose lightweight Python objects Pipeline, Node Python execution or native instance path, depending on the call

“Python node” means a processing component written in Python; it does not refer to Node.js.

Run locally

After installing the client and native runtime, a single-node manifest can echo text:

import asyncio
from remotemedia import execute_pipeline_with_input

manifest = {
    "version": "v1",
    "metadata": {"name": "hello"},
    "nodes": [{"id": "echo", "node_type": "PassThrough"}],
    "connections": [],
}

async def main():
    result = await execute_pipeline_with_input(manifest, ["hello"])
    print(result)

asyncio.run(main())

This explicitly requires FFI. The general Pipeline.run() convenience method can fall back to Python after native availability or execution failures; it is a different choice when execution identity matters.

Stream, control, and extend

  • Streaming: send repeated inputs, consume all output kinds, finish input, and close.
  • Scaling: attach through Entry, and understand deployment, joins, and media transport.
  • Control and RPC: tap outputs, inject context, change node state, and call exposed methods.
  • Python nodes: transform RuntimeData with explicit configuration and lifecycle hooks.
  • Data and buffers: use typed payloads and understand copy ownership.
  • Shared sessions: attribute participant output and distinguish model reuse.
  • Cancellation: interrupt or abort a real generator.
  • Source plugins: package and provision a Python node.
  • RPC and tools: host application callbacks locally or through Entry.
  • Python WebRTC: negotiate a room and exchange audio.
  • Observability: inspect performance and copy reports.
  • API map: find the public surface for each task.

A local FFI session and a remote attach have different creation and ownership contracts. Use separate setup examples even when later control operations share an API.