# Ask and search

> How search works and how to connect Ask to a model.

## Search

Search works with no setup. The build writes `search.json` with the text of every page, and the browser searches it. Press <kbd>Ctrl</kbd> <kbd>K</kbd>, or <kbd>⌘</kbd> <kbd>K</kbd> on a Mac.

## Files for AI tools

The build also writes files that AI tools can read:

| Path | What it holds |
|---|---|
| `/llms.txt` | A list of every page with its description |
| `/llms-full.txt` | Every written page as Markdown, in one file |
| `/<slug>.md` | One page as plain Markdown |

Each page also has **Copy page**, which copies it as Markdown.

## Ask

Ask starts in preview mode. It shows the sample answers from `ask.samples` in `driftless.config.ts`, and search matches for other questions.

To connect a model, set `ask.endpoint` to a URL that accepts a POST request:

```json
{ "question": "How do I add a page?", "page": "/ask" }
```

and returns:

```json
{ "answer": ["First paragraph.", "Second paragraph."], "sources": [{ "title": "Write a page", "href": "/write-a-page" }] }
```

A small serverless function can do this. It reads `llms.txt` and the `.md` pages, sends the question and the matching pages to a model, and returns the answer. Keep the model key in the function. Never put it in the site.
