> ## 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 declares a TableModel in app.py, then runs `pxt schema update app.py <target>` to create the tables and `pxt service update` to serve routes. Do not call pxt.create_table() or add_embedding_index() in application code; declare 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.

# Agentic workflows

> Insert a message. Tool calls run as columns.

Insert a message. The model picks a tool, `invoke_tools` runs it, and both results are columns on that row.

Create the tables with `pxt schema update app.py my_app`, then open them with `t = pxt.get_table('my_app.assistant')`. Cookbooks on this topic use `pxt.create_table()` so you can run cells without a project. An app puts the same columns on a `TableModel` in `app.py` and creates the tables with `pxt schema update`.

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
import pixeltable as pxt
import pixeltable.functions as pxtf
from pixeltable.serving import FastAPIRouter

TableModel = pxt.model_base()


@pxt.udf
def get_weather(city: str) -> str:
    return f'Weather in {city}: 72°F, sunny'


tools = pxt.tools(get_weather)


class Assistant(TableModel, name='assistant'):
    message: pxt.String
    response = pxtf.openai.chat_completions(
        messages=[{'role': 'user', 'content': message}],
        model='gpt-4o-mini',
        tools=tools,
    )
    tool_output = pxtf.openai.invoke_tools(tools, response)


ask = FastAPIRouter(name='ask')
ask.add_insert_route(
    Assistant, path='/ask', inputs=[Assistant.message], outputs=[Assistant.tool_output]
)
```

```bash theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
pxt schema update app.py my_app
pxt service update app.py my_app
```

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
assistant = pxt.get_table('my_app.assistant')
assistant.insert([{'message': 'Weather in Paris?'}])
assistant.select(assistant.message, assistant.tool_output).collect()
```

`pxt service list` prints the URL. POST `/ask` with `{"message": "..."}`. Chat history is another table with an embedding index: [Agent memory](/howto/cookbooks/agents/pattern-agent-memory). MCP tools load with `pxt.mcp_udfs(...)` and go into the same `pxt.tools()` list.

A full chat app: [`uvx pixeltable-new`](https://github.com/pixeltable/pixeltable-new) copies the [starter kit](/resources/starter-kit) agent. Pass `agent` as the last argument to `pxt schema update`. `/ask` needs `ANTHROPIC_API_KEY`.

On Cloud, create an API key in the [dashboard](/howto/deployment/cloud#get-an-api-key), set `PIXELTABLE_API_KEY`, then run `pxt db update`, `pxt schema update`, and `pxt service update` against `pxt://org:mydb`.

Search over chunks instead of tools: [RAG and live APIs](/use-cases/multimodal-backend). Coming from LangGraph: [Migrate](/howto/coming-from#langgraph).

<CardGroup cols={2}>
  <Card title="Tool calling" icon="wrench" href="/howto/cookbooks/agents/llm-tool-calling">
    Register tools and run `invoke_tools` as a column.
  </Card>

  <Card title="Agentic patterns" icon="diagram-project" href="/howto/cookbooks/agents/agentic-patterns">
    Patterns for agents as tables.
  </Card>

  <Card title="RAG pipeline" icon="book" href="/howto/cookbooks/agents/pattern-rag-pipeline">
    Search over chunks instead of tools.
  </Card>

  <Card title="HTTP serving" icon="globe" href="/howto/deployment/serving">
    POST `/ask` from the same file.
  </Card>
</CardGroup>
