Add GitHub Copilot API proxy integration to LLM Gateway: * Implement copilot-bridge service: - HTTP wrapper managing copilot-api (GitHub Copilot API proxy) - OpenAI-compatible /v1/chat/completions endpoint (port 3252) - Graceful startup and SIGTERM shutdown handling - Health check endpoint with service diagnostics * Register copilot-bridge in provider fallback chain: - Position: After OpenAI, before free LLM APIs (tier 4) - Rate limit: 60 requests/min (GitHub Copilot API limit) - Models: gpt-4 (reasoning), gpt-3.5-turbo (medium) - Authentication: GitHub Copilot subscription (internal to copilot-api) * Update PM2 ecosystem configuration: - Add copilot-bridge service definition (port 3252) - Configure COPILOT_BRIDGE_URL in gateway environment - Add copilot to LLM_PROVIDERS list * Enhance deployment automation: - Update ensure-bridges.sh with copilot-bridge deployment - Copy service files from repo to /opt/copilot-bridge - Run npm install for copilot-api dependency * Comprehensive documentation: - Expand DEPLOYMENT-BRIDGES.md with copilot-bridge section - Prerequisites: Node.js 20+, GitHub Copilot subscription - Authentication workflow: npm run auth with GitHub OAuth - Troubleshooting: subscription verification, auth cache reset Provider chain now supports: 1. Ollama (local, free) 2. claude-bridge (Claude subscription) 3. openai-bridge (OpenAI subscription) 4. copilot-bridge (GitHub Copilot subscription) ← NEW 5. Free APIs: Cerebras, Groq, Mistral, NVIDIA, Cloudflare Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
4.9 KiB
4.9 KiB
OpenAI/ChatGPT Integration Status
✅ COMPLETED
Code Implementation
-
openai-bridge service created at
/openai-bridge/with Node.js HTTP server- Wraps OpenAI CLI (
openai api chat.completions.create) - Provides OpenAI-compatible
/v1/chat/completionsendpoint - Port: 3251 (configurable via OPENAI_BRIDGE_PORT)
- Health check:
GET /health
- Wraps OpenAI CLI (
-
external-providers.ts updated with new providers
openai-bridge: GPT-4 Turbo, GPT-4, GPT-3.5-Turbo (rate limit: 90 req/min)chatgpt-bridge: Same models, alternative routing path- Both properly configured for auth via OPENAI_API_KEY
- No Authorization header for bridge services (handled internally)
-
ecosystem.config.cjs configured
- openai-bridge PM2 app definition added
- Environment variables set up for OPENAI_API_KEY, port, model
- Integrated with llm-gateway and llm-learning services
-
Deployment automation
ensure-bridges.sh: Idempotent startup script- Auto-deploys openai-bridge on first run
- Handles /opt/openai-bridge directory creation
- Production-ready with timestamps and status logging
-
Documentation
DEPLOYMENT-BRIDGES.md: Complete deployment guide- Prerequisites, setup steps, configuration, verification
- Troubleshooting guide with common issues and solutions
- Integration details with fallback chain
Build & Testing
- Build verification:
npm run buildpasses without errors - Type checking: All TypeScript files compile successfully
- Git commits: Changes pushed to Gitea
Commits
afe3597 feat: add automated bridge deployment script and comprehensive deployment guide
7599f33 feat: integrate OpenAI Codex and ChatGPT as primary LLM providers via subscription
e128d39 chore: add openai-bridge deployment script for Erik
🚀 READY FOR DEPLOYMENT
Next Steps on Erik (192.168.178.82)
-
Pull latest code
cd /opt/llm-gateway git pull origin main -
Run deployment automation
bash scripts/ensure-bridges.shOr manually:
mkdir -p /opt/openai-bridge cp openai-bridge/server.js /opt/openai-bridge/ cp openai-bridge/package.json /opt/openai-bridge/ -
Configure API Key Edit
/opt/llm-gateway/deploy/ecosystem.config.cjs:OPENAI_API_KEY: 'sk-proj-your-key-here' -
Deploy with PM2
pm2 start deploy/ecosystem.config.cjs --update-env -
Verify
curl http://localhost:3251/health
📊 Provider Fallback Chain
Request → Gateway
↓
1. Ollama (local, if available)
2. claude-bridge (Claude subscription)
3. openai-bridge (OpenAI subscription) ← NEW
4. chatgpt-bridge (ChatGPT alternate routing) ← NEW
5. cerebras (free tier)
6. groq (free tier)
7. mistral (free tier)
8. nvidia (free tier)
9. cloudflare (free tier)
🔒 Security Checklist
- No API keys hardcoded in code ✅
- Environment variables used for secrets ✅
- No Authorization header for bridge services (handled internally) ✅
- OPENAI_API_KEY validated before use ✅
- Error messages sanitized (500 char limit) ✅
- Input validation on messages array ✅
- Timeout handling (300s default) ✅
- Buffer size limited (10MB max) ✅
📝 Configuration Template
Add to ~/.env.local on Erik or use PM2 --update-env:
OPENAI_API_KEY=sk-proj-xxxxx...
OPENAI_BRIDGE_PORT=3251
OPENAI_MODEL=gpt-4-turbo
OPENAI_BRIDGE_URL=http://localhost:3251
CHATGPT_BRIDGE_URL=http://localhost:3251
LLM_PROVIDERS=claude,openai,chatgpt,cerebras,groq,mistral,nvidia
🎯 Integration Points
Gateway reads from:
external-providers.ts: Provider registry, rate limits, modelsecosystem.config.cjs: Environment variables- Environment:
OPENAI_API_KEY,OPENAI_BRIDGE_URL
Bridge service exposes:
GET http://localhost:3251/health- Health/config statusPOST http://localhost:3251/v1/chat/completions- OpenAI-compatible endpoint
Learning engine integrates:
- Monitors openai-bridge response quality
- Tracks latency and token usage
- Auto-adjusts routing based on confidence scores
📦 Pending: Microsoft Copilot
Status: Not yet integrated (awaiting CLI tool identification)
To add Copilot once available:
- Follow openai-bridge pattern (wrapper around CLI)
- Add copilot-bridge provider in external-providers.ts
- Update ecosystem.config.cjs with copilot service
- Extend ensure-bridges.sh deployment script
🔄 Deployment Rollback
If issues occur:
pm2 stop openai-bridge
pm2 delete openai-bridge
rm -rf /opt/openai-bridge
pm2 restart llm-gateway
Status: ✅ READY FOR PRODUCTION DEPLOYMENT
Last Updated: 2026-04-25 04:32 UTC
Deployed By: Claude Autonomous Execution
Approval Required: OPENAI_API_KEY configuration only