How youssefvdel/qwengate works
Qwen Gate is a local OpenAI-compatible gateway to Qwen, with a web dashboard for account and service management. A client submits a chat request; the gateway authenticates and routes it through account/session management to Qwen, then returns a response or SSE stream, translating tool-call text and filtering output when applicable. The README also documents Anthropic compatibility, file uploads, account rotation, and monitoring. Edges reflect README statements or relationships listed in the SOURCE INDEX; unsampled implementation details are not inferred.
Main entry points: chat.ts Chat endpoint · anthropic.ts Anthropic endpoint · index.tsx HTTP server · qwen.ts Qwen client
Components 29
API and chat
- HTTP server
src/index.tsx - Chat endpoint
src/routes/chat.ts - Anthropic endpoint
src/routes/anthropic.ts - Chat preparation
src/routes/chatHelpers.ts - Non-stream response
src/routes/chatNonStreaming.ts - SSE response
src/routes/chatStreaming.ts - Stream helpers
src/routes/chatStreamingHelpers.ts - Tool-call parser
src/tools/xmlToolParser.ts
Accounts and sessions
- Account routes
src/routes/accounts.ts - Authentication
src/services/auth.ts - Account manager
src/services/accountManager.ts - Browser profiles
src/services/browserProfiles.ts - Browser login
src/services/playwright.ts - Session pool
src/services/sessionPool.ts
Qwen transport
- Qwen client
src/services/qwen.ts - File uploads
src/services/qwenFileUpload.ts - Browserless fetch
src/services/browserlessFetch.ts - Model health routing
src/services/modelRouter.ts
Operations and dashboard
- Dashboard routes
src/routes/dashboard/dashboardRoutes.ts - Dashboard monitoring
src/routes/dashboard/monitor.ts - Network diagnostics
src/routes/debugNetwork.ts - Request logs
src/services/logStore.ts
Shared services
- OpenAI types
src/types/openai.ts - Configuration
src/services/configService.ts - Rate limiting
src/middleware/rateLimit.ts - Account types
src/types/auth.ts - Path utilities
src/utils/paths.ts
Other components
- API client
- Qwen service
Connections 44
- API client → HTTP server: sends requests
- HTTP server → Chat endpoint: routes chat
src/index.tsx - HTTP server → Anthropic endpoint: routes API
src/index.tsx - HTTP server → Account routes: routes accounts
src/index.tsx - HTTP server → Dashboard routes: registers routes
src/index.tsx - HTTP server → Rate limiting: applies limits
src/index.tsx - Chat endpoint → Chat preparation: prepares request
src/routes/chat.ts - Chat endpoint → Non-stream response: handles response
src/routes/chat.ts - Chat endpoint → SSE response: handles streaming
src/routes/chat.ts - Anthropic endpoint → Chat preparation: uses chat helpers
src/routes/anthropic.ts - Chat endpoint → Model health routing: selects model
src/routes/chat.ts - Chat endpoint → Qwen client: requests completion
src/routes/chat.ts - Anthropic endpoint → Qwen client: requests completion
src/routes/anthropic.ts - Chat endpoint → Session pool: acquires sessions
src/routes/chat.ts - Anthropic endpoint → Session pool: acquires sessions
src/routes/anthropic.ts - Chat endpoint → File uploads: uploads context
src/routes/chat.ts - Anthropic endpoint → File uploads: uploads context
src/routes/anthropic.ts - Non-stream response → Tool-call parser: parses tool calls
src/routes/chatNonStreaming.ts - SSE response → Stream helpers: uses helpers
src/routes/chatStreaming.ts - Chat endpoint → OpenAI types: uses API types
src/routes/chat.ts - Anthropic endpoint → OpenAI types: uses API types
src/routes/anthropic.ts - Account routes → Authentication: manages auth
src/routes/accounts.ts - Authentication → Account manager: loads accounts
src/services/auth.ts - Authentication → Browser login: loads profile tokens
src/services/auth.ts - Account manager → Account types: uses account types
src/services/accountManager.ts - Authentication → Browser profiles: uses profiles
src/services/auth.ts - Browser login → Browser profiles: uses profile helpers
src/services/playwright.ts - Session pool → Authentication: selects accounts
src/services/sessionPool.ts - Session pool → Browser login: gets headers
src/services/sessionPool.ts - Session pool → Browserless fetch: creates sessions
src/services/sessionPool.ts - Qwen client → Authentication: gets account token
src/services/qwen.ts - Qwen client → Browserless fetch: sends requests
src/services/qwen.ts - Qwen client → Qwen service: calls upstream
- Qwen client → Session pool: uses pooled sessions
src/routes/chat.ts - File uploads → Qwen service: uploads files
- Dashboard routes → Dashboard monitoring: routes monitoring
src/routes/dashboard/dashboardRoutes.ts - Dashboard routes → Account manager: reports accounts
src/routes/dashboard/dashboardRoutes.ts - Dashboard routes → Configuration: reads and updates
src/routes/dashboard/dashboardRoutes.ts - Dashboard routes → Request logs: serves logs
src/routes/dashboard/dashboardRoutes.ts - Network diagnostics → Request logs: records diagnostics
- Configuration → Path utilities: resolves files
src/services/configService.ts - Request logs → Configuration: reads settings
src/services/logStore.ts - Chat endpoint → Request logs: records requests
src/routes/chat.ts - Anthropic endpoint → Request logs: records requests
src/routes/anthropic.ts