Skip to main content
ExuluReadApi provides low-level, RBAC-enforced read functions for knowledge contexts. Where ExuluContext.search() covers relevance-ranked retrieval, ExuluReadApi covers targeted reads by item ID or external ID, embed-query utilities, and table-name resolution — all while applying the same access-control rules as the GraphQL layer. Use ExuluReadApi when you need to read specific known items without going through vector search, or when you need the underlying table names to build custom queries.

API surface

ExuluReadApi.authorizedRead

Reads chunks from a context, joining them to their parent items and applying RBAC via applyAccessControl. At least itemIds or externalIds must be supplied — unconstrained full-table reads are rejected.
context
object
required
The context to read from. Must have an id matching a registered ExuluContext.
user
User
required
Authenticated user. Used for RBAC filtering on the items table.
role
string
required
Role ID. Merged into the user object so access-control’s role branch works correctly.
opts.itemIds
string[]
Filter to chunks whose parent item ID is in this list.
opts.externalIds
string[]
Filter to chunks whose parent item external_id is in this list.
opts.chunkIndexRange
{ from?: number; to?: number }
Restrict to a contiguous range of chunk_index values within the matched items.
return
Promise<VectorSearchChunkResult[]>
Chunk rows with joined item metadata, ordered by (source, chunk_index).

ExuluReadApi.embedQuery

Embeds a text string using the context’s configured embedder model. Returns the embedding vector as a number array.

ExuluReadApi.entitiesAvailable

Returns true when the context declares an entities config and the corresponding _chunk_entities table physically exists. Use this to guard entity tool registration at runtime.

Table-name helpers

Return the Postgres table names used by the given context. Useful when building custom queries directly against the database.

Example

Resolve table names for a custom Knex query:

Notes

  • authorizedRead always applies RBAC via applyAccessControl on the items alias — this gate cannot be bypassed through opts.
  • Results are ordered by (chunks.source, chunks.chunk_index) — stable page order for items with multiple chunks.
  • embedQuery routes through the same resolveEmbedder path as the ingestion pipeline, so LiteLLM cost attribution applies.