From 6bb74376caecaff0c3c6c59326667989e07fde25 Mon Sep 17 00:00:00 2001 From: jft0m <377632523@qq.com> Date: Tue, 14 Oct 2025 16:17:12 +0000 Subject: [PATCH] fix: add /openai/v1/chat/completions route support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Register unifiedRoutes under /openai prefix to enable /openai/v1/chat/completions - Reuse existing intelligent routing logic from unified.js (no code duplication) - Keep existing Codex API routes (/openai/responses, /openai/v1/responses) unchanged Benefits: - Fixes 404 error for /openai/v1/chat/completions endpoint - Provides consistent API experience across /api and /openai prefixes - Automatically routes to correct backend (Claude/OpenAI/Gemini) based on model Tested: - ✅ /openai/v1/chat/completions now returns authentication error (route works) - ✅ /api/v1/chat/completions continues to work - ✅ Existing Codex routes remain functional 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/app.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app.js b/src/app.js index 4f86c6cf..67454ea8 100644 --- a/src/app.js +++ b/src/app.js @@ -269,7 +269,8 @@ class Application { this.app.use('/gemini', geminiRoutes) // 保留原有路径以保持向后兼容 this.app.use('/openai/gemini', openaiGeminiRoutes) this.app.use('/openai/claude', openaiClaudeRoutes) - this.app.use('/openai', openaiRoutes) + this.app.use('/openai', unifiedRoutes) // 复用统一智能路由,支持 /openai/v1/chat/completions + this.app.use('/openai', openaiRoutes) // Codex API 路由(/openai/responses, /openai/v1/responses) // Droid 路由:支持多种 Factory.ai 端点 this.app.use('/droid', droidRoutes) // Droid (Factory.ai) API 转发 this.app.use('/azure', azureOpenaiRoutes)