A production-ready starter for building a grounded documentation 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, retries, and support escalation
The browser never receives Antfly or model-provider credentials. Retrieval and generation run in server-side Next.js routes.
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
- 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
-
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 |
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— uses OpenAI-backed MCP mode when OpenAI is configured; otherwise tries the native Retrieval Agent before falling back to MCP.
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