feat: use correct DashScope API endpoint for Qwen OAuth
Based on ZeroClaw implementation study: - Change API endpoint from api.qwen.ai to dashscope.aliyuncs.com/compatible-mode/v1 - Update credentials file reference to oauth_creds.json - Add ZeroClaw native qwen-oauth provider documentation - Add API endpoints and models reference table - Update import script with correct endpoint and platform support - Add PicoClaw and NanoClaw platform configurations Key findings from ZeroClaw binary: - Native qwen-oauth provider with auto token refresh - Uses DashScope OpenAI-compatible endpoint - Reads ~/.qwen/oauth_creds.json directly Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -126,53 +126,71 @@
|
||||
### Quick Start
|
||||
|
||||
```bash
|
||||
# Step 1: Install Qwen Code
|
||||
# Step 1: Install Qwen Code CLI
|
||||
npm install -g @qwen-code/qwen-code@latest
|
||||
|
||||
# Step 2: Get FREE OAuth
|
||||
qwen
|
||||
/auth # Select "Qwen OAuth" → Browser login with qwen.ai
|
||||
# Step 2: Get FREE OAuth (opens browser for login)
|
||||
qwen --auth-type qwen-oauth -p "test"
|
||||
# Credentials saved to: ~/.qwen/oauth_creds.json
|
||||
|
||||
# Step 3: Import to ANY platform
|
||||
source ~/.qwen/.env && openclaw
|
||||
source ~/.qwen/.env && nanobot gateway
|
||||
source ~/.qwen/.env && picoclaw gateway
|
||||
source ~/.qwen/.env && zeroclaw gateway
|
||||
|
||||
# ZeroClaw (native provider - auto token refresh)
|
||||
cat > ~/.zeroclaw/config.toml << EOF
|
||||
default_provider = "qwen-oauth"
|
||||
default_model = "qwen3-coder-plus"
|
||||
EOF
|
||||
|
||||
# Other platforms (OpenAI-compatible)
|
||||
export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token')
|
||||
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||
```
|
||||
|
||||
### Platform-Specific Import
|
||||
|
||||
#### OpenClaw + FREE Qwen
|
||||
#### OpenClaw + FREE Qwen (OpenAI-Compatible)
|
||||
```bash
|
||||
git clone https://github.com/openclaw/openclaw.git
|
||||
cd openclaw && npm install
|
||||
|
||||
export OPENAI_API_KEY=$(cat ~/.qwen/oauth-token.json | jq -r '.access_token')
|
||||
export OPENAI_BASE_URL="https://api.qwen.ai/v1"
|
||||
# Extract token from Qwen OAuth credentials
|
||||
export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token')
|
||||
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||
export OPENAI_MODEL="qwen3-coder-plus"
|
||||
|
||||
npm run start
|
||||
```
|
||||
|
||||
#### NanoBot + FREE Qwen
|
||||
#### NanoBot + FREE Qwen (OpenAI-Compatible)
|
||||
```bash
|
||||
pip install nanobot-ai
|
||||
|
||||
cat > ~/.nanobot/config.json << CONFIG
|
||||
{
|
||||
"providers": {
|
||||
"qwen": {
|
||||
"apiKey": "$(cat ~/.qwen/oauth-token.json | jq -r '.access_token')",
|
||||
"baseURL": "https://api.qwen.ai/v1"
|
||||
}
|
||||
},
|
||||
"agents": { "defaults": { "model": "qwen/qwen3-coder-plus" } }
|
||||
}
|
||||
CONFIG
|
||||
# Extract token and configure
|
||||
export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token')
|
||||
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||
export OPENAI_MODEL="qwen3-coder-plus"
|
||||
|
||||
nanobot gateway
|
||||
```
|
||||
|
||||
#### PicoClaw + FREE Qwen (OpenAI-Compatible)
|
||||
```bash
|
||||
# Extract token and set environment
|
||||
export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token')
|
||||
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||
|
||||
picoclaw gateway
|
||||
```
|
||||
|
||||
#### NanoClaw + FREE Qwen (OpenAI-Compatible)
|
||||
```bash
|
||||
# Extract token and set environment
|
||||
export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token')
|
||||
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||
|
||||
nanoclaw
|
||||
```
|
||||
|
||||
#### ZeroClaw + FREE Qwen (NATIVE Provider)
|
||||
```bash
|
||||
# Install ZeroClaw
|
||||
@@ -213,7 +231,7 @@ zeroclaw gateway
|
||||
│ ───────────────────────────────────────────────────── │
|
||||
│ • Treats Qwen API as OpenAI-compatible endpoint │
|
||||
│ • Extract access_token and use as OPENAI_API_KEY │
|
||||
│ • Set OPENAI_BASE_URL=https://api.qwen.ai/v1 │
|
||||
│ • Set OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1 │
|
||||
│ • Manual re-export needed when token expires │
|
||||
│ │
|
||||
│ COMPARISON: │
|
||||
@@ -249,6 +267,22 @@ Qwen Code stores OAuth credentials in `~/.qwen/oauth_creds.json`:
|
||||
| `refresh_token` | Used to get new access_token when expired |
|
||||
| `expiry_date` | Unix timestamp when access_token expires |
|
||||
|
||||
### API Endpoints
|
||||
|
||||
| Endpoint | URL |
|
||||
|----------|-----|
|
||||
| **API Base** | `https://dashscope.aliyuncs.com/compatible-mode/v1` |
|
||||
| **Chat Completions** | `https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions` |
|
||||
| **Token Refresh** | `https://chat.qwen.ai/api/v1/oauth2/token` |
|
||||
|
||||
### Available Models (FREE Tier)
|
||||
|
||||
| Model | Best For |
|
||||
|-------|----------|
|
||||
| `qwen3-coder-plus` | Coding (recommended) |
|
||||
| `qwen3-coder-flash` | Fast coding |
|
||||
| `qwen-max` | Complex tasks |
|
||||
|
||||
---
|
||||
|
||||
## 🤖 FEATURE 2: 25+ AI Providers
|
||||
@@ -475,10 +509,11 @@ zeroclaw gateway
|
||||
```bash
|
||||
# ~/.qwen/.env or ~/.config/claw/.env
|
||||
|
||||
# Qwen OAuth (FREE - from qwen && /auth)
|
||||
OPENAI_API_KEY=$(cat ~/.qwen/oauth-token.json | jq -r '.access_token')
|
||||
OPENAI_BASE_URL=https://api.qwen.ai/v1
|
||||
OPENAI_MODEL=qwen3-coder-plus
|
||||
# Qwen OAuth (FREE - from qwen --auth-type qwen-oauth)
|
||||
# Credentials stored in: ~/.qwen/oauth_creds.json
|
||||
export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token')
|
||||
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||
export OPENAI_MODEL="qwen3-coder-plus"
|
||||
|
||||
# Or use paid providers
|
||||
ANTHROPIC_API_KEY=sk-ant-xxx
|
||||
@@ -571,8 +606,11 @@ source ~/.qwen/.env
|
||||
### API Errors
|
||||
```bash
|
||||
# Verify token is valid
|
||||
curl -H "Authorization: Bearer $OPENAI_API_KEY" \
|
||||
https://api.qwen.ai/v1/models
|
||||
QWEN_TOKEN=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token')
|
||||
curl -X POST "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions" \
|
||||
-H "Authorization: Bearer $QWEN_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"model": "qwen3-coder-plus", "messages": [{"role": "user", "content": "Hello"}]}'
|
||||
|
||||
# Check rate limits
|
||||
# FREE tier: 60 req/min, 2000/day
|
||||
|
||||
Reference in New Issue
Block a user