File System Operations

Hand off to an LLM

Navigate parsed documents and the cross-doc memory store via Unix-shell verbs.

POST /v3/fs is a single op-driven endpoint that lets an LLM agent (or any programmatic client) walk a corpus the way it would walk a filesystem — ls to list, cat to read, grep to search, head for a quick peek, stat for metadata, and find / open / xref for the cross-doc entity memory layer.

The body always carries an op field; other fields apply per op. The response envelope is uniform: {op, data, hasMore?, nextCursor?, count?, hint?}.

Quick reference

OppathOther fieldsWhat it does
lsfilter, limit, cursorList parsed documents
grepreferenceID (optional)pattern, scope, countOnlySearch across documents
catreferenceIDrange, selectRead a document's parsed content
headreferenceIDnFirst N sections (default 10)
statreferenceID or entityIDMetadata only
findfilter, limit, cursorList canonical entities
openentityIDEntity detail + all mentions
xrefentityIDlimit, cursorSections across docs mentioning an entity

path is the positional identifier. For doc ops (cat, head, stat), pass a referenceID from ls. For entity ops (open, xref), pass an entityID from find. grep optionally takes a path to scope search to one document.

Examples

List documents: {"op": "ls"}

Search one document: {"op": "grep", "path": "my-doc-001", "pattern": "holiday", "scope": "sections"}

Read one page: {"op": "cat", "path": "my-doc-001", "range": {"page": 7}}

Read a page range: {"op": "cat", "path": "my-doc-001", "range": {"pageRange": [5, 10]}}

Project section labels and pages only: {"op": "cat", "path": "my-doc-001", "select": ["sections.label", "sections.page", "sections.type"]}

Preview first 5 sections: {"op": "head", "path": "my-doc-001", "n": 5}

Document metadata: {"op": "stat", "path": "my-doc-001"}

List entities: {"op": "find"}

Entity detail + mentions: {"op": "open", "path": "ent_abc123"}

Cross-document sections for an entity: {"op": "xref", "path": "ent_abc123"}

Key details

range is an object with optional keys: page (integer), pageRange (two-element array [from, to]), sectionTypes (array of strings like ["table", "heading"]).

select is an array of strings — dotted paths like ["sections.label", "sections.page"].

scope (grep) is one of "sections", "entities", "relationships", or "all" (default).

Pagination

List ops (ls, find) paginate by cursor: pass the last item's nextCursor from a previous response to fetch the next page; hasMore: false signals the last page. Same idiom as /v3/calls and /v3/outputs.

POST
/v3/fs
x-api-key<token>

Authenticate using API Key in request header

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

curl -X POST "https://api.bem.ai/v3/fs" \  -H "Content-Type: application/json" \  -d '{    "op": "ls"  }'
{
  "op": "ls",
  "data": null,
  "hasMore": true,
  "nextCursor": "string",
  "count": 0,
  "hint": "string"
}