Skip to main content

How to Create a Custom Node

To expose any function as a node in Pipeline‑UI, simply add the @node() decorator. For example:
from pipeline_ui import node, NodeInput, NodeOutput, TextParameter
from typing import Annotated

@node()
def add_numbers(
    a: int = NodeInput(python_type=int, description="First number to add"),
    b: int = NodeInput(python_type=int, description="Second number to add")
) -> Annotated[int, NodeOutput(name="sum", description="Sum of two numbers")]:
    return a + b

Steps for Creating Your Own Node

  1. Define the Function: Write a Python function with the appropriate inputs.
  2. Decorate with @node(): Add the decorator.
  3. Annotate the Return Type: Use Annotated[<type>, NodeOutput(...)] to declare output properties.
  4. Customize Inputs: Use NodeInput for required data and parameter classes (such as TextParameter, NumberParameter) for configuration defaults.
  5. Test in the UI: Run the project; your node should appear as a draggable block in the editor.
For more advanced examples, check out our sample workflows in the examples folder.