The Open Source ChatGPT Alternative - Bring Your Own API Key
π― Mission: Make AI accessible to everyone by providing a free, open-source ChatGPT interface where users control their own API keys and data.
OpenGPT's clean and intuitive interface - bringing the power of ChatGPT with complete privacy and control
- π¬ ChatGPT-like Interface - Familiar and intuitive chat experience
- π Bring Your Own API Key - No subscriptions, use your OpenAI credits directly
- π§ Intelligent Memory System - Advanced conversation context with 4-layer memory architecture
- π± Fully Responsive - Perfect experience on desktop, tablet, and mobile
- β‘ Real-time Streaming - See responses as they're generated, just like ChatGPT
- πΎ Persistent Chat History - All conversations saved locally with full control
- ποΈ Smart Chat Management - Organize with search, rename, delete, and auto-titles
- π― 4-Layer Architecture - Immediate, recent, historical, and important context layers
- π Token Optimization - 85-90% token reduction for long conversations
- π Automatic Summarization - Intelligent compression of conversation history
- π‘ Context Preservation - Never lose important details from past messages
- β‘ Infinite Scalability - Handle 500+ message conversations efficiently
- π Encrypted Local Storage - Your API keys are encrypted and stored locally
- π« Zero Data Collection - We don't see, store, or analyze your conversations
- π Completely Local - All processing happens in your browser
- π‘οΈ XSS Protection - Built-in security against common web vulnerabilities
- π No Server Logging - Your conversations never touch our servers
- π Beautiful Dark Theme - Sleek, modern design that's easy on the eyes
- π Smooth Animations - Polished micro-interactions throughout
- β¨οΈ Keyboard Shortcuts - Power user friendly with Enter to send
- π Markdown Support - Rich text rendering with code highlighting
- π File Upload - Support for text, code, and document files
- ποΈ Model Selection - Choose from GPT-4, GPT-3.5-turbo, and more
- π Model Context Protocol - Extend your agent with external tools and data sources
- π‘ Stdio Servers - Local servers accessed via command line (npx, node, python)
- π HTTP Servers - Remote or local servers with Streamable HTTP transport
- π Environment Variables - Configure API tokens and credentials securely
- π οΈ Tool Discovery - Automatically discover and display available tools
- ποΈ Tool Visibility - See all tool calls in real-time with collapsible dropdowns
- β‘ Persistent Connections - Servers connect once and stay alive
- π Tool Results - View arguments, results, and visited URLs
- Node.js 18+ - Download here
- OpenAI API Key - Get yours here
- Clone the repository
git clone https://github.com/RaheesAhmed/OpenGPT.git
cd OpenGPT- Install dependencies
npm install
# or
yarn install
# or
pnpm install- Run the development server
npm run dev
# or
yarn dev
# or
pnpm dev-
Open your browser
Navigate to http://localhost:3000
-
Add your API key
Click the settings icon and securely add your OpenAI API key
That's it! Start chatting with AI while maintaining complete control over your data.
// Your API key workflow:
1. Enter API key in settings β
2. Encrypted with AES-256 β
3. Stored locally in browser β
4. Never sent to our servers β
5. Used directly with OpenAI API// 4-Layer Memory System:
Layer 1: Immediate Context (5-8 messages) // 800-1200 tokens
Layer 2: Recent Chunks (summarized) // 600-900 tokens
Layer 3: Historical Summary (compressed) // 400-600 tokens
Layer 4: Important Messages (preserved) // 200-400 tokens
Total: ~3k tokens (regardless of conversation length)// Local Browser Storage:
βββ Encrypted API Keys
βββ Chat Messages (by conversation ID)
βββ Memory Context (intelligent summaries)
βββ User Preferences
βββ No server-side data (100% local)- Framework: Next.js 15+ (App Router)
- Language: TypeScript (Strict Mode)
- Styling: Tailwind CSS + shadcn/ui
- State Management: React Hooks + Local Storage
- Memory System: Custom intelligent context management
- Security: AES-256 encryption for API keys
- Deployment: Vercel-ready with Docker support
βββ app/ # Next.js App Router
β βββ api/ # API routes (chat, models)
β βββ globals.css # Global styles
β βββ page.tsx # Main chat interface
βββ components/ # React components
β βββ ui/ # shadcn/ui components
β βββ chat-sidebar.tsx # Chat management
β βββ sidebar.tsx # Expanded sidebar
β βββ mini-sidebar.tsx # Collapsed sidebar
β βββ model-selector.tsx # AI model selection
βββ lib/ # Utility functions
β βββ chat-memory.ts # Memory system
β βββ utils.ts # Helper functions
βββ public/ # Static assets
All models from OpenAI are supported
const DEFAULT_CONFIG = {
model: "gpt-4o-mini",
temperature: 0.7,
streaming: true,
memoryEnabled: true,
autoTitle: true,
};- Click the button above
- Fork the repository
- Deploy automatically
- Start using immediately!
# Build for production
npm run build
# Start production server
npm start# Build the image
docker build -t opengpt .
# Run the container
docker run -p 3000:3000 opengptPerfect for complete privacy! Deploy on your own server:
# Clone and build
git clone https://github.com/RaheesAhmed/OpenGPT.git
cd OpenGPT
npm install
npm run build
# Run with PM2 (recommended)
pm2 start npm --name "opengpt" -- startWe welcome contributions! Here's how you can help:
Found a bug? Please create an issue with:
- Clear description of the problem
- Steps to reproduce
- Expected vs actual behavior
- Screenshots if applicable
Have an idea? We'd love to hear it! Please include:
- Clear description of the feature
- Use case and benefits
- Any implementation ideas
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes
- Test thoroughly
- Commit with clear messages:
git commit -m 'Add amazing feature' - Push to your branch:
git push origin feature/amazing-feature - Open a Pull Request
- Use TypeScript for all new code
- Follow existing code style and patterns
- Add comments for complex logic
- Test your changes thoroughly
- Update documentation if needed
- π¬ GitHub Discussions: Ask questions & share ideas
- π Issues: Report bugs
- π§ Email: [email protected]
β Is my API key safe? β Yes! Your API key is encrypted and stored only in your browser. We never see it.
β Do you collect my conversations? β No! All conversations stay on your device. Zero data collection.
β Can I use this offline? β You need internet for API calls to OpenAI, but your data stays local.
β Which models are supported? β All OpenAI models: GPT-4, GPT-4 Turbo, GPT-4o, GPT-3.5 Turbo, and more.
β Can I export my chats? β Yes! Your chats are saved locally and can be backed up from browser storage.
β Is this really free? β Completely free! You only pay OpenAI for your API usage.
| Feature | OpenGPT | ChatGPT Plus | Other Alternatives |
|---|---|---|---|
| Cost | Free + Your API | $20/month | Varies |
| Privacy | 100% Local | Data collected | Usually collected |
| API Key Control | You own it | N/A | Rarely |
| Customization | Full control | Limited | Limited |
| Open Source | β MIT License | β Closed | Rarely |
| Memory System | Advanced 4-layer | Basic | Basic |
| Self-Hosting | β Yes | β No | Rarely |
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI - For the incredible GPT models
- Vercel - For Next.js and amazing deployment platform
- shadcn - For beautiful UI components
- The Open Source Community - For inspiration and contributions
Made with β€οΈ by Rahees Ahmed
β Star us on GitHub if you find this project useful!
π Live Demo | Documentation | Contributing
"AI should be accessible to everyone, with complete privacy and control." - OpenGPT Mission
