---
title: "Chat agent"
description: "Knowledge, conversation memory, and the LLM answer are tables and computed columns."
pattern: "serving"
url: "https://pixeltable.com/recipes/chat-agent"
---

# Chat agent

Knowledge, conversation memory, and the LLM answer are tables and computed columns.

- **Pattern:** serving
- **Cloud deploy:** no
- **Scaffold:** `pxt schema update app.py agent && pxt service update app.py agent`
- **Secrets:** `ANTHROPIC_API_KEY`

## Tables

### knowledge

| Column | Type |
| --- | --- |
| body | String |
| title | String |
| source | String |

### conversations

| Column | Type |
| --- | --- |
| role | String |
| content | String |
| conversation_id | String |

### agent

| Column | Type |
| --- | --- |
| prompt | String |
| conversation_id | String |

## Routes

- `INSERT /api/ask` (table: agent)
- `INSERT /api/knowledge` (table: knowledge)
- `QUERY /api/knowledge/search`

## Sample calls

### Add knowledge

```sh
curl -X POST "$PIXELTABLE_API_URL/api/knowledge" -H "Authorization: Bearer $PIXELTABLE_API_KEY" -H "Content-Type: application/json" -d '{"body": "Pixeltable is declarative multimodal data infrastructure.", "title": "intro", "source": "docs"}'
```

Source: https://github.com/pixeltable/pixeltable-starter-kit/blob/main/examples/chat-agent
