# RAG over AutessaDB and Drive

Source: https://docs.autessa.com/docs/features/rag

> Retrieval for AI agents: search AutessaDB tables by meaning and Drive files by meaning or exact text, with your access rules applied, from any agent or framework.

# RAG over AutessaDB and Drive

Give any agent search over your own data. Search AutessaDB table columns by meaning, and search Drive files by meaning, keywords, or exact text. Row, column, and file access rules apply to every result.

## When to use it

- Your agent answers questions from your documents, policies, or product data.
- You want retrieval without running your own vector database or chunking pipeline.
- You need search results to respect who can see what.

## Quickstart

1. [Get a free API key](https://builder.autessa.com/get-api-key). New accounts get $100 of free credits for your first month, no card needed. The developer key acts as you, so it can search any table or Drive you can open. To limit a key to one table or Drive, create one in **Settings → API keys** instead. See [Keys](/docs/start/keys.md).
2. Put your files in [Drive](/docs/guide/autessadb/drive.md), or turn on vector search for a [table](/docs/guide/autessadb/tables.md) column.
3. Call `POST /clients/autessadb-drive/search` (files) or `POST /clients/autessadb/search` (a table column). Pass the ID as `?resourceId=` and as `tableId`.

**curl:**

```bash
curl -X POST "https://api.autessa.com/clients/autessadb-drive/search?resourceId=V1StGXR8Z5" \
  -H "Authorization: $AUTESSA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"tableId": "V1StGXR8Z5", "query": "refund policy for annual plans", "mode": "hybrid", "topK": 5}'
```

**Python:**

```python
import os
import requests

DRIVE_ID = "V1StGXR8Z5"
res = requests.post(
    "https://api.autessa.com/clients/autessadb-drive/search",
    params={"resourceId": DRIVE_ID},
    headers={"Authorization": os.environ["AUTESSA_API_KEY"]},
    json={"tableId": DRIVE_ID, "query": "refund policy for annual plans", "topK": 5},
    timeout=30,
)
for hit in res.json()["results"]:
    print(hit["path"], hit["score"], hit["snippet"])
```

**TypeScript:**

```typescript
const DRIVE_ID = "V1StGXR8Z5";
const res = await fetch(
  `https://api.autessa.com/clients/autessadb-drive/search?resourceId=${DRIVE_ID}`,
  {
    method: "POST",
    headers: { Authorization: process.env.AUTESSA_API_KEY!, "Content-Type": "application/json" },
    body: JSON.stringify({ tableId: DRIVE_ID, query: "refund policy for annual plans", topK: 5 }),
  },
);
const { results } = await res.json();
for (const hit of results) console.log(hit.path, hit.score, hit.snippet);
```

**Java:**

```java
var driveId = "V1StGXR8Z5";
var body = """
    {"tableId": "%s", "query": "refund policy for annual plans", "topK": 5}
    """.formatted(driveId);
var req = java.net.http.HttpRequest.newBuilder(java.net.URI.create(
        "https://api.autessa.com/clients/autessadb-drive/search?resourceId=" + driveId))
    .header("Authorization", System.getenv("AUTESSA_API_KEY"))
    .header("Content-Type", "application/json")
    .POST(java.net.http.HttpRequest.BodyPublishers.ofString(body))
    .build();
System.out.println(java.net.http.HttpClient.newHttpClient()
    .send(req, java.net.http.HttpResponse.BodyHandlers.ofString()).body());
```

Each Drive result has `path`, `page`, `lineStart`, `lineEnd`, `score`, and a `snippet` you can quote and cite.

## Search a table column

```bash
curl -X POST "https://api.autessa.com/clients/autessadb/search?resourceId=V1StGXR8Z5" \
  -H "Authorization: $AUTESSA_API_KEY" -H "Content-Type: application/json" \
  -d '{"tableId": "V1StGXR8Z5", "columnName": "description", "query": "waterproof hiking boots", "limit": 5}'
```

Results come back ranked with `score` and the row's `rowData`. Use `scoreThreshold` (0 to 1) to drop weak matches. Use `POST /clients/autessadb/query` for exact filters and sorting.

## How it works

- **Drive search modes:** `hybrid` (default: meaning plus keywords), `semantic`, `lexical`, and `keyword`. Narrow with `path` or `glob`.
- **Exact text:** `POST /clients/autessadb-drive/grep` finds a pattern across files. `/read` returns a file's text. `/find` filters by name, type, size, or date.
- **Tables:** columns marked for vector search are indexed when rows change. Call `/clients/autessadb/index-record` to index one row right away.
- **Access rules:** results only include rows, columns, and files the key can see. Masked columns stay masked.

## Libraries and frameworks

| Where | Package | Call |
| --- | --- | --- |
| Python | `autessa-rag` | `Rag().search(query, drive=..., top_k=...)`, or `table=..., column=...` |
| TypeScript | `@autessa/rag` | `new Rag().search({ drive, query, topK })`, or `{ table, column, query, topK }` |
| Java | `com.autessa:autessa-rag` | `Rag.fromEnv().search(SearchRequest.drive(driveId, query).topK(5))`, or `SearchRequest.table(tableId, query).column(...)` |
| LangChain | `langchain-autessa`, `@autessa/langchain` | `AutessaRetriever` |
| Agent tools | built-in `autessadb_search`, `drive_search`, `drive_read` | See [Agent tools and MCP](/docs/features/agent-tools-mcp.md) |

```python
from autessa.rag import Rag

rag = Rag()  # reads AUTESSA_API_KEY
result = rag.search("refund policy for annual plans", drive="V1StGXR8Z5", top_k=5)
for hit in result.hits:
    print(round(hit.score, 2), hit.source, hit.text)
```

The libraries add `resourceId` for you and return one shape for tables and Drive: `hits`, each with `id`, `score`, `text`, `source`, and `metadata`. Table search needs `column`, the text column to search. For Drive, `mode`, `path`, and `glob` narrow the search. Each library also has row calls (`query`, `get_row`, `insert_row`, `update_row`, `index_record` in Python) and Drive calls (`ls`, `find`, `stat`, `grep`, `read`, `search`, `download_url`).

The libraries are in private preview and not yet on PyPI, npm, or Maven Central. Install from GitHub as each library's README describes, for example:

```bash
pip install "autessa-core @ git+https://github.com/Autessa-Inc/autessa-python#subdirectory=packages/autessa-core"
pip install "autessa-rag @ git+https://github.com/Autessa-Inc/autessa-python#subdirectory=packages/autessa-rag"
```

The HTTP API above works today.

## Limits

- Table search: `limit` up to 100 per page.
- Each key has its own rate limits. See [API keys and scopes](/docs/start/api-keys.md).
- Storage and indexing are billed to your company. See [Billing](/docs/guide/company/billing.md).

## API reference

- [Drive API](/docs/reference/drive.md) and [AutessaDB Tables API](/docs/reference/tables.md)
- Detailed guides: [Drive client API](/docs/api/autessadb-drive.md), [AutessaDB client API](/docs/api/autessadb.md)

## Benchmarks

No public retrieval benchmark yet. See [Benchmarks](/docs/benchmarks.md) for what we publish.

## Example

- [LangGraph support agent](https://github.com/Autessa-Inc/autessa-examples/tree/main/examples/langgraph-support-agent): a support agent that answers from your Drive files with `AutessaRetriever`.
- [Vercel AI chat](https://github.com/Autessa-Inc/autessa-examples/tree/main/examples/vercel-ai-chat): the built-in `drive_search` tool in a Next.js chat.

## Related

- [Drive](/docs/guide/autessadb/drive.md)
- [Tables](/docs/guide/autessadb/tables.md)
- [LangChain integration](/docs/integrations/langchain.md)
- [Start here](/docs/start.md)

