grepticon/
Sign inGet started
← All writing
Guide

Add AI to your Fumadocs site in ten minutes

Give your documentation an agent, and your readers can ask it questions instead of hunting for the right page. It answers by reading your docs: searching them, opening the pages that match, and linking the ones it used.

The whole integration is two files: a script that syncs your pages into a Grepticon workspace every time you change your Fumadocs documentation, and one API route that hands the agent its read tools.

An assistant for your documentation

A floating Ask AI button on every docs page. Someone asks a question in their own words, and the agent works through your documentation in front of them: grep for the terms in the question, find the files that mention them, cat the two that matter, then an answer that links the pages it opened.

Because it reads the pages themselves, it handles questions that span several of them, which is most of what people actually ask. “How do I authenticate, and what happens when I hit a rate limit” is two pages and one answer.

Because every synced file carries its own page URL, the links in that answer are real pages from your site rather than URLs the model assembled.

Why an agent filesystem instead of embeddings

A vector pipeline decides what is relevant once, before the model sees anything, and the model is stuck with that guess. Here the model retrieves for itself, as many times as the question takes, with four commands it already understands from its training data: ls, find, cat, and grep.

That means no embedding pass on every deploy, no vector store to host, and no index to keep in sync. A page you edit is answerable the moment it syncs, and a page you delete stops being citable on the same deploy.

It also means retrieval is exact. grep matches bytes, which matters when the answer is one flag name among forty near-identical ones. See our experiment on how grep compares to naive RAG: Agent filesystem beats naive RAG on retrieval accuracy.

What you need

You only need three components to get started:

  • Grepticon account: Sign up for a free Grepticon account, then create a workspace and an API key.
  • LLM provider: Sign up for any LLM provider of your choice to power the agent. We’ll be using OpenRouter for this setup, and any tool-capable model works.
  • Fumadocs documentation: A docs site built with Fumadocs.

The integration

Fumadocs ships the chat UI itself. One command installs the Ask AI dialog, its streaming markdown renderer, a starter /api/chat route, and the AI SDK packages:

npx @fumadocs/cli add ai/openrouter
npm install @grepticon/sdk

What it does not ship is retrieval. That is the part you add.

1. Sync your pages into a workspace

First let Fumadocs hand you each page as clean Markdown, which is one setting on the defineDocs call your starter already has:

export const docs = defineDocs({
  dir: 'content/docs',
  docs: {
    postprocess: { includeProcessedMarkdown: true },
  },
});

Each page then becomes one Markdown file. The title goes first, then the page’s absolute URL on its own line, then the content. That URL line is what lets the agent cite a real link without any path-to-URL mapping on your side.

for (const page of source.getPages()) {
  const path = `docs${page.url === '/' ? '/index' : page.url}.md`;
  const body = await page.data.getText('processed');

  await client.files.upload(
    WORKSPACE,
    path,
    `# ${page.data.title}\n\n${SITE}${page.url}\n\n${body}`,
    { contentType: 'text/markdown' },
  );
}

2. Hand the agent the read tools

The SDK ships the four commands as AI SDK tools already, so this is one call:

const session = new GrepticonClient({
  apiKey: process.env.GREPTICON_TOKEN!,
}).session('docs-corpus');

const tools = createVfsTools(session); // ls, find, cat, grep

3. Let it loop

Replace the body of the generated route with a streamText call that gets those tools:

const result = streamText({
  model: openrouter.chat('moonshotai/kimi-k2'),
  instructions,
  messages: await convertToModelMessages(messages ?? []),
  tools,
  stopWhen: stepCountIs(10),
});

The instructions tell the agent how to read the corpus and how to cite it: explore with grep and find, cat what matches, and cite a source only by copying the URL printed at the top of a file it actually read.

That is the whole backend. The full guide has every file end to end.

Keeping it current

Run the sync script on every deploy so the corpus tracks your main branch:

on:
  push:
    branches: [main]
    paths: ['content/docs/**', 'scripts/sync-docs.ts']

Changed pages are re-uploaded and deleted pages are removed, so the agent never answers from a page you have taken down.

Common questions

How do I add AI chat to a Fumadocs site?
Fumadocs ships the dialog: npx @fumadocs/cli add ai/openrouter installs the chat UI, its markdown renderer, and a starter /api/chat route. You supply retrieval by syncing your pages somewhere the model can read them and handing the model tools to read with. On Grepticon that is a sync script and one route.
Do I need a vector database for a docs AI assistant?
No. A documentation corpus is small enough that an agent can search it directly with grep and find, then read the matching files with cat. Embeddings buy you fuzzy matching over very large record sets, which a docs tree is not, and they cost you an index to build, keep fresh, and re-embed on every edit.
How much does it cost to run?
The loop is grep-and-read rather than reasoning, so a cheap tool-capable open model handles it; we run Kimi K2 through OpenRouter. On the retrieval side there is no embedding pass, no vector store to host, and no sandbox per session, so nothing scales with corpus size the way a re-indexing pipeline does.
Can I do this if my docs are not on Fumadocs?
Yes. Only the sync step is Fumadocs-specific: it walks the page source for each page’s title, URL, and Markdown. Docusaurus, VitePress, Nextra, or a directory of Markdown files all work the same way once you can produce those three things.

Get started

The Fumadocs guide is the whole integration, and the quickstart hands your agent the four commands. Signup is free.