AI Chat
Understand AI Chat APIs, persistence model, and runtime requirements.
MuseMVP includes an out-of-the-box AI chat feature built on Vercel AI SDK for streaming output, with conversations and messages persisted to PostgreSQL. This guide covers module structure, APIs, and configuration.

Required Runtime Configuration
| Config | Description |
|---|---|
GOOGLE_GENERATIVE_AI_API_KEY | API key from Google AI Studio used to call Gemini models |
config.ai.enabled | Master switch for AI Chat. When false, AI Chat UI entries are hidden, /app/aichat redirects to /app, and /api/aichat/** returns 404 |
config.ai.chatModel | Default is gemini-3-pro-preview, configurable in src/config/index.ts |
Missing AI Key
If GOOGLE_GENERATIVE_AI_API_KEY is not configured, streaming fails immediately and the frontend receives an error prompt.
When You Want to Disable AI Chat
Set config.ai.enabled=false in src/config/index.ts.
This disables the account-side AI Chat entry points without requiring you to delete the module or database tables.
Extending and Customizing
Disable the feature: set config.ai.enabled=false to turn off AI Chat routes and navigation while keeping the code available for later re-enable.
Change model: update config.ai.chatModel or adjust the model call logic in the aichat route.
Integrate another AI provider: replace the Vercel AI SDK generateText call in src/modules/aichat or API routes.
Extend message types: support rich media such as images and files in both database schema and frontend components.
Related Docs
- Tech Stack: Vercel AI SDK — AI capability overview
- API Architecture — Hono routes and middleware