Status: foundation implementation based on the production-ready Next.js support-agent reference.
A Next.js/Vercel starter for building a customer-owned knowledge base, documentation search experience, and grounded support agent with:
- Next.js and React
- Antfly Cloud tables, full-text search, vector search, and MCP retrieval
- OpenAI or a chat-capable model served through Antfly Inference
- Vercel deployment
- Source citations, feedback, rate limiting, bounded failure handling, and support escalation
- Reusable
⌘K/Ctrl+Ksupport command palette with an embedded chat modal - A server-only deployment-readiness dashboard at
/admin
The current foundation provides the production support-agent path. Website,
GitHub, and file connectors; conventional search; durable conversations;
analytics; content-gap detection; and escalation adapters are the next staged
modules. Their product boundary and release gates are maintained in the
knowledge-support entry in the Antfly template library.
The browser never receives Antfly or model-provider credentials. Retrieval and generation run in server-side Next.js routes.
The reference page mounts SupportCommandPalette once alongside the full-page
chat. It provides a visible Ask Antfly button and opens the same support
experience with ⌘K on macOS or Ctrl+K on Windows/Linux:
import { SupportCommandPalette } from "@/components/support-command-palette";
export default function LayoutContent() {
return (
<>
<YourSiteContent />
<SupportCommandPalette />
</>
);
}The shortcut is ignored while focus is in an input, textarea, select, or editable element. Escape, the close button, and clicking the backdrop close the modal. The component is intentionally in-site: launching it from every website would require a browser extension or another browser-level surface.
Documentation and knowledge sources
↓
Antfly extraction, chunking, full-text and vector indexes
↓
Antfly MCP retrieval
↓
OpenAI or Antfly Inference generation
↓
Next.js API routes on Vercel
↓
Grounded answer, citations, feedback and escalation
Specific technical questions start with one Antfly hybrid query: BM25 and semantic search run together, and Antfly fuses the rankings with RRF. Broad conceptual questions use semantic-first retrieval so exact-match API and schema pages do not displace product overviews. Queries return document chunks rather than source-record metadata. When evidence is empty or insufficient, the server may make one focused fallback query; it never fans out parallel MCP calls.
- An Antfly Cloud instance
- A table containing your documentation
- A full-text index and an embeddings index for the extracted chunks
- An instance-scoped, read-only Antfly API key
- Either:
- an OpenAI API key, or
- a chat-capable model available through Antfly Inference
- Node.js 20 or newer
See Antfly setup for the complete data and retrieval checklist.
-
Install dependencies:
npm install
-
Create local configuration:
cp .env.example .env.local
-
Replace the example Antfly URLs, key, table, and index names in
.env.local. -
Check the live Antfly connection:
npm run inspect:antfly
Measure cold and warm MCP latency with
npm run benchmark:mcp. See MCP performance and observability. -
Start the application:
npm run dev
-
Open http://localhost:3000.
| Variable | Purpose |
|---|---|
ANTFLY_MCP_URL |
Hosted Streamable HTTP MCP endpoint ending in /mcp/v1 |
ANTFLY_INFERENCE_URL |
Hosted inference base URL; required only for Antfly-hosted generation |
ANTFLY_API_KEY |
Instance-scoped Antfly Cloud token, without the Bearer prefix |
ANTFLY_TABLE |
Documentation table |
ANTFLY_VECTOR_INDEX |
Embeddings index used for semantic retrieval |
ANTFLY_SEARCH_FIELD |
Full-text field on extracted chunks; normally text |
SUPPORT_PRODUCT_NAME |
Product the agent supports |
SUPPORT_PRODUCT_ALIASES |
Optional comma-separated product names used to recognize broad questions |
OPENAI_API_KEY or ANTFLY_INFERENCE_MODEL |
Final answer generation |
Every supported setting is documented in .env.example.
mcp— recommended starter mode. Uses Antfly MCP retrieval, then the configured generator.agent— uses Antfly's native Retrieval Agent endpoint.auto— prefers the native Retrieval Agent whenANTFLY_INFERENCE_MODELis configured, then falls back to MCP. Without that model it uses MCP directly.
Pin ANTFLY_RETRIEVAL_MODE to agent or mcp in production so adding a
generation credential cannot silently change the retrieval path. Broad product
questions use semantic-first retrieval with an expanded query and may make one sequential quality
fallback when the first result set lacks coverage of core product concepts.
The template connects only to retrieval tools. It does not expose Antfly write or administration tools to the browser or model.
GENERATION_PROVIDER=openai
OPENAI_API_KEY=...
OPENAI_MODEL=gpt-5-miniAntfly still performs document storage, extraction, chunking, embeddings, full-text indexing, vector indexing, and retrieval. OpenAI only writes the final answer from the retrieved evidence.
GENERATION_PROVIDER=antfly
ANTFLY_INFERENCE_MODEL=your-chat-modelRun npm run inspect:antfly first and choose a model that supports chat generation. An embeddings-only model cannot generate the final response.
See Vercel deployment for the complete workflow.
At a minimum:
- Push this project to GitHub.
- Import it into Vercel.
- add the
.env.examplevariables to the Vercel project. - Deploy.
- Confirm
GET /api/healthreturnsstatus: ready. - Run several questions before adding a production domain.
Branding, suggestions, support escalation, source links, and model instructions are configurable. See Customization.
- Use a dedicated, instance-scoped, read-only Antfly key.
- Never add credentials to
NEXT_PUBLIC_*variables. - Keep
.env.local,.vercel, and deployment credentials out of Git. - Rotate any key copied from a prototype before public launch.
- Add a Vercel Firewall rule or shared rate-limit store for high-traffic public deployments. The included in-memory limit is per serverless instance.
- Review generated answers and citations before using the agent for regulated or high-stakes support.
See Troubleshooting for authentication errors, empty retrieval results, model problems, timeouts, and citation-link configuration.
Apache-2.0