- 新增 CLAUDE_CONSOLE_BLOCKED_HANDLING_MINUTES 配置项,自动处理账户临时禁用的 400 错误(如 "organization has been disabled"、"too many active sessions" 等)。
- 添加 errorSanitizer 工具模块,自动清理上游错误响应中的供应商特定信息(URL、供应商名称等),避免泄露中转服务商信息。
- 统一调度器现在会主动检查并恢复已过期的封禁账户,确保账户在临时封禁时长结束后可以立即重新使用。
- 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 <noreply@anthropic.com>
- Created new src/routes/unified.js (225 lines)
- detectBackendFromModel(): Detects backend from model name
- routeToBackend(): Routes to Claude/OpenAI/Gemini with permission checks
- POST /v1/chat/completions: OpenAI-compatible endpoint with intelligent routing
- POST /v1/completions: Legacy completions endpoint with intelligent routing
- Updated src/routes/api.js (reduced from 1185 to 968 lines)
- Removed ~217 lines of routing logic
- Kept Claude-specific endpoints (/api/v1/messages)
- Maintained all other Claude API functionality
- Updated src/app.js
- Added unifiedRoutes registration at /api prefix
Benefits:
- Single responsibility: api.js focuses on Claude API routes
- Better organization: routing logic isolated in unified.js
- Easier maintenance: changes to routing won't affect Claude code
- File size reduction: api.js reduced by 18%
Tested:
- ✅ Claude model routing via /v1/chat/completions
- ✅ OpenAI model routing (correct backend detection)
- ✅ Gemini model routing (correct backend detection)
- ✅ Legacy /v1/completions endpoint
- ✅ All tests pass, no regressions
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>