---
title: "Use a table pipeline as a reusable function"
description: "Convert a table with computed columns into a callable function for multi-agent workflows and pipeline composition."
url: "https://www.pixeltable.com/notebooks/pattern-table-as-udf"
updated: "2026-04-10"
---

# Use a table pipeline as a reusable function

Convert a table with computed columns into a callable function for multi-agent workflows and pipeline composition.

- **Type:** Notebook
- **Group:** Agents

## How it works

You wrap an entire table pipeline as a function. When you call this function from another table, it inserts a row into the agent table, runs all computed columns, and returns the specified output column.

## What it covers

- Create an "agent" table with computed columns
- Convert the table to a callable UDF with pxt.udf(table, return_value=...)
- Use the table UDF in other tables' computed columns

## What it uses

- **Install:** `pip install pixeltable openai`
- **Environment variables it names:** `OPENAI_API_KEY`
- **Pixeltable calls:** `openai.chat_completions()`, `pxt.create_table()`, `pxt.udf()`, `add_computed_column()`, `insert()`

## A look at the code

```python
# Add the LLM call as a computed column
summarizer.add_computed_column(
    response=chat_completions(
        messages=[
            {
                'role': 'user',
                'content': 'Summarize this in one sentence:\n\n'
                + summarizer.text,
            }
        ],
        model='gpt-4o-mini',
    )
)
```

## Open it

- **Open in Colab:** https://colab.research.google.com/github/pixeltable/pixeltable/blob/release/docs/release/howto/cookbooks/agents/pattern-table-as-udf.ipynb
- **Docs page:** https://docs.pixeltable.com/howto/cookbooks/agents/pattern-table-as-udf
- **Source on GitHub:** https://github.com/pixeltable/pixeltable/blob/release/docs/release/howto/cookbooks/agents/pattern-table-as-udf.ipynb
