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

# jina

> <a href="https://github.com/pixeltable/pixeltable/blob/main/pixeltable/functions/jina.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>

# <span style={{ 'color': 'gray' }}>module</span>  pixeltable.functions.jina

Pixeltable [UDFs](https://docs.pixeltable.com/platform/udfs-in-pixeltable) that wrap [Jina AI](https://jina.ai/) APIs
for embeddings and reranking. In order to use them, the API key must be specified either with `JINA_API_KEY`
environment variable, or as `api_key` in the `jina` section of the Pixeltable config file.

## <span style={{ 'color': 'gray' }}>udf</span>  embeddings()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
embeddings(
    input: pxt.String,
    *,
    model: pxt.String,
    task: pxt.String | None = None,
    dimensions: pxt.Int | None = None,
    late_chunking: pxt.Bool | None = None
) -> pxt.Array[(None,), float32]
```

Creates embedding vectors for the input text using Jina AI embedding models.

Equivalent to the Jina AI embeddings API endpoint.
For additional details, see: [https://jina.ai/embeddings/](https://jina.ai/embeddings/)

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

**Parameters:**

* **`input`** (`pxt.String`): The text to embed.
* **`model`** (`pxt.String`): The Jina embedding model to use. See available models at
  [https://jina.ai/embeddings/](https://jina.ai/embeddings/).
* **`task`** (`pxt.String | None`): Task-specific embedding optimization. Options:
  * `retrieval.query`: For search queries
  * `retrieval.passage`: For documents/passages to be searched
  * `separation`: For clustering/separation tasks
  * `classification`: For classification tasks
  * `text-matching`: For semantic similarity
* **`dimensions`** (`pxt.Int | None`): Output embedding dimensions (optional). If not specified, uses
  the model's default dimension.
* **`late_chunking`** (`pxt.Bool | None`): Enable late chunking for long documents.

**Returns:**

* `pxt.Array[(None,), float32]`: An array representing the embedding of `input`.

**Examples:**

Add a computed column that applies jina-embeddings-v3 to an existing column:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
tbl.add_computed_column(
    embed=jina.embeddings(
        tbl.text, model='jina-embeddings-v3', task='retrieval.passage'
    )
)
```

Add an embedding index:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
tbl.add_embedding_index(
    'text', string_embed=jina.embeddings.using(model='jina-embeddings-v3')
)
```

## <span style={{ 'color': 'gray' }}>udf</span>  rerank()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
rerank(
    query: pxt.String,
    documents: pxt.Json[(String, ...)],
    *,
    model: pxt.String,
    top_n: pxt.Int | None = None,
    return_documents: pxt.Bool | None = None
) -> JinaRerankResponse
```

Reranks documents based on their relevance to a query using Jina AI reranker models.

Equivalent to the Jina AI rerank API endpoint.
For additional details, see: [https://jina.ai/reranker/](https://jina.ai/reranker/)

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

**Parameters:**

* **`query`** (`pxt.String`): The query string to rank documents against.
* **`documents`** (`pxt.Json[(String`): The list of documents to rerank.
* **`model`** (`Any`): The Jina reranker model to use. See available models at
  [https://jina.ai/reranker/](https://jina.ai/reranker/).
* **`top_n`** (`Any`): Number of top results to return. If not specified, returns all documents.
* **`return_documents`** (`Any`): Whether to include the original document text in results.

**Returns:**

* `JinaRerankResponse`: A dictionary containing:

  * `results`: List of reranking results with `index` and `relevance_score`
    (and `document` if `return_documents=True`)
  * `usage`: Token usage information

**Examples:**

Rerank search results for better relevance:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
tbl.add_computed_column(
    reranked=jina.rerank(
        tbl.query,
        tbl.candidate_docs,
        model='jina-reranker-v2-base-multilingual',
        top_n=5,
    )
)
```


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