How yangyuhou/qwen2api works
qwen2API is a self-hosted gateway that exposes Qwen Web capabilities through OpenAI-, Anthropic-, and Gemini-compatible APIs, alongside an administration and testing WebUI. The principal request path is client → Go HTTP/API layer → protocol and context processing → account pool → Qwen upstream; the README documents this high-level flow. The WebUI separately manages accounts, keys, settings, and chat/image/video tests. Several backend subsystems are represented by their exact directories because their individual source was not sampled; detailed internal calls beyond documented relationships are therefore omitted.
Main entry points: main.go HTTP router · standard_request.go Protocol adapter · context_pipeline.go Context pipeline · pool_core.go Account pool
Components 21
Clients
- API clients
Admin WebUI
- Admin console
frontend/src/App.tsx - Account management
frontend/src/pages/AccountsPage.tsx - Dashboard
frontend/src/pages/Dashboard.tsx - API keys
frontend/src/pages/TokensPage.tsx - Runtime settings
frontend/src/pages/SettingsPage.tsx - Chat testing
frontend/src/pages/TestPage.tsx - Image testing
frontend/src/pages/ImagePage.tsx - Video testing
frontend/src/pages/VideoPage.tsx
Go Gateway
- HTTP router
backend/main.go - Protocol APIs
backend/api - Admin API
backend/api/admin.go
Request Processing
- Protocol adapter
backend/adapter/standard_request.go - Context pipeline
backend/context_pipeline.go - Tool-call parsing
backend/toolcall/parser.go - Stream execution
backend/runtime/execution.go
Accounts And Upstream
- Account pool
backend/core/account_pool/pool_core.go - Qwen Web
- Qwen executor
backend/upstream/qwen_executor.go - Payload builder
backend/upstream/payload_builder.go - JSON data stores
backend/core/database.go
Connections 22
- API clients → HTTP router: send requests
README.md - Admin console → HTTP router: calls admin APIs
README.md - HTTP router → Protocol adapter: dispatches to
README.md - Protocol adapter → Context pipeline: processes through
README.md - Context pipeline → Account pool: uses
README.md - Account pool → Qwen Web: forwards requests
README.md - Account pool → JSON data stores: uses account data
README.md - HTTP router → Protocol APIs: routes protocol requests
- HTTP router → Admin API: routes management requests
- Protocol APIs → Protocol adapter: adapts protocols
- Account management → HTTP router: manages accounts
- Dashboard → HTTP router: reads status
- API keys → HTTP router: manages keys
- Runtime settings → HTTP router: updates settings
- Chat testing → HTTP router: tests chat
frontend/src/pages/TestPage.tsx - Image testing → HTTP router: tests images
- Video testing → HTTP router: tests videos
- Protocol adapter → Tool-call parsing: handles tool calls
- Context pipeline → Stream execution: passes request
- Stream execution → Payload builder: builds upstream payload
- Payload builder → Qwen executor: provides payload
- Qwen executor → Qwen Web: executes request