# AI Integration

URL: https://whitepaper.designervenkat.online/docs/ai-machine-learning/ai-integration
Markdown: https://whitepaper.designervenkat.online/llms.mdx/docs/ai-machine-learning/ai-integration
Site: White Papers - Designer Venkat
Author: Designer Venkat
Language: en

Expose your content to coding agents and chat models via /llms.txt and Markdown endpoints.





Coding agents are now a primary audience for documentation. Claude, Cursor, and GitHub Copilot all read docs when answering questions about a library — but only if those docs are exposed in a way agents can consume.

## The /llms.txt convention [#the-llmstxt-convention]

Anthropic, Cloudflare, and a growing list of sites have standardized on a simple pattern: a text endpoint at `/llms.txt` that lists every page on the site in Markdown, with links to full-text versions.

This site exposes two endpoints:

<Cards>
  <Card icon="<FileText />" title="/llms.txt" href="/llms.txt">
    A directory — every page's title, URL, and one-line description.
  </Card>

  <Card icon="<Globe />" title="/llms-full.txt" href="/llms-full.txt">
    The full text of every page concatenated, ready for an agent to ingest in one fetch.
  </Card>
</Cards>

<Callout type="info" title="When to use which">
  Use `/llms.txt` for agents that can navigate (they'll fetch individual pages on demand).
  Use `/llms-full.txt` when an agent needs to load the whole library into context at once —
  for a code review on a small codebase, for instance.
</Callout>

## How they're built [#how-theyre-built]

Both endpoints are static Next.js routes. The directory is one line per page; the full version concatenates the rendered Markdown.

```ts title="app/llms.txt/route.ts"
import { source } from "@/lib/source";
import { llms } from "fumadocs-core/source";

export const revalidate = false;

export function GET() {
  return new Response(llms(source).index());
}
```

```ts title="app/llms-full.txt/route.ts"
import { source } from "@/lib/source";
import { getLLMText } from "@/lib/get-llm-text";

export const revalidate = false;

export async function GET() {
  const pages = source.getPages();
  const scanned = await Promise.all(pages.map(getLLMText));
  return new Response(scanned.join("\n\n"), {
    headers: { "Content-Type": "text/plain; charset=utf-8" },
  });
}
```

`revalidate: false` makes these endpoints fully static — they're generated at build time and never re-run.

## Why static text instead of HTML? [#why-static-text-instead-of-html]

Three reasons:

1. **Token cost.** Stripping HTML cuts the size by 60–80% on a typical page. For an agent paying per-token to ingest your docs, that's the difference between a viable read and an abandoned one.
2. **Parser robustness.** Markdown has fewer edge cases than HTML. Less ambiguity means fewer parse errors in the agent.
3. **Cache friendliness.** Plain text compresses better and serves from edge caches without negotiation headers.

## Customizing what agents see [#customizing-what-agents-see]

The `getLLMText` function in `lib/get-llm-text.ts` decides what goes into `/llms-full.txt`. The default is title + description + body, but you can:

* **Strip code blocks** if your audience is a doc-querying chat and not a code-completion model
* **Add metadata** — last-updated date, tags, author — that doesn't appear in the user-facing page
* **Filter pages** — exclude internal docs, draft folders, or 404s

```ts title="lib/get-llm-text.ts"
export async function getLLMText(page) {
  const description = page.data.description
    ? `\n> ${page.data.description}\n`
    : "";
  return `# ${page.data.title} (${page.url})${description}`;
}
```

<Callout type="warn" title="Privacy">
  These endpoints make your content trivially scrapable. If any of your docs are sensitive — internal architecture, security postures — make sure they're behind auth and not in the index.
</Callout>

## Future: native chat integration [#future-native-chat-integration]

Fumadocs is working on a `<AskAI>` widget that mounts directly in the sidebar — readers ask questions in plain English and get answers grounded in the site's content. It uses the same `/llms-full.txt` endpoint as a context source.

Track the [Fumadocs AI integrations](https://fumadocs.dev/docs/integrations) page for the latest.
