Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
A Next.js RAG chatbot template using the AI SDK middleware for retrieval-augmented generation and guardrails.
Internal Knowledge Base Preview is a Next.js starter template from Vercel Labs that demonstrates retrieval-augmented generation (RAG) and guardrail enforcement through the AI SDK's language model middleware. It is a working example that turns internal documents into a question-answering chatbot, with a public GitHub repository that has collected 318 stars.
Internal Knowledge Base Preview is a chatbot template built for internal knowledge management. It takes a user's natural-language question, retrieves relevant context from a document store, and returns a grounded answer generated by a language model from providers like OpenAI or Anthropic. The template runs on Next.js and relies on the AI SDK to connect to models, with middleware that intercepts requests to add retrieval and guardrail logic.
The template boots via create-next-app with the example repository URL. After signing up for AI provider accounts and setting API keys, you copy .env.example to .env, install dependencies with npm install, and start the development server with npm run dev. The middleware intercepts each language model call, retrieves relevant documents, and applies guardrails before returning the final response.
The example lists OPENAI_API_KEY and AUTH_SECRET as required, plus storage configuration for Vercel Blob and Postgres. You can find the exact keys in the .env.example file in the repository.
The setup mentions signing up for providers such as OpenAI and Anthropic. Because the AI SDK supports many providers, you can switch by updating the environment variables and model configuration.
Yes, it's published by Vercel Labs, the experimental arm of Vercel, and is part of the AI SDK preview examples.
Yes, the README includes a Deploy with Vercel button that clones the repository and sets up the required Blob and Postgres stores.
