Rene Fichtmueller 1d327720d5 feat: Implement Phase 2G.3 — ChatGPT/OpenAI API compatibility adapter
HTTP server providing OpenAI API compatibility for LLM Gateway.

- OpenAI client SDK drop-in replacement (baseURL only change)
- POST /v1/chat/completions endpoint with streaming support
- GET /v1/models for client library discovery
- Automatic model mapping: gpt-4 → qwen2.5:32b, etc.
- Server-Sent Events (SSE) streaming implementation
- Full TypeScript types and comprehensive test suite
- Graceful shutdown handling (SIGTERM/SIGINT)
- Health check endpoint with gateway status
- Performance: Same as gateway (100-500ms with fallback to Ollama)
2026-04-19 22:05:20 +02:00

24 lines
580 B
JavaScript

#!/usr/bin/env node
import ChatGPTAPIAdapter from './index'
const port = parseInt(process.env.CHATGPT_API_PORT || '3111', 10)
const adapter = new ChatGPTAPIAdapter(port)
adapter.start().catch(error => {
console.error('[ChatGPT API] Failed to start:', error)
process.exit(1)
})
process.on('SIGTERM', async () => {
console.error('[ChatGPT API] SIGTERM received, shutting down...')
await adapter.stop()
process.exit(0)
})
process.on('SIGINT', async () => {
console.error('[ChatGPT API] SIGINT received, shutting down...')
await adapter.stop()
process.exit(0)
})