> ## 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.

# parallel

> <a href="https://github.com/pixeltable/pixeltable/blob/main/pixeltable/functions/parallel.py#L0" id="viewSource" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/View%20Source%20on%20Github-blue?logo=github&labelColor=gray" alt="View Source on GitHub" style={{ display: 'inline', margin: '0px' }} noZoom /></a>

# module  pixeltable.functions.parallel

Pixeltable [UDFs](https://docs.pixeltable.com/platform/udfs-in-pixeltable.md) that wrap
[Parallel](https://parallel.ai/)'s web search and extraction APIs.

Without an API key, the UDFs call Parallel's free MCP endpoint, which needs `pip install mcp` and serves searches in
Fast mode under the service's anonymous rate limits. Specify `PARALLEL_API_KEY`, or `api_key` in the `parallel`
section of the Pixeltable config file, to call the Search and Extract REST APIs, which also accept the search and
extraction settings the free endpoint does not.

## udf  extract()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
extract(
    url: pxt.String,
    *,
    objective: pxt.String | None = None,
    search_queries: pxt.Json[(String, ...)] | None = None,
    full_content: pxt.Bool | None = None,
    fetch_policy: pxt.Json[{'max_age_seconds': Int, 'timeout_seconds': Float, 'disable_cache_fallback': Bool}, optional_keys=['disable_cache_fallback', 'max_age_seconds', 'timeout_seconds']] | None = None,
    links: pxt.Bool | None = None,
    allow_live_fetch: pxt.Bool | None = None,
    session_id: pxt.String | None = None
) -> ParallelExtractResponse
```

Extract relevant excerpts, or the whole text, from a web page.

Equivalent to the Parallel Extract API endpoint.
For additional details, see: [https://docs.parallel.ai/extract/extract-quickstart](https://docs.parallel.ai/extract/extract-quickstart)

Without an API key, the free endpoint returns excerpts or full content; `fetch_policy` and `links` then
require one, and `allow_live_fetch` is the freshness setting it offers in place of `fetch_policy`.

Request throttling:
Applies the rate limit set in the config (section `parallel`, key `rate_limit`). If no rate
limit is configured, uses a default of 600 RPM.

**Parameters:**

* **`url`** (`pxt.String`): An HTTP or HTTPS page URL.
* **`objective`** (`pxt.String | None`): Information to extract, up to 200 characters. Omit for general page excerpts.
* **`search_queries`** (`pxt.Json[(String`): Keyword queries of three to six words each, which focus the excerpts alongside `objective`;
  pass the queries of the search that produced `url`.
* **`full_content`** (`Any`): Return the whole page as markdown instead of excerpts. A long page can run to tens of
  thousands of tokens. Defaults to the service's setting, which returns excerpts.
* **`fetch_policy`** (`Any`): How fresh the page contents have to be, as `max_age_seconds`, `timeout_seconds` and
  `disable_cache_fallback`. Defaults to the service's setting, which decides from `url` and `objective`.
  Requires an API key.
* **`links`** (`Any`): Also return the page's outgoing links. Requires an API key.
* **`allow_live_fetch`** (`Any`): Whether the free endpoint may read the page live rather than serve its cached copy.
  Defaults to the service's setting of `True`. With an API key, use `fetch_policy` instead.
* **`session_id`** (`Any`): Application-owned conversation ID; pass the ID used by the related searches.

**Returns:**

* `ParallelExtractResponse`: A dictionary with the following entries:

  * `extract_id` (`str`): Parallel's ID for this extraction, for support requests

  * `results` (`list`): one entry if the page was read, otherwise empty, with

    * `url` (`str`): the page URL
    * `title` (`str | None`): the page title
    * `publish_date` (`str | None`): the publication date, as `YYYY-MM-DD`
    * `excerpts` (`list[str]`): passages relevant to `objective`
    * `full_content` (`str | None`): the whole page as markdown, if `full_content` asked for it
    * `links` (`list[str] | None`): the page's outgoing links, if `links` asked for them

  * `errors` (`list`): one entry if the page could not be read, otherwise empty, with

    * `url` (`str`): the page URL
    * `error_type` (`str`): Parallel's error classification, e.g. `fetch_error`
    * `http_status_code` (`int | None`): the status returned by the page
    * `content` (`str | None`): the error body, if the page returned one

  * `warnings` (`list | None`): the adjustments the service made to the request, each with a `type`,
    a `message` and an optional `detail`

  * `usage` (`list | None`): what the request billed, each entry with a `name` and a `count`

  * `session_id` (`str`): the conversation ID, echoed back, or one generated by the service

  A page that could not be read is reported in `errors` rather than as a UDF error.

**Examples:**

Extract excerpts for a column of page URLs:

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

tbl.add_computed_column(page=parallel.extract(tbl.url))
```

Read the excerpts, and the reason a page could not be read, out of the response:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
tbl.select(
    tbl.page.results[0].excerpts, tbl.page.errors[0].error_type
).collect()
```

Group a row's search and extraction under the conversation ID stored alongside it:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
tbl.add_computed_column(
    page=parallel.extract(tbl.url, session_id=tbl.conversation)
)
```

## udf  search()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
search(
    objective: pxt.String,
    *,
    search_queries: pxt.Json[(String, ...)] | None = None,
    mode: pxt.String = 'fast',
    max_results: pxt.Int | None = None,
    source_policy: pxt.Json[{'include_domains': Json[(String, ...)], 'exclude_domains': Json[(String, ...)], 'after_date': String}, optional_keys=['after_date', 'exclude_domains', 'include_domains']] | None = None,
    fetch_policy: pxt.Json[{'max_age_seconds': Int, 'timeout_seconds': Float, 'disable_cache_fallback': Bool}, optional_keys=['disable_cache_fallback', 'max_age_seconds', 'timeout_seconds']] | None = None,
    session_id: pxt.String | None = None
) -> ParallelSearchResponse
```

Search the web and return source URLs, titles and relevant excerpts.

Equivalent to the Parallel Search API endpoint.
For additional details, see: [https://docs.parallel.ai/search/search-quickstart](https://docs.parallel.ai/search/search-quickstart)

Without an API key, the free endpoint serves `fast` searches; `mode`, `max_results`, `source_policy` and
`fetch_policy` then require one.

Request throttling:
Applies the rate limit set in the config (section `parallel`, key `rate_limit`). If no rate
limit is configured, uses a default of 600 RPM.

**Parameters:**

* **`objective`** (`pxt.String`): The information to find, including any source or freshness requirements.
* **`search_queries`** (`pxt.Json[(String`): Keyword queries of three to six words each, which may use search operators; two or three
  work best. The service ranks sources against them and against `objective`. Defaults to `objective`
  as the only query.
* **`mode`** (`Any`): How much work the service puts into the search, in increasing order of latency and cost. `advanced`
  and `basic` cost five times `fast` and `turbo`. See
  [https://docs.parallel.ai/search/modes](https://docs.parallel.ai/search/modes).
* **`max_results`** (`Any`): How many sources to return. Defaults to the service's setting of 10, and is capped at 20.
* **`source_policy`** (`Any`): Which sources to search, as `include_domains`, `exclude_domains` and `after_date`. See
  [https://docs.parallel.ai/search/advanced-search-settings](https://docs.parallel.ai/search/advanced-search-settings).
* **`fetch_policy`** (`Any`): How fresh the page contents have to be, as `max_age_seconds`, `timeout_seconds` and
  `disable_cache_fallback`. Defaults to the service's setting, which serves its cached index.
* **`session_id`** (`Any`): Application-owned conversation ID, a UUID or a hex string of at least 32 characters. Pass the
  same ID for related search and extract calls; omit it for standalone requests. Use a new opaque ID for
  a new conversation.

**Returns:**

* `ParallelSearchResponse`: A dictionary with the following entries:

  * `search_id` (`str`): Parallel's ID for this search, for support requests

  * `results` (`list`): the sources, ordered by decreasing relevance, each with

    * `url` (`str`): the source URL
    * `title` (`str | None`): the page title
    * `publish_date` (`str | None`): the publication date, as `YYYY-MM-DD`
    * `excerpts` (`list[str]`): passages relevant to `objective`

  * `warnings` (`list | None`): the adjustments the service made to the request, each with a `type`,
    a `message` and an optional `detail`

  * `usage` (`list | None`): what the request billed, each entry with a `name` and a `count`

  * `session_id` (`str`): the conversation ID, echoed back, or one generated by the service

**Examples:**

Search for each row's question:

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

tbl.add_computed_column(sources=parallel.search(tbl.question))
```

Read the first source's excerpts out of the response:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
tbl.select(tbl.sources.results[0].excerpts).collect()
```

Search with keyword queries of their own, in the highest-quality mode:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
tbl.add_computed_column(
    sources=parallel.search(
        tbl.question, search_queries=tbl.keyword_queries, mode='advanced'
    )
)
```

Make search available to an LLM using the existing tool-calling API:

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


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