A sophisticated multimodal chat application that supports text, images, audio, and web search across multiple AI providers including OpenAI, Anthropic, and xAI.
- Multi-Agent Chains: Create sequences of AI agents with different models and capabilities
- Real-time Streaming: Live streaming responses from AI models
- Session Management: Persistent chat sessions with full history
- Model Switching: Support for OpenAI, Anthropic Claude, and xAI Grok models
- Image Upload & Analysis: Upload and analyze images with vision-capable models
- Voice Recording & Transcription: Record audio messages with automatic transcription
- Web Search Integration: Search the web and include results in AI context
- File Storage: Secure file storage with Convex backend
- Smart Model Detection: Automatic capability detection based on selected model
- Professional UI: Modern, responsive interface with dark theme
- Error Handling: Comprehensive error handling and user feedback
- Type Safety: Full TypeScript implementation
- Frontend: Next.js 15, React 18, TypeScript, Tailwind CSS
- Backend: Convex (database & file storage)
- AI Providers: OpenAI, Anthropic, xAI
- Audio Processing: Web Audio API, OpenAI Whisper
- File Handling: React Dropzone, Image compression
Before setting up the application, you'll need:
- Node.js (v18 or higher)
- npm or yarn
- Convex Account - Sign up at convex.dev
- API Keys (at least one):
- OpenAI API Key - Get from OpenAI
- Anthropic API Key - Get from Anthropic
- xAI API Key - Get from xAI
git clone <repository-url>
cd chain-chat
npm install# Install Convex CLI globally
npm install -g convex
# Initialize Convex in your project
npx convex dev
# Follow the prompts to create a new Convex project
# This will create a .env.local file with CONVEX_DEPLOYMENT and NEXT_PUBLIC_CONVEX_URLCreate a .env.local file in the root directory:
# Convex (automatically generated by convex dev)
CONVEX_DEPLOYMENT=your-deployment-name
NEXT_PUBLIC_CONVEX_URL=https://your-deployment.convex.cloud
# AI Provider API Keys (add at least one)
OPENAI_API_KEY=sk-your-openai-key
ANTHROPIC_API_KEY=sk-ant-your-anthropic-key
XAI_API_KEY=xai-your-xai-key
# Optional: For production web search (currently using mock data)
# GOOGLE_SEARCH_API_KEY=your-google-api-key
# GOOGLE_SEARCH_ENGINE_ID=your-search-engine-id# Push the database schema to Convex
npx convex deploynpm run devThe application will be available at http://localhost:3000
Visit http://localhost:3000/test to run the multimodal integration tests. This will verify:
- β Image upload API functionality
- β Audio transcription API (requires OpenAI API key)
- β Web search API
- β LLM integration setup
- β Streaming agent configuration
- Add Agents: Click the "+" button to add new agents to your chain
- Select Models: Choose from available AI models based on your API keys
- Add Multimodal Content:
- π Images: Click the paperclip icon to upload images
- π€ Audio: Click the microphone to record voice messages
- π Web Search: Click the search icon to search the web
- Run Chain: Click "Run Chain" to execute all agents in sequence
| Provider | Models | Text | Vision | Audio | Web Search |
|---|---|---|---|---|---|
| OpenAI | GPT-4o | β | β | β | β |
| OpenAI | GPT-4o Mini | β | β | β | β |
| OpenAI | GPT-4 Turbo | β | β | β | β |
| Anthropic | Claude 3.5 Sonnet | β | β | β | β |
| Anthropic | Claude 3.5 Haiku | β | β | β | β |
| xAI | Grok Beta | β | β | β | β |
- POST
/api/upload-file - Handles image and audio file uploads
- Integrates with Convex file storage
- Supports validation and compression
- POST
/api/transcribe-audio - Uses OpenAI Whisper for speech-to-text
- Supports multiple audio formats
- Returns transcription with timing data
- POST
/api/web-search - Currently returns mock search results
- Ready for integration with real search APIs
- Supports structured search result format
- POST
/api/stream-agent - Real-time streaming responses
- Supports all AI providers
- Handles multimodal context
- POST
/api/run-chain - Executes multi-agent chains
- Processes multimodal attachments
- Stores results in database
// Chat Sessions
chatSessions: {
_id: Id<"chatSessions">
_creationTime: number
title: string
userId?: string
}
// Agent Steps
agentSteps: {
_id: Id<"agentSteps">
sessionId: Id<"chatSessions">
index: number
model: string
prompt: string
response?: string
isComplete: boolean
isStreaming: boolean
error?: string
tokenUsage?: TokenUsage
}
// Attachments
attachments: {
_id: Id<"attachments">
sessionId: Id<"chatSessions">
agentStepId?: Id<"agentSteps">
type: "image" | "audio"
fileName: string
fileSize: number
mimeType: string
storageId: Id<"_storage">
metadata: ImageMetadata | AudioMetadata
}components/
βββ agent-input.tsx # Main agent configuration component
βββ chat-area.tsx # Chat display and history
βββ ui/
β βββ AttachmentDisplay.tsx # Multimodal content display
βββ modality/
βββ ImageUpload.tsx # Image upload and preview
βββ VoiceRecorder.tsx # Audio recording interface
βββ WebSearch.tsx # Web search interface
βββ ModalityIcons.tsx # Modality selection icons
- API keys are stored securely in environment variables
- File uploads are validated for type and size
- Convex handles secure file storage
- All API endpoints include error handling
- TypeScript ensures type safety throughout
-
Connect to Vercel:
npm install -g vercel vercel
-
Configure Environment Variables in Vercel dashboard:
- Add all environment variables from
.env.local - Ensure Convex deployment is set to production
- Add all environment variables from
-
Deploy Convex to Production:
npx convex deploy --prod
- Set up production Convex deployment
- Configure production API keys
- Set up real web search API (Google Custom Search, Bing, etc.)
- Configure proper CORS settings
- Set up monitoring and logging
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues:
- Check the troubleshooting section
- Review the API documentation
- Run the integration tests at
/test - Check the browser console for errors
- Verify your API keys and environment variables
"Cannot find module" errors:
rm -rf node_modules package-lock.json
npm installConvex connection issues:
npx convex dev
# Follow the setup prompts againAPI key errors:
- Verify API keys are correctly set in
.env.local - Check API key permissions and quotas
- Ensure keys are not expired
File upload failures:
- Check file size limits (10MB for images, 25MB for audio)
- Verify supported file formats
- Check Convex storage configuration
Built with β€οΈ using Next.js, Convex, and modern AI APIs.
This project uses HTML5 video elements for optimal performance and reliability:
- β Simple & Fast: No complex video processing or API routes
- β Vercel Ready: Videos deploy automatically with your app
- β CDN Optimized: Served through Vercel's global CDN
- β Git Friendly: Demo video included, large videos excluded
- β Performance: Optimized bundle size (12.6 kB landing page)
- Demo Video:
public/videos/chained_demo.mp4(included in Git) - Future Videos: Add to
.gitignoreto exclude large files from Git
-
Clone the repository
git clone <your-repo-url> cd chain-chat
-
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env.local # Add your API keys and configuration -
Run development server
npm run dev
-
Build for production
npm run build
-
Connect to Vercel
- Push code to GitHub/GitLab/Bitbucket
- Connect repository to Vercel dashboard
- Set environment variables in Vercel dashboard
-
Automatic Deployment
- Videos are automatically deployed with your app
- Served through Vercel's global CDN
- No additional configuration needed
See VERCEL_DEPLOYMENT.md for detailed deployment instructions.
NEXT_PUBLIC_CONVEX_URL=your_convex_url
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_key
CLERK_SECRET_KEY=your_clerk_secret
# ... other environment variables- Framework: Next.js 15.3.3
- Database: Convex
- Authentication: Clerk
- Styling: Tailwind CSS
- Video: HTML5 video elements
- Deployment: Vercel
βββ app/ # Next.js app directory
βββ components/ # React components
βββ convex/ # Convex database functions
βββ lib/ # Utility functions
βββ public/ # Static assets
β βββ videos/ # Video files
βββ VERCEL_DEPLOYMENT.md # Deployment guide
βββ VIDEO_MANAGEMENT.md # Video management guide
- Landing Page: 12.6 kB (optimized)
- Video Loading: CDN-optimized with caching
- Build Time: ~12 seconds
- Bundle Size: Optimized for production
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
- Check
VERCEL_DEPLOYMENT.mdfor deployment issues - Check
VIDEO_MANAGEMENT.mdfor video-related questions - Open an issue for bugs or feature requests
[Your License Here]