AI Chat Assistant
Configure and use the built-in AI chat panel powered by OpenRouter in this Fumadocs site.
Preview First
The AI chat opens from the floating Ask AI button in the bottom-right corner on both home and docs pages.
What It Does
Answers questions about your docs, can run internal doc search, and streams responses in real time.
Best Query Style
Ask specific questions like: "How do I use Git branching in this site docs?" for better grounded answers.
Important Limitation
AI can be inaccurate. Always verify critical details against source docs.
Configuration
Required Environment Variables
OPENROUTER_API_KEY=your_openrouter_api_key
OPENROUTER_MODEL=minimax/minimax-m2.5:free
OPENROUTER_BASE_URL=https://openrouter.ai/api/v1OPENROUTER_API_KEY is required. OPENROUTER_MODEL and OPENROUTER_BASE_URL are optional and use defaults when unset.
You can place these values in either .env or .env.local. Next.js loads both automatically.
For Netlify/Vercel, set the same variables in the project environment settings (do not commit secrets to git).
API Route
The chat backend is served from /api/chat and streams responses to the UI.
Usage
Open and Ask
Click the floating Ask AI button in the bottom-right corner.
Type your question, then press Enter to send.
Use Shift + Enter for a new line.
Use Retry to regenerate or Clear Chat to reset.
Keyboard Shortcuts
| Action | macOS | Windows/Linux |
|---|---|---|
| Open panel | Cmd + / | Ctrl + / |
| Close panel | Esc | Esc |
| Send message | Enter | Enter |
| New line | Shift + Enter | Shift + Enter |
Internal Components
import { AIChatWidget } from '@/components/ai/chat-widget';
// docs layout
<AIChatWidget mode="docs" />
// home layout
<AIChatWidget mode="overlay" />Troubleshooting
No Response or Error
Check that OPENROUTER_API_KEY, OPENROUTER_MODEL, and OPENROUTER_BASE_URL are present in .env or .env.local, then restart the dev server.
- Confirm the server is running (
pnpm dev). - Open browser devtools and verify
POST /api/chatis successful. - If the API returns an error JSON, fix the missing config and retry.
- If answers are weak, ask a narrower query with clearer domain terms.