Version 1.0.0 | Made by Clobig
BitGenius is an advanced AI conversational agent that integrates Bitcoin Lightning Network payments for seamless micropayment interactions. Built with Next.js and OpenAI, it enables pay-per-use AI conversations with instant Lightning payments.
- 🤖 AI Conversations: Powered by OpenAI models (GPT-3.5, GPT-4)
- ⚡ Lightning Payments: Instant Bitcoin micropayments for each interaction
- 🔒 HTTP 402 Support: Standard payment-required protocol implementation
- 🎛️ Customizable Agents: Clone and customize for different use cases
- 🔗 Node Integration: Connect your own Bitcoin/Lightning full node
- 📱 Modern UI: Clean, responsive interface with dark theme
- 🔐 Secure: End-to-end payment verification and secure API handling
- Frontend: Next.js 14, React, TypeScript, Tailwind CSS
- Backend: Next.js API Routes, Node.js
- AI: OpenAI API (GPT models)
- Payments: Bitcoin Lightning Network
- Database: Compatible with any SQL/NoSQL database
- Deployment: Vercel, Docker, or self-hosted
- Node.js 18+ and npm/pnpm
- Bitcoin Lightning node (LND, CLN, or Eclair)
- OpenAI API key
git clone https://github.com/your-username/bitgenius.git
cd bitgeniusnpm install
# or
pnpm installcp .env.example .env.localCreate a .env.local file with the following variables:
# OpenAI Configuration
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-4
# Lightning Network Configuration
LND_HOST=localhost:10009
LND_MACAROON_PATH=/path/to/admin.macaroon
LND_TLS_CERT_PATH=/path/to/tls.cert
# Alternative: Use hex-encoded credentials
LND_MACAROON_HEX=your_macaroon_hex_here
LND_TLS_CERT_HEX=your_tls_cert_hex_here
# Application Configuration
NEXT_PUBLIC_APP_URL=http://localhost:3000
PAYMENT_AMOUNT_SATS=10
SESSION_SECRET=your_session_secret_hereDATABASE_URL=postgresql://user:password@localhost:5432/bitgenius
npm run devpnpm dev# Open http://localhost:3000 in your browser
BitGenius supports four main interaction methods:
POST /api/methods
Content-Type: application/json
{
"method": "invoice",
"amount": 100,
"description": "AI Chat Session"
}Response:
{
"success": true,
"invoice": "lnbc100n1...",
"payment_hash": "abc123...",
"expires_at": "2024-01-01T12:00:00Z"
}
POST /api/methods
Content-Type: application/json
{
"method": "sendcode",
"phone": "+1234567890"
}POST /api/methods
Content-Type: application/json
{
"method": "lightning",
"invoice": "lnbc100n1..."
}POST /api/methods
Content-Type: application/json
{
"method": "voice",
"audio_data": "base64_encoded_audio"
}POST /api/chat
Content-Type: application/json
Authorization: Bearer <payment_proof>
{
"message": "Hello, BitGenius!",
"conversation_id": "optional_conversation_id"
}- Client makes request to
/api/chat - Server responds with
402 Payment Requiredand Lightning invoice - Client pays the Lightning invoice
- Client retries request with payment proof
- Server processes the AI interaction
// 1. Request chat (will return 402 if payment needed)
const chatResponse = await fetch('/api/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message: 'Hello!' })
});
if (chatResponse.status === 402) {
// 2. Get payment invoice
const paymentData = await chatResponse.json();
// 3. Pay invoice (using your Lightning wallet)
await payLightningInvoice(paymentData.invoice);
// 4. Retry with payment proof
const paidChatResponse = await fetch('/api/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${paymentProof}`
},
body: JSON.stringify({ message: 'Hello!' })
});
const aiResponse = await paidChatResponse.json();
console.log(aiResponse.message);
}// Configure BitGenius for specific use cases
const agentConfig = {
personality: "helpful coding assistant",
expertise: ["JavaScript", "Bitcoin", "Lightning Network"],
paymentAmount: 50, // sats per interaction
model: "gpt-4"
};
await fetch('/api/configure', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(agentConfig)
});- Push your code to GitHub
- Connect your repository to Vercel
- Add environment variables in Vercel dashboard
- Deploy automatically
docker build -t bitgenius .docker run -p 3000:3000 --env-file .env.local bitgeniusnpm run buildnpm start- Macaroon Security: Store Lightning macaroons securely and use least-privilege access
- Rate Limiting: Implement rate limiting to prevent abuse
- Payment Verification: Always verify Lightning payments before processing requests
- API Keys: Rotate OpenAI API keys regularly
- HTTPS: Use HTTPS in production for secure communication
- Fork the repository
- Modify the AI prompt in
/lib/ai-config.js - Adjust payment amounts and models
- Customize the UI components
- Deploy your custom agent
- Code Assistant: Programming help with Lightning payments
- Content Creator: Writing assistance with micropayments
- Tutor: Educational interactions with pay-per-question
- Consultant: Professional advice with premium pricing
We welcome contributions! Please see our Contributing Guidelines for details.
- 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.
- Documentation: docs.bitgenius.ai
- Issues: GitHub Issues
- Email: info@clobig.com
- OpenAI for providing powerful language models
- Lightning Network developers for enabling instant micropayments
- The Bitcoin community for building the foundation of digital money
- Multi-language support
- Advanced payment routing
- Plugin system for custom integrations
- Mobile app development
- Enterprise features
- Advanced analytics dashboard
Made with ⚡ by Clobig
BitGenius - Where AI meets Bitcoin Lightning