llm.search/v1
Knowledge bases (buckets) an app searches with hybrid search, for retrieval-augmented generation (RAG). An app makes the bucket it needs (ensure); its admins fill it
with sources, each one tracked unit however many documents it brings: a file, pasted text, a folder, a zip, a web
page, a Git repository or one of the app's collections. Adding a source of the same name again replaces it (unchanged
documents cost nothing, missing ones go); pages and repositories are read again on an interval, collections kept in
sync. The provider splits each document into chunks that keep their source (document, section, lines, record), embeds
them with the app's one embedding model (llm.embed/v1, picked automatically; identical chunks anywhere in the app are
embedded once), and returns the best chunks for a query across the buckets asked for. It never answers the question
itself; llm.text/v1 and llm.chat/v1 calls take enrich to add a search's passages to their prompt, through the
Enrich helper every provider of those contracts uses.
A wire contract at /api/_c/llm.search/v1 (search.go), one provider. The llm-search
extension provides it. It brings the dashboard's Search screen (ui/main.js), which calls only this
contract (and llm.embed/v1's model list), so it works whoever provides it.
Use
In page code it's $llm.search (bound by the llm extension), and enrich on $llm calls:
$llm.search.ensure({ name: "help", title: "Help center", description: "Our help articles." })
$llm.search.addURL({ bucket: "help", url: "https://github.com/acme/docs", every: "day" })
const r = await $llm.search.searchAsync({ buckets: ["help"], query: "export to PDF", limit: 5, viewer: ctx.auth })
const answer = await $llm.text.completeAsync({ model: "vultr/glm-5.3", prompt: question, enrich: ["help"] })
Over HTTP (a superuser, or a token with the scope shown):
| Operation |
HTTP |
Body |
Token scope |
| Status |
GET /api/_c/llm.search/v1/status |
|
search:read |
| Set model |
POST /api/_c/llm.search/v1/set-model |
{"model"} ("" picks one again) |
search |
| Buckets |
GET /api/_c/llm.search/v1/buckets |
|
search:read |
| Bucket |
GET /api/_c/llm.search/v1/bucket |
?name= |
search:read |
| Ensure |
POST /api/_c/llm.search/v1/ensure |
{"name", "title", "description", "owner"} |
search |
| Update |
POST /api/_c/llm.search/v1/update |
{"name", "title"?, "description"?, "maxDocuments"?, "maxBytes"?} |
search |
| Delete |
POST /api/_c/llm.search/v1/delete |
{"name"} |
search |
| Sources |
GET /api/_c/llm.search/v1/sources |
?bucket= |
search:read |
| Add |
POST /api/_c/llm.search/v1/add |
{"bucket", "name", "text", "kind"?, "replace"?} (a file or text) |
search |
| Upload |
POST /api/_c/llm.search/v1/upload |
?bucket=&name=&replace=, the file (or .zip) as the body |
search |
| Put |
POST /api/_c/llm.search/v1/put |
{"bucket", "source", "path", "text", "replace"?} (a folder's file) |
search |
| Prune |
POST /api/_c/llm.search/v1/prune |
{"bucket", "source", "keep": [...]} (ends a folder) |
search |
| Add URL |
POST /api/_c/llm.search/v1/add-url |
{"bucket", "url", "kind"?, "every"?, "commits"?, "exclude"?} |
search |
| Detect URL |
POST /api/_c/llm.search/v1/detect-url |
{"url"} → {"kind"}: git when the server answers the Git protocol, else page |
search:read |
| Follow |
POST /api/_c/llm.search/v1/follow |
{"bucket", "collection", "fields": [...], "filter"?} |
search |
| Add folder |
POST /api/_c/llm.search/v1/add-folder |
{"bucket", "path", "include"?, "exclude"?, "url"?} (a folder of the app's files on the server) |
search |
| Refresh |
POST /api/_c/llm.search/v1/refresh |
{"bucket", "source"} |
search |
| Remove |
POST /api/_c/llm.search/v1/remove |
{"bucket", "sources": [...]} |
search |
| Documents |
GET /api/_c/llm.search/v1/documents |
?bucket=&source=&prefix= |
search:read |
| Search |
POST /api/_c/llm.search/v1/search |
{"buckets": [...], "query", "limit", "prefix", "viewer"} |
search:read |
| Sample |
POST /api/_c/llm.search/v1/sample |
{"buckets": [...], "count", "prefix"}: chunks picked at random (no query, no embedding) |
search:read |
A source answers {"bucket", "name", "kind", "url", "every", "commits", "exclude", "collection", "fields", "filter", "path", "include", "pageURL", "hash", "status", "error", "documents", "chunks", "embedded", "bytes", "pending", "costMicroUSD", "refreshed", "next"} (embedded below chunks: embedding under way; documents carry the same); kind is
file, text, folder, dir (a server folder), zip, page, git or collection, status is reading, ready or error, and hash is
a file's or zip's sha256, to spot an exact duplicate under another name. replace names an existing source the new one
replaces under its new name. Search answers {"results": [{"bucket", "source", "document", "text", "heading", "startLine", "endLine", "record", "url", "score"}], "model", "usage"}; no buckets searches every bucket. viewer
({"collection", "id"}, or {} for a guest) leaves out records it can't view by the collection's view rule. Status
answers {"model", "chunks", "embedded", "note"}: embedded below chunks means embedding is under way.
Errors: not_found (no such bucket or source), bad_request (a bad name, URL, collection or field, an empty query,
binary content), too_large (over the bucket's limits, a document over 10 MB, a zip over 100 MB), not_configured (no
embedding model), and llm.embed/v1's errors from embedding the query.
From Go: searchv1.Contract.Must(app) (from pocketone.dev/ext/contracts/llm/search/v1), and
searchv1.Enrich(ctx, app, enrich, query) for the passages a model call adds.
Provide
Implement searchv1.Search and provide it in Register (searchv1.Contract.Provide(app, impl)). Keep these promises:
Ensure is idempotent: an existing bucket keeps its settings; only an empty title, description or owner is filled in.
- A source is identified by its name within its bucket; adding one of the same name (or naming it in
replace)
replaces it, leaving sources in other buckets alone. Unchanged documents cost nothing; documents the new version
doesn't have go.
- One embedding model for the app, so any buckets can be searched together; vectors from two models are never
compared, a new model embeds every chunk again, and a chunk's content is embedded once however many sources hold it.
- A collection source's documents follow its records: saved, filtered out, deleted. Pages and repositories with an
interval are read again when it comes round; a server folder is read again every few minutes.
- A server folder's path stays inside the app's own folder (the one holding
pb_data) and never reaches pb_data, by
the path or by a link.
- A result's
url, when set, is where the passage is published: a page's URL, or a server folder's url pattern with
{path} filled in and the section's heading id as the anchor.
- With a
viewer, no result comes from a record the viewer can't view.
- Results are chunks with their source, best first, at most
limit (default 5, at most 50); score orders them.
- Searching is the only operation that waits on a model; adding and reading sources return before embedding is done.
Commands and APIs
Every operation is a REST endpoint, a pocketone command and an MCP tool, all generated from the contract and behind the same token scope check and hooks. See Remote CLI, or the full CLI, Extension APIs and MCP references.
status
Is the app's embedding model and how far embedding has got across every bucket.
|
|
| REST |
GET /api/_c/llm.search/v1/status |
| CLI |
pocketone remote llm search status |
| MCP |
llm_search_status |
| Token scope |
search:read |
set_model
Changes the app's embedding model ("provider/model" from llm.embed/v1's models; "" picks one again). Every bucket is embedded again in the background; until a chunk is, keywords still find it.
|
|
| REST |
POST /api/_c/llm.search/v1/set-model |
| CLI |
pocketone remote llm search set-model --model <value> |
| MCP |
llm_search_set_model |
| Token scope |
search |
| Input field |
Flag |
Type |
model |
--model |
string |
buckets
Lists the app's buckets with their counts.
|
|
| REST |
GET /api/_c/llm.search/v1/buckets |
| CLI |
pocketone remote llm search buckets |
| MCP |
llm_search_buckets |
| Token scope |
search:read |
bucket
Returns one bucket with its counts.
|
|
| REST |
GET /api/_c/llm.search/v1/bucket |
| CLI |
pocketone remote llm search bucket --name <value> |
| MCP |
llm_search_bucket |
| Token scope |
search:read |
| Input field |
Flag |
Type |
name |
--name |
string |
ensure
Makes a bucket if it's missing and returns it. An existing bucket keeps its settings, except that an empty title, description or owner is filled in. Apps call it at startup for the bucket they need.
|
|
| REST |
POST /api/_c/llm.search/v1/ensure |
| CLI |
pocketone remote llm search ensure --name <value> --title <value> --description <value> --owner <value> |
| MCP |
llm_search_ensure |
| Token scope |
search |
| Input field |
Flag |
Type |
name |
--name |
string |
title |
--title |
string |
description |
--description |
string |
owner |
--owner |
string |
update
Changes a bucket's title, description or limits (fields left out stay).
|
|
| REST |
POST /api/_c/llm.search/v1/update |
| CLI |
pocketone remote llm search update --name <value> --title <json> --description <json> --maxdocuments <json> --maxbytes <json> |
| MCP |
llm_search_update |
| Token scope |
search |
| Input field |
Flag |
Type |
name |
--name |
string |
title |
--title |
json |
description |
--description |
json |
maxDocuments |
--maxdocuments |
json |
maxBytes |
--maxbytes |
json |
delete
Removes a bucket and everything in it.
|
|
| REST |
POST /api/_c/llm.search/v1/delete |
| CLI |
pocketone remote llm search delete --name <value> |
| MCP |
llm_search_delete |
| Token scope |
search |
| Input field |
Flag |
Type |
name |
--name |
string |
sources
Lists a bucket's sources, by name.
|
|
| REST |
GET /api/_c/llm.search/v1/sources |
| CLI |
pocketone remote llm search sources --bucket <value> |
| MCP |
llm_search_sources |
| Token scope |
search:read |
| Input field |
Flag |
Type |
bucket |
--bucket |
string |
add
Puts a file or pasted text in a bucket as its own source (one document), replacing the source of that name. The same text again costs nothing; changed text embeds only its new chunks. It returns at once; the document is embedded in the background (its status says how far it got).
|
|
| REST |
POST /api/_c/llm.search/v1/add |
| CLI |
pocketone remote llm search add --bucket <value> --name <value> --text <value> --kind <value> --replace <value> |
| MCP |
llm_search_add |
| Token scope |
search |
| Input field |
Flag |
Type |
bucket |
--bucket |
string |
name |
--name |
string |
text |
--text |
string |
kind |
--kind |
string |
replace |
--replace |
string |
upload
Adds a file sent as the request body: ?bucket=<name>&name=<file name>[&replace=<source>]. A .zip is one source with a document per text file inside it; anything else is a file source.
|
|
| REST |
POST /api/_c/llm.search/v1/upload |
| CLI |
pocketone remote llm search upload --file <path> |
| Token scope |
search |
| Body |
the raw upload, not JSON |
put
Adds one file to a folder source (made on the first one), the way the dashboard sends a dropped folder; Prune ends it.
|
|
| REST |
POST /api/_c/llm.search/v1/put |
| CLI |
pocketone remote llm search put --bucket <value> --source <value> --path <value> --text <value> --replace <value> |
| MCP |
llm_search_put |
| Token scope |
search |
| Input field |
Flag |
Type |
bucket |
--bucket |
string |
source |
--source |
string |
path |
--path |
string |
text |
--text |
string |
replace |
--replace |
string |
prune
Removes the documents of a folder source that aren't in Keep: the files the folder no longer has.
|
|
| REST |
POST /api/_c/llm.search/v1/prune |
| CLI |
pocketone remote llm search prune --bucket <value> --source <value> --keep <a,b> |
| MCP |
llm_search_prune |
| Token scope |
search |
| Input field |
Flag |
Type |
bucket |
--bucket |
string |
source |
--source |
string |
keep |
--keep |
strings |
add_u_r_l
Adds a web page or a Git repository as a source (named by its URL, replacing one of that name) and reads it in the background; Every keeps it current.
|
|
| REST |
POST /api/_c/llm.search/v1/add-url |
| CLI |
pocketone remote llm search add-u-r-l --bucket <value> --url <value> --kind <value> --every <value> --commits <n> --exclude <a,b> |
| MCP |
llm_search_add_u_r_l |
| Token scope |
search |
| Input field |
Flag |
Type |
bucket |
--bucket |
string |
url |
--url |
string |
kind |
--kind |
string |
every |
--every |
string |
commits |
--commits |
int |
exclude |
--exclude |
strings |
add_folder
Adds a folder of the app's own files on the server (named by its path, replacing one of that name): every text file in it, read in the background and read again every few minutes, so changed files are embedded again and removed ones leave. With URL, each result from it links to the page that file is published at.
|
|
| REST |
POST /api/_c/llm.search/v1/add-folder |
| CLI |
pocketone remote llm search add-folder --bucket <value> --path <value> --include <a,b> --exclude <a,b> --url <value> |
| MCP |
llm_search_add_folder |
| Token scope |
search |
| Input field |
Flag |
Type |
bucket |
--bucket |
string |
path |
--path |
string |
include |
--include |
strings |
exclude |
--exclude |
strings |
url |
--url |
string |
detect_u_r_l
Says how AddURL would read a URL: as a Git repository when its server answers the Git protocol (any host, with or without .git), otherwise as a web page.
|
|
| REST |
POST /api/_c/llm.search/v1/detect-url |
| CLI |
pocketone remote llm search detect-u-r-l --url <value> |
| MCP |
llm_search_detect_u_r_l |
| Token scope |
search:read |
| Input field |
Flag |
Type |
url |
--url |
string |
follow
Adds one of the app's collections as a source (named by the collection): each record the filter keeps is a document, kept in sync as records are saved and deleted.
|
|
| REST |
POST /api/_c/llm.search/v1/follow |
| CLI |
pocketone remote llm search follow --bucket <value> --collection <value> --fields <a,b> --filter <value> |
| MCP |
llm_search_follow |
| Token scope |
search |
| Input field |
Flag |
Type |
bucket |
--bucket |
string |
collection |
--collection |
string |
fields |
--fields |
strings |
filter |
--filter |
string |
refresh
Reads a source again now: fetches a URL or repository, rereads a collection, resplits a file or zip.
|
|
| REST |
POST /api/_c/llm.search/v1/refresh |
| CLI |
pocketone remote llm search refresh --bucket <value> --source <value> |
| MCP |
llm_search_refresh |
| Token scope |
search |
| Input field |
Flag |
Type |
bucket |
--bucket |
string |
source |
--source |
string |
remove
Takes sources out of a bucket, with their documents.
|
|
| REST |
POST /api/_c/llm.search/v1/remove |
| CLI |
pocketone remote llm search remove --bucket <value> --sources <a,b> |
| MCP |
llm_search_remove |
| Token scope |
search |
| Input field |
Flag |
Type |
bucket |
--bucket |
string |
sources |
--sources |
strings |
documents
Lists a bucket's documents (or one source's), by source and name.
|
|
| REST |
GET /api/_c/llm.search/v1/documents |
| CLI |
pocketone remote llm search documents --bucket <value> --source <value> --prefix <value> |
| MCP |
llm_search_documents |
| Token scope |
search:read |
| Input field |
Flag |
Type |
bucket |
--bucket |
string |
source |
--source |
string |
prefix |
--prefix |
string |
search
Returns the chunks that best match a query across the buckets named, best first.
|
|
| REST |
POST /api/_c/llm.search/v1/search |
| CLI |
pocketone remote llm search --buckets <a,b> --bucket <value> --query <value> --limit <n> --prefix <value> --viewer <json> |
| MCP |
llm_search_search |
| Token scope |
search:read |
| Input field |
Flag |
Type |
buckets |
--buckets |
strings |
bucket |
--bucket |
string |
query |
--query |
string |
limit |
--limit |
int |
prefix |
--prefix |
string |
viewer |
--viewer |
json |
sample
Returns chunks picked at random from the buckets named: material to draw from ("surprise me", a topic nobody asked about), not matches. No query, no embedding, so it costs nothing. Like Search without a viewer, it may return any chunk, a followed record's included.
|
|
| REST |
POST /api/_c/llm.search/v1/sample |
| CLI |
pocketone remote llm search sample --buckets <a,b> --bucket <value> --count <n> --prefix <value> |
| MCP |
llm_search_sample |
| Token scope |
search:read |
| Input field |
Flag |
Type |
buckets |
--buckets |
strings |
bucket |
--bucket |
string |
count |
--count |
int |
prefix |
--prefix |
string |
Extensions
License
MIT
Questions and comments
Comments are a GitHub Discussions thread; sign in with GitHub to post.