Back to Qwen Proxy

Qwen Proxy Documentation

OpenAI-compatible proxy for Qwen AI

Quick Start

Get up and running in 4 steps.

1

Install

Run the one-liner installer to download and set up qwen-proxy.

curl -fsSL https://rlabs.arosyihuddin.com/install.sh | bash
2

Login

Authenticate with your Qwen account. Supports headless, headed, token, or bulk login.

qwen-proxy login
3

Start Server

Start the proxy server as a background daemon on port 8080.

qwen-proxy start
4

Use the API

Send requests using any OpenAI-compatible client or SDK.

curl http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-max-latest",
    "messages": [{"role": "user", "content": "Hello!"}],
    "stream": true
  }'

CLI Commands

Complete reference for all available commands.

API Endpoints

OpenAI-compatible REST API reference.

MethodEndpointDescriptionAuth
GET/Server info (name, version, endpoints, account count)-
GET/healthzHealth check (status, account count, timestamp)-
GET/v1/modelsList available Qwen modelsRequired
POST/v1/chat/completionsChat completions (streaming + non-streaming)Required
POST/v1/images/generationsGenerate imagesRequired
POST/v1/images/editsEdit imagesRequired
POST/v1/videos/generationsGenerate videosRequired
GET/v1/validateValidate token status for all accountsRequired
GET/v1/refreshForce refresh tokensRequired
POST/v1/chats/deleteDelete all chatsRequired
GET/dashboardWeb dashboard SPA-
GET/api/dashboard/statsDashboard overview stats-
GET/api/dashboard/logsRequest logs-
GET/api/dashboard/usageUsage statistics-
GET/api/dashboard/accountsList accounts with status-
GET/api/dashboard/modelsList models-
POST/api/dashboard/chatChat playground-
POST/api/dashboard/imageImage generation playground-

Configuration

All configuration options stored in ~/.qwen-proxy/config.json.

KeyTypeDefaultDescription
portnumber8080Server port
api-keysstring[][]API keys for proxy access (comma-separated)
upstreamstringhttps://qwen.aikit.clubUpstream API URL
debugbooleanfalseEnable debug logging
refresh-intervalnumber60000Background token refresh interval (ms)
dashboard-passwordstring""Dashboard login password (empty = no auth)

Authentication

API keys can be provided via any of these methods:

Authorization: Bearer <key> Standard Bearer token header
X-Api-Key: <key> Custom API key header
?key=<key> Query parameter

If no API keys are configured, the proxy is open to all requests.

Architecture

How qwen-proxy works under the hood.

Architecture
Client (OpenAI SDK / curl / any HTTP client)
    │
    ▼
┌─────────────────────────────────────────┐
│           qwen-proxy (localhost:8080)    │
│                                         │
│  ┌─ CORS Middleware                     │
│  ├─ Request Logger                      │
│  ├─ API Key Auth                        │
│  │                                      │
│  ├─ Token Manager                       │
│  │   ├─ Round-robin account selection   │
│  │   ├─ Background token refresh        │
│  │   └─ Proactive renewal (20min lead)  │
│  │                                      │
│  ├─ Routes                              │
│  │   ├─ /v1/chat/completions            │
│  │   ├─ /v1/models                      │
│  │   ├─ /v1/images/*                    │
│  │   └─ /v1/videos/*                    │
│  │                                      │
│  └─ Dashboard (SPA)                     │
│      ├─ Stats & Monitoring              │
│      ├─ Account Management              │
│      └─ Chat/Image/Video Playground     │
└─────────────────────────────────────────┘
    │
    ▼
Upstream API (qwen.aikit.club)
    │
    ▼
Qwen AI (chat.qwen.ai)

Storage Layout

File Structure
~/.qwen-proxy/
├── config.json          # Server configuration
├── server.pid           # Background server PID
├── server.log           # Server log file (rotated at 10MB)
└── accounts/
    ├── qwen-user1.json  # JWT token for account 1
    └── qwen-user2.json  # JWT token for account 2