Skip to content

Python SDK

How the runtime sets up a project's Python, when you want uv yourself, how to add tatolab-stream and other packages to a project, and where settings and secrets go.

A project is an ordinary Python project: a pyproject.toml, your node code, and a virtual environment in .venv/. The runtime runs your nodes with that environment’s Python, so whatever you install there, your nodes can import. The Python SDK is tatolab-stream, imported as tatolab.stream.

The runtime carries its own copy of uv. Whenever it opens a project whose .venv/bin/python doesn’t run, it makes the .venv with uv sync. It carries CPython 3.12, the version a new project’s .python-version names, and installs it when the machine has none. It also carries tatolab-stream and its core modules, built at its own version, and the wheels they need, so a new project syncs without the network and always matches the runtime. Opening a project needs no setup step.

To add packages from the command line, you’ll want uv of your own. On macOS or Linux:

Terminal window
curl -LsSf https://astral.sh/uv/install.sh | sh

Or with Homebrew: brew install uv. Check it with uv --version.

Nodes run on CPython 3.12 or 3.13, the standard builds; the free-threaded builds aren’t supported. tatolab new pins 3.12 in .python-version.

If you’re going on to the quickstart, skip this: it creates my-stream in its first step.

Terminal window
tatolab new my-stream

The runtime writes the project and its one stream, makes .venv/, and opens the project, held stopped. Without a folder name, it makes one up under ~/streams. To start from a sample instead, name one: tatolab new --sample test-pattern-halftone-lens.

A new project’s pyproject.toml depends on tatolab-stream and names Tatolab’s own package index, which serves the first-party modules the runtime doesn’t carry:

pyproject.toml
[project]
name = "tatolab-stream-project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["tatolab-stream>=0.54.2"]
[[tool.uv.index]]
name = "tatolab"
url = "https://get.tatolab.com/simple/"

Every other name falls through to PyPI.

Terminal window
uv add tatolab-camera
uv add torch

uv add adds the package to pyproject.toml and installs it into .venv. Every node in the project can now import it, and the node types a package ships appear in Tato Studio’s node search. tatolab dev notices the change to pyproject.toml and reloads the project, so you don’t have to restart it. Editing pyproject.toml by hand installs nothing until the next uv sync.

Tatolab’s modules install the same way: tatolab-camera, tatolab-microphone, tatolab-speaker, tatolab-h264, tatolab-h265, tatolab-opus, tatolab-moq, tatolab-webrtc, tatolab-virtualcamera and others. In Tato Studio, File › Marketplace… adds them for you.

A folder is a project when it holds a tatolab-project.json. The easiest start is tatolab new into a fresh folder, then moving your code in. Then:

  1. uv add tatolab-stream.
  2. Put each node in a module of the project, such as nodes/detector.py. A process node runs in its own interpreter, which imports its class by the module:ClassName path the graph document names.
  3. Add nodes to streams/main.graph.json in Tato Studio, or by hand, and run tatolab dev in the project folder.

The runtime looks for Python at <project>/.venv/bin/python and nowhere else. If it doesn’t run, the runtime makes the .venv again with uv sync. A .venv you made some other way is used as it is, as long as it holds tatolab-stream.

tatolab-stream ships with complete type hints, and installs and imports without the runtime. Point your editor at the project’s .venv and you get completion for the whole API; your type checker and unit tests work on a machine with no runtime at all. A function node is still an ordinary function you can call in a test:

from tatolab.stream import node
@node.function
def Clamp(x: float, low: float = 0.0, high: float = 1.0) -> float:
return min(max(x, low), high)
assert Clamp(1.5) == 1.0

A node’s settings are values in the graph document, set in Tato Studio or by hand; see Write a node. The graph document is kept on the project’s history, so never put a secret in it.

Every node’s process inherits the runtime’s environment, not your shell’s. Set a secret where tatolabd starts, in a systemd unit’s Environment= or the terminal you start it from, and read it with os.environ. A file in the project works too: a node finds its project with ctx.stream_project_directory.

nodes/publisher.py
import os
WHIP_URL = os.environ["STREAMLIB_WHIP_URL"] # set where tatolabd starts

The MoQ gateway takes credentials on an input as well as in its settings, so a node that reads a secret store can hand them over while the stream runs. See Across machines.