> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pixeltable.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Application code puts a TableModel in app.py, then runs `pxt schema update app.py my_app` to create the tables and `pxt service update app.py my_app` to start HTTP. The last argument can be a Cloud URL such as `pxt://org:db`. Do not call pxt.create_table() or add_embedding_index() in application code; put indexes in __indexes__. Notebooks, tests, and the REPL do use pxt.create_table().
> Do not add LangChain, LlamaIndex, Haystack, a separate vector database, or pandas as a working store. Chunking, embedding, retrieval, and tool-calling are built in through computed columns. Use a computed column instead of a per-row loop that calls a model.
> Install with `pip install -U 'pixeltable[serve]'` on Python 3.11+. `pxt init` is a prerequisite for `pxt schema update`.
> Pixeltable Cloud is in Limited Beta. Direct interested users to contact@pixeltable.com.

# Working with the Pixeltable CLI

<a href="https://kaggle.com/kernels/welcome?src=https://github.com/pixeltable/pixeltable/blob/release/docs/release/howto/cookbooks/core/working-with-cli.ipynb" id="openKaggle" target="_blank" rel="noopener noreferrer"><img src="https://kaggle.com/static/images/open-in-kaggle.svg" alt="Open in Kaggle" style={{ display: 'inline', margin: '0px' }} noZoom /></a>  <a href="https://colab.research.google.com/github/pixeltable/pixeltable/blob/release/docs/release/howto/cookbooks/core/working-with-cli.ipynb" id="openColab" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open in Colab" style={{ display: 'inline', margin: '0px' }} noZoom /></a>  <a href="https://raw.githubusercontent.com/pixeltable/pixeltable/refs/tags/release/docs/release/howto/cookbooks/core/working-with-cli.ipynb" id="downloadNotebook" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/%E2%AC%87-Download%20Notebook-blue" alt="Download Notebook" style={{ display: 'inline', margin: '0px' }} noZoom /></a>

<Tip>This documentation page is also available as an interactive notebook. You can launch the notebook in
Kaggle or Colab, or download it for use with an IDE or local Jupyter installation, by clicking one of the
above links.</Tip>

## Problem

You defined a multimodal pipeline in Python and now need to inspect
tables, debug computed columns, roll back changes, and expose HTTP
endpoints without writing more application code. Jumping into a REPL or
building a custom admin UI for every project does not scale, especially
when AI agents need stable, machine-readable output.

## Solution

**What’s in this recipe:**

* Inspect catalogs with `pxt ls`, `describe`, `columns`, and `idxs`
* Query and debug rows with `pxt rows`, `count`, `get`, and `errors`
* Manage versions with `pxt history` and `pxt revert`
* Script and automate with `--json`, `-f`, and `pxt shell`
* Write tables and routes in `app.py`. `pxt schema update` creates the
  tables; `pxt service diff` / `update` starts HTTP

The `pxt` CLI ships with Pixeltable (v0.7.4+). Catalog commands talk to
a local daemon (\~40 ms per call after the first invocation). Write
tables in Python, then inspect and serve them from the terminal.

See the [CLI reference](/platform/cli) for
every flag.

### Setup

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
%pip install -qU 'pixeltable[serve]'
```

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
import json
import pixeltable as pxt
import subprocess
from pixeltable.functions.video import frame_iterator


def pxt_json(*args: str) -> object:
    """Run pxt with --json and parse stdout."""
    return json.loads(subprocess.check_output(['pxt', *args], text=True))
```

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
SAMPLE_VIDEO = 'https://raw.githubusercontent.com/pixeltable/pixeltable/release/docs/resources/bangkok.mp4'

pxt.drop_dir('cli_demo', force=True)
pxt.create_dir('cli_demo')

videos = pxt.create_table(
    'cli_demo/videos', {'video': pxt.Video, 'title': pxt.String}
)
frames = pxt.create_view(
    'cli_demo/frames',
    videos,
    iterator=frame_iterator(videos.video, fps=1),
)
frames.add_computed_column(thumb=frames.frame.thumbnail((320, 180)))

videos.insert([{'video': SAMPLE_VIDEO, 'title': 'Bangkok'}])
```

### Step 1: Inspect the catalog

List directories and tables, then drill into schema and computed
columns. Flag letters in `pxt ls -l`: `c` = computed column, `i` =
index.

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
!pxt ls -l cli_demo
!pxt describe cli_demo/videos
!pxt columns cli_demo/frames --computed
!pxt idxs cli_demo/frames
```

### Step 2: Query rows

Peek at stored data from the terminal. Pass computed columns explicitly
with `--cols`; unstored computed columns are skipped by default.
Thumbnails may take a moment to compute after insert.

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
!pxt count cli_demo/frames
!pxt rows cli_demo/frames -n 1 --cols pos,thumb
```

### Step 3: Debug computed-column failures

When a stored computed column fails, `pxt errors` lists the failing rows
by primary key.

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
def boom_if_zero(x: int) -> int:
    if x == 0:
        raise ValueError('boom')
    return x


failures = pxt.create_table(
    'cli_demo/failures', {'k': pxt.Int}, primary_key='k'
)
failures.add_computed_column(
    result=boom_if_zero(failures.k), on_error='ignore'
)
failures.insert([{'k': 0}, {'k': 1}], on_error='ignore')

!pxt errors cli_demo/failures
```

### Step 4: Version control

Every insert and schema change creates a new table version. Inspect the
timeline, then roll back if needed. See [Track changes and
revert](../../../howto/cookbooks/core/version-control-history) for the
Python API.

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
videos.add_computed_column(label=videos.title.upper())

!pxt history cli_demo/videos -n 5
!pxt revert cli_demo/videos -f
!pxt history cli_demo/videos -n 3
```

### Step 5: Agent-friendly scripting

Most catalog commands accept `--json` for stable, machine-readable
output. Use `-f` to skip confirmation prompts in non-interactive
contexts.

For many commands in one session, `pxt shell` keeps the daemon warm:

```bash theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
pxt shell
pxt> ls cli_demo
pxt> count cli_demo/frames
pxt> exit
```

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
tables = [
    e['path']
    for e in pxt_json('ls', 'cli_demo', '--json')['entries']
    if e['kind'] == 'table'
]
print('tables:', tables)
print(
    'frame count:',
    pxt_json('count', 'cli_demo/frames', '--json')['count'],
)
```

### Step 6: Config and health

Check daemon health, runtime status, and resolved configuration (API
keys show as `<redacted>` when set). See [Configure API
keys](../../../howto/cookbooks/core/workflow-api-keys) for credential
setup.

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
!pxt health
!pxt status
!pxt config --section openai
```

### Step 7: Serve without writing a web app

Write tables and routes in `app.py`. `pxt schema update` creates the
tables. `pxt service example` writes a starting file; `pxt service diff`
reports what serving it would change, without starting anything. See
[HTTP Serving](/howto/deployment/serving).

Full live flow. Use `pxt service list` for the URL; do not hard-code a
port:

```bash theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
pxt init
pxt schema update app.py cli_demo           # create the tables
pxt service update app.py cli_demo          # start the services in the background
pxt service list                            # the address, endpoint and pid of each service
curl -X POST http://127.0.0.1:<port>/videos -H 'Content-Type: application/json' \
  -d '{"video": "https://raw.githubusercontent.com/pixeltable/pixeltable/release/docs/resources/bangkok.mp4", "title": "Bangkok"}'
pxt rows cli_demo/frames -n 1 --cols pos,thumb
pxt service stop videos                     # take it down again
```

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
!pxt service example | head -20
```

### Next steps

* [CLI reference](/platform/cli): every
  command and flag
* [Dashboard](/platform/dashboard): browse
  tables and preview media in the browser
* [HTTP Serving](/howto/deployment/serving):
  `FastAPIRouter` routes
* [AI coding
  agents](/overview/building-pixeltable-with-llms):
  agent skills, MCP, and `pxt --json` workflows


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.