> ## 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`.
> For Pixeltable Cloud, point users to https://docs.pixeltable.com/cloud, which goes from `pxt login` to a running service.

# Working with Parallel in Pixeltable

[![Open in Kaggle](https://kaggle.com/static/images/open-in-kaggle.svg)](https://kaggle.com/kernels/welcome?src=https://github.com/pixeltable/pixeltable/blob/release/docs/release/howto/providers/working-with-parallel.ipynb)  [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/pixeltable/pixeltable/blob/release/docs/release/howto/providers/working-with-parallel.ipynb)  [![Download Notebook](https://img.shields.io/badge/%E2%AC%87-Download%20Notebook-blue)](https://raw.githubusercontent.com/pixeltable/pixeltable/refs/tags/release/docs/release/howto/providers/working-with-parallel.ipynb)

> [!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.

Pixeltable’s [Parallel](https://parallel.ai/) integration gives your
tables and agents web search and page extraction, as computed columns
that run once per row and are cached with the rest of your data.

The UDFs work without a Parallel account: with no API key configured,
they call Parallel’s free MCP endpoint, which serves searches in Fast
mode under the service’s anonymous rate limits. With a key, they call
the Search and Extract REST APIs, which also accept the settings shown
further down.

### Prerequisites

* `pip install mcp`, which the free endpoint needs
* Optionally, a Parallel account and API key
  ([https://platform.parallel.ai/](https://platform.parallel.ai/))

### Important notes

* Parallel usage may incur costs based on your Parallel plan. Searches
  in `basic` and `advanced` mode cost five times those in `fast` and
  `turbo` mode.
* Be mindful of sensitive data and consider security measures when
  integrating with external services.

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
%pip install -qU pixeltable mcp
```

Everything up to [Searching with your own
account](#searching-with-your-own-account) runs without a Parallel API
key, on the free endpoint, in Fast mode. That section needs one.

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
import os

if 'PARALLEL_API_KEY' in os.environ:
    print('Using the Search and Extract APIs of your Parallel account.')
else:
    print('No PARALLEL_API_KEY: using the free endpoint, in Fast mode.')
```

<pre>
  No PARALLEL\_API\_KEY: using the free endpoint, in Fast mode.
</pre>

Now let’s create a Pixeltable directory to hold the tables for our demo.

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
import pixeltable as pxt

# Remove the 'parallel_demo' directory and its contents, if it exists
pxt.drop_dir('parallel_demo', force=True)
pxt.create_dir('parallel_demo')
```

<pre>
  Created directory 'parallel\_demo'.
  \<pixeltable.catalog.dir.Dir at 0x7fddbe435c10>
</pre>

## Searching the web

`parallel.search()` takes the information a row needs and returns the
sources that answer it, each with the passages relevant to the request.
Pass `search_queries` to rank sources against keyword queries of your
own; with none, the UDF sends the objective as the only query.

Each row also carries a conversation ID, which the next section uses.

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
import uuid
from pixeltable.functions import parallel

research_t = pxt.create_table(
    'parallel_demo.research',
    {'question': pxt.String, 'conversation': pxt.String},
)
research_t.add_computed_column(
    sources=parallel.search(
        research_t.question, session_id=research_t.conversation
    )
)
```

<pre>
  Created table 'research'.
  Added 0 column values with 0 errors in 0.01 s
  No rows affected.
</pre>

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
research_t.insert(
    [
        {
            'question': 'What is the Pixeltable Python library for?',
            'conversation': uuid.uuid4().hex,
        },
        {
            'question': 'Which file formats can Pixeltable index?',
            'conversation': uuid.uuid4().hex,
        },
    ]
)
```

<pre>
  Inserted 2 rows with 0 errors in 1.46 s (1.37 rows/s)
  2 rows inserted.
</pre>

The response is a dictionary, so a JSON path reaches into it from a
query or another computed column. `results` is ordered by decreasing
relevance.

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
research_t.select(
    research_t.question,
    title=research_t.sources.results[0].title,
    url=research_t.sources.results[0].url,
).collect()
```

## Extracting a page

`parallel.extract()` reads one page. It takes the excerpts relevant to
an objective, or the whole page as markdown with `full_content=True`.
Chaining it onto the search above extracts the top source of each row.
Parallel may read the page live; `allow_live_fetch=False` restricts the
free endpoint to the copy in its index, which answers faster but can be
older.

`session_id` is the application’s own ID for one conversation: a UUID,
or a hex string of at least 32 characters, generated once and reused
across the related searches and extractions. Parallel correlates the
calls under it, and meters the free endpoint by it. The `conversation`
column holds one per row, so a row’s search and extraction go under the
same ID.

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
research_t.add_computed_column(
    top_page=parallel.extract(
        research_t.sources.results[0].url,
        objective=research_t.question,
        session_id=research_t.conversation,
    )
)
```

<pre>
  Added 2 column values with 0 errors in 0.99 s (2.02 rows/s)
  2 rows updated.
</pre>

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
page = research_t.select(research_t.top_page).collect()['top_page'][0]
page['results'][0]['excerpts'][0][:400]
```

<pre>
  '# What is Pixeltable?\n> Pixeltable is a declarative, incremental data infrastructure for multimodal AI, unifying tables, computed columns, and vector search in one system.\n**The only open source Python library providing declarative data infrastructure for building multimodal AI applications, enabling incremental storage, transformation, indexing, retrieval, and orchestration of data.**\nWith Pixelt'
</pre>

A page that could not be read is reported in `errors` rather than
failing the row, so one dead link does not stop the rest of a batch.

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
research_t.select(
    url=research_t.top_page.results[0].url,
    errors=research_t.top_page.errors,
).collect()
```

## Searching with your own account

With `PARALLEL_API_KEY` set, `search()` also takes `mode`,
`max_results`, `source_policy` and `fetch_policy`, and `extract()` takes
`fetch_policy` and `links`. Requesting one of them without a key reports
`MISSING_CREDENTIALS` instead of silently searching on the free tier,
which is why the cell below runs only with a key.

`mode` defaults to `fast`. Use `advanced` for multi-hop questions,
`turbo` for the lowest latency, and read
[https://docs.parallel.ai/search/modes](https://docs.parallel.ai/search/modes)
for the trade-offs.

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
if 'PARALLEL_API_KEY' in os.environ:
    research_t.add_computed_column(
        docs_only=parallel.search(
            research_t.question,
            mode='advanced',
            max_results=3,
            source_policy={'include_domains': ['docs.pixeltable.com']},
        )
    )
    display(
        research_t.select(
            url=research_t.docs_only.results[0].url
        ).collect()
    )
else:
    print('These settings need PARALLEL_API_KEY; skipping.')
```

<pre>
  These settings need PARALLEL\_API\_KEY; skipping.
</pre>

## Giving a model web access

Both UDFs go into a tool list like any other Pixeltable function, and a
model calls them through the usual [tool-calling
API](https://docs.pixeltable.com/howto/cookbooks/agents/llm-tool-calling.md):

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
tools = pxt.tools(parallel.search, parallel.extract)
```

A published tool exposes every parameter, so the model chooses the
search settings and invents a `session_id` of its own. Binding a
parameter fixes its value and takes it out of the published schema,
which is how an application keeps the conversation ID, and the settings
its credentials cannot serve, to itself:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
conversation = uuid.uuid4().hex
tools = pxt.tools(
    pxt.tool(
        parallel.search.using(
            mode='fast',
            max_results=None,
            source_policy=None,
            fetch_policy=None,
            session_id=conversation,
        ),
        name='search',
    ),
    pxt.tool(
        parallel.extract.using(
            fetch_policy=None,
            links=None,
            allow_live_fetch=None,
            session_id=conversation,
        ),
        name='extract',
    ),
)
```

That leaves the model `objective` and `search_queries` on `search`, and
`url`, `objective`, `search_queries` and `full_content` on `extract`:
everything the free endpoint serves, and nothing it refuses.

[Agentic workflows](https://docs.pixeltable.com/use-cases/agentic-workflows.md) puts the whole
loop together.

## Learn More

* [Parallel documentation](https://docs.parallel.ai/)
* [Search API](https://docs.parallel.ai/search/search-quickstart)
* [Extract API](https://docs.parallel.ai/extract/extract-quickstart)
* [Search modes](https://docs.parallel.ai/search/modes)
* [Parallel MCP
  server](https://docs.parallel.ai/integrations/mcp/quickstart)


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