Grid docs

Build retrieval into your agent runtime

Grid is an in-process search layer for conversational AI. You pack knowledge into an index, load it next to your agent, and query in milliseconds—without standing up a remote vector cluster on the hot path.

Overview

Most agent lag comes from retrieval: each lookup hops to a remote database, adding latency and cost. Grid keeps the index in memory beside your process so a search is a local function call.

  • Hybrid semantic + keyword retrieval
  • Optional local embeddings or bring-your-own vectors
  • Same API in browser (WASM), Node, Python, and on-device
  • Cloud packaging and hot-swap updates when you want sync

Core concepts

Index
A portable artifact of documents, embeddings, and metadata. One project can hold many indexes (docs, playbooks, FAQs).
Runtime
The library embedded in your app. It downloads (or opens) an index, holds it in memory, and serves queries locally.
Session
A short-lived, writable index for live calls—notes, transcript snippets, or user-specific facts that sync when the turn ends.
Project
Your workspace credentials. Used to publish indexes and authorize SDK access.

Quickstart

  1. Create a project and copy your project ID and key.
  2. Ingest documents (Markdown, HTML, or JSON) into an index.
  3. Install the SDK for your runtime and load the index once.
  4. Query on every agent turn; pass top hits into your prompt.
import { Grid } from "@grid-dev/runtime";

const grid = await Grid.connect({
  projectId: process.env.GRID_PROJECT_ID,
  projectKey: process.env.GRID_PROJECT_KEY,
});

await grid.loadIndex("product-docs");

const hits = await grid.query({
  index: "product-docs",
  text: "What is the refund window?",
  topK: 3,
});

Indexing

Push sources through the Grid console or API. Grid chunks text, embeds with a bundled model (or your vectors), and packs a single downloadable index.

  • Chunking — aim for self-contained passages (roughly 200–500 tokens) with stable IDs.
  • Metadata — attach product, locale, or tier so queries can filter before ranking.
  • Updates — republish the index; runtimes hot-swap without dropping in-flight sessions.

Querying

After loadIndex, each query embeds the text (if needed) and searches in-process. Prefer hybrid mode for product language and proper nouns.

const hits = await grid.query({
  index: "support-playbook",
  text: userUtterance,
  mode: "hybrid",
  filter: { locale: "en-US" },
  topK: 5,
});

Typical in-memory lookups land in single-digit milliseconds once the index is warm. Network time only appears when hydrating or syncing.

Live sessions

Open a session when a call starts. Index ephemeral context as the conversation unfolds, query it together with long-lived indexes, then flush or discard when the call ends.

const session = await grid.openSession({ name: "call-4821" });
await session.add({ id: "note-1", text: "Caller asked about SKU-19." });
const local = await session.query({ text: "SKU-19", topK: 2 });

SDKs

Surface Package Best for
Node.js @grid-dev/runtime Server agents & copilots
Browser @grid-dev/runtime-web Static sites, extensions
Python grid-runtime Voice pipelines & notebooks

Limits & tips

  • Load indexes at process start; reuse them across turns.
  • Keep hot indexes sized for memory—split large corpora by product or locale.
  • Production projects require a corporate work email on Get started.
  • Prefer waitlist access via corporate signup if your org is not provisioned yet.