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
|
### Quick Start
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Step 1: Install Qwen Code
|
# Step 1: Install Qwen Code CLI
|
||||||
npm install -g @qwen-code/qwen-code@latest
|
npm install -g @qwen-code/qwen-code@latest
|
||||||
|
|
||||||
# Step 2: Get FREE OAuth
|
# Step 2: Get FREE OAuth (opens browser for login)
|
||||||
qwen
|
qwen --auth-type qwen-oauth -p "test"
|
||||||
/auth # Select "Qwen OAuth" → Browser login with qwen.ai
|
# Credentials saved to: ~/.qwen/oauth_creds.json
|
||||||
|
|
||||||
# Step 3: Import to ANY platform
|
# Step 3: Import to ANY platform
|
||||||
source ~/.qwen/.env && openclaw
|
|
||||||
source ~/.qwen/.env && nanobot gateway
|
# ZeroClaw (native provider - auto token refresh)
|
||||||
source ~/.qwen/.env && picoclaw gateway
|
cat > ~/.zeroclaw/config.toml << EOF
|
||||||
source ~/.qwen/.env && zeroclaw gateway
|
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
|
### Platform-Specific Import
|
||||||
|
|
||||||
#### OpenClaw + FREE Qwen
|
#### OpenClaw + FREE Qwen (OpenAI-Compatible)
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/openclaw/openclaw.git
|
git clone https://github.com/openclaw/openclaw.git
|
||||||
cd openclaw && npm install
|
cd openclaw && npm install
|
||||||
|
|
||||||
export OPENAI_API_KEY=$(cat ~/.qwen/oauth-token.json | jq -r '.access_token')
|
# Extract token from Qwen OAuth credentials
|
||||||
export OPENAI_BASE_URL="https://api.qwen.ai/v1"
|
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"
|
export OPENAI_MODEL="qwen3-coder-plus"
|
||||||
|
|
||||||
npm run start
|
npm run start
|
||||||
```
|
```
|
||||||
|
|
||||||
#### NanoBot + FREE Qwen
|
#### NanoBot + FREE Qwen (OpenAI-Compatible)
|
||||||
```bash
|
```bash
|
||||||
pip install nanobot-ai
|
pip install nanobot-ai
|
||||||
|
|
||||||
cat > ~/.nanobot/config.json << CONFIG
|
# Extract token and configure
|
||||||
{
|
export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token')
|
||||||
"providers": {
|
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
"qwen": {
|
export OPENAI_MODEL="qwen3-coder-plus"
|
||||||
"apiKey": "$(cat ~/.qwen/oauth-token.json | jq -r '.access_token')",
|
|
||||||
"baseURL": "https://api.qwen.ai/v1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"agents": { "defaults": { "model": "qwen/qwen3-coder-plus" } }
|
|
||||||
}
|
|
||||||
CONFIG
|
|
||||||
|
|
||||||
nanobot gateway
|
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)
|
#### ZeroClaw + FREE Qwen (NATIVE Provider)
|
||||||
```bash
|
```bash
|
||||||
# Install ZeroClaw
|
# Install ZeroClaw
|
||||||
@@ -213,7 +231,7 @@ zeroclaw gateway
|
|||||||
│ ───────────────────────────────────────────────────── │
|
│ ───────────────────────────────────────────────────── │
|
||||||
│ • Treats Qwen API as OpenAI-compatible endpoint │
|
│ • Treats Qwen API as OpenAI-compatible endpoint │
|
||||||
│ • Extract access_token and use as OPENAI_API_KEY │
|
│ • 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 │
|
│ • Manual re-export needed when token expires │
|
||||||
│ │
|
│ │
|
||||||
│ COMPARISON: │
|
│ 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 |
|
| `refresh_token` | Used to get new access_token when expired |
|
||||||
| `expiry_date` | Unix timestamp when access_token expires |
|
| `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
|
## 🤖 FEATURE 2: 25+ AI Providers
|
||||||
@@ -475,10 +509,11 @@ zeroclaw gateway
|
|||||||
```bash
|
```bash
|
||||||
# ~/.qwen/.env or ~/.config/claw/.env
|
# ~/.qwen/.env or ~/.config/claw/.env
|
||||||
|
|
||||||
# Qwen OAuth (FREE - from qwen && /auth)
|
# Qwen OAuth (FREE - from qwen --auth-type qwen-oauth)
|
||||||
OPENAI_API_KEY=$(cat ~/.qwen/oauth-token.json | jq -r '.access_token')
|
# Credentials stored in: ~/.qwen/oauth_creds.json
|
||||||
OPENAI_BASE_URL=https://api.qwen.ai/v1
|
export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token')
|
||||||
OPENAI_MODEL=qwen3-coder-plus
|
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
|
export OPENAI_MODEL="qwen3-coder-plus"
|
||||||
|
|
||||||
# Or use paid providers
|
# Or use paid providers
|
||||||
ANTHROPIC_API_KEY=sk-ant-xxx
|
ANTHROPIC_API_KEY=sk-ant-xxx
|
||||||
@@ -571,8 +606,11 @@ source ~/.qwen/.env
|
|||||||
### API Errors
|
### API Errors
|
||||||
```bash
|
```bash
|
||||||
# Verify token is valid
|
# Verify token is valid
|
||||||
curl -H "Authorization: Bearer $OPENAI_API_KEY" \
|
QWEN_TOKEN=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token')
|
||||||
https://api.qwen.ai/v1/models
|
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
|
# Check rate limits
|
||||||
# FREE tier: 60 req/min, 2000/day
|
# FREE tier: 60 req/min, 2000/day
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
---
|
---
|
||||||
name: claw-setup
|
name: claw-setup
|
||||||
description: Use this skill when the user asks to "setup openclaw", "install nanobot", "deploy zeroclaw", "configure picoclaw", "setup qwen code", "import qwen oauth", "use free qwen tier", "configure AI providers", "add openai provider", "AI agent setup", or mentions setting up AI platforms.
|
description: Use this skill when the user asks to "setup openclaw", "install nanobot", "deploy zeroclaw", "configure picoclaw", "setup qwen code", "import qwen oauth", "use free qwen tier", "configure AI providers", "add openai provider", "AI agent setup", or mentions setting up AI platforms.
|
||||||
version: 1.3.0
|
version: 2.0.0
|
||||||
---
|
---
|
||||||
|
|
||||||
# Claw Setup Skill
|
# Claw Setup Skill
|
||||||
|
|
||||||
End-to-end professional setup of AI Agent platforms with **25+ OpenCode-compatible providers** and **FREE Qwen OAuth cross-platform import**.
|
End-to-end professional setup of AI Agent platforms with **25+ OpenCode-compatible providers** and **FREE Qwen OAuth cross-platform import**.
|
||||||
|
|
||||||
## ⭐ Two Key Features
|
## Two Key Features
|
||||||
|
|
||||||
```
|
```
|
||||||
┌─────────────────────────────────────────────────────────────────┐
|
┌─────────────────────────────────────────────────────────────────┐
|
||||||
@@ -21,6 +21,7 @@ End-to-end professional setup of AI Agent platforms with **25+ OpenCode-compatib
|
|||||||
│ • Works with: OpenClaw, NanoBot, PicoClaw, ZeroClaw │
|
│ • Works with: OpenClaw, NanoBot, PicoClaw, ZeroClaw │
|
||||||
│ • Model: Qwen3-Coder (optimized for coding) │
|
│ • Model: Qwen3-Coder (optimized for coding) │
|
||||||
│ • Auth: Browser OAuth via qwen.ai │
|
│ • Auth: Browser OAuth via qwen.ai │
|
||||||
|
│ • Token refresh: Automatic (ZeroClaw) / Manual (others) │
|
||||||
│ │
|
│ │
|
||||||
│ FEATURE 2: 25+ OpenCode-Compatible AI Providers │
|
│ FEATURE 2: 25+ OpenCode-Compatible AI Providers │
|
||||||
│ ───────────────────────────────────────────────── │
|
│ ───────────────────────────────────────────────── │
|
||||||
@@ -38,10 +39,10 @@ End-to-end professional setup of AI Agent platforms with **25+ OpenCode-compatib
|
|||||||
| Platform | Language | Memory | Qwen OAuth | All Providers | Best For |
|
| Platform | Language | Memory | Qwen OAuth | All Providers | Best For |
|
||||||
|----------|----------|--------|------------|---------------|----------|
|
|----------|----------|--------|------------|---------------|----------|
|
||||||
| **Qwen Code** | TypeScript | ~200MB | ✅ Native | ✅ | FREE coding |
|
| **Qwen Code** | TypeScript | ~200MB | ✅ Native | ✅ | FREE coding |
|
||||||
|
| **ZeroClaw** | Rust | <5MB | ✅ Native | ✅ | Max performance |
|
||||||
|
| **PicoClaw** | Go | <10MB | ✅ Import | ✅ | Embedded |
|
||||||
| **OpenClaw** | TypeScript | >1GB | ✅ Import | ✅ | Full-featured |
|
| **OpenClaw** | TypeScript | >1GB | ✅ Import | ✅ | Full-featured |
|
||||||
| **NanoBot** | Python | ~100MB | ✅ Import | ✅ | Research |
|
| **NanoBot** | Python | ~100MB | ✅ Import | ✅ | Research |
|
||||||
| **PicoClaw** | Go | <10MB | ✅ Import | ✅ | Embedded |
|
|
||||||
| **ZeroClaw** | Rust | <5MB | ✅ Import | ✅ | Performance |
|
|
||||||
| **NanoClaw** | TypeScript | ~50MB | ✅ Import | ✅ | WhatsApp |
|
| **NanoClaw** | TypeScript | ~50MB | ✅ Import | ✅ | WhatsApp |
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -51,32 +52,80 @@ End-to-end professional setup of AI Agent platforms with **25+ OpenCode-compatib
|
|||||||
## Get FREE Qwen OAuth
|
## Get FREE Qwen OAuth
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Install Qwen Code
|
# Install Qwen Code CLI
|
||||||
npm install -g @qwen-code/qwen-code@latest
|
npm install -g @qwen-code/qwen-code@latest
|
||||||
|
|
||||||
# Authenticate (FREE)
|
# Authenticate (FREE - opens browser)
|
||||||
qwen
|
qwen --auth-type qwen-oauth -p "test"
|
||||||
/auth # Select "Qwen OAuth" → Browser login with qwen.ai
|
|
||||||
|
|
||||||
# FREE: 2,000 requests/day, 60 req/min
|
# FREE: 2,000 requests/day, 60 req/min
|
||||||
|
# Credentials saved to: ~/.qwen/oauth_creds.json
|
||||||
```
|
```
|
||||||
|
|
||||||
## Import to Any Platform
|
## Credentials File Structure
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"access_token": "your-access-token",
|
||||||
|
"refresh_token": "your-refresh-token",
|
||||||
|
"token_type": "Bearer",
|
||||||
|
"resource_url": "portal.qwen.ai",
|
||||||
|
"expiry_date": 1771774796531
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## API Endpoints
|
||||||
|
|
||||||
|
| Endpoint | URL |
|
||||||
|
|----------|-----|
|
||||||
|
| **API Base** | `https://dashscope.aliyuncs.com/compatible-mode/v1` |
|
||||||
|
| **Chat Completions** | `/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 |
|
||||||
|
|
||||||
|
## Import Methods
|
||||||
|
|
||||||
|
### ZeroClaw (Native Provider - Auto Token Refresh)
|
||||||
|
|
||||||
|
ZeroClaw has **built-in qwen-oauth provider** that handles token refresh automatically:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Configure ZeroClaw to use native qwen-oauth provider
|
||||||
|
cat > ~/.zeroclaw/config.toml << EOF
|
||||||
|
default_provider = "qwen-oauth"
|
||||||
|
default_model = "qwen3-coder-plus"
|
||||||
|
default_temperature = 0.7
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# ZeroClaw automatically:
|
||||||
|
# • Reads ~/.qwen/oauth_creds.json
|
||||||
|
# • Refreshes expired tokens using refresh_token
|
||||||
|
# • Uses correct DashScope API endpoint
|
||||||
|
|
||||||
|
zeroclaw agent -m "Hello!"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Other Platforms (OpenAI-Compatible Import)
|
||||||
|
|
||||||
|
For OpenClaw, NanoBot, PicoClaw, NanoClaw - use OpenAI-compatible endpoint:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Extract token
|
# Extract token
|
||||||
export QWEN_TOKEN=$(cat ~/.qwen/oauth-token.json | jq -r '.access_token')
|
export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token')
|
||||||
|
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
|
|
||||||
# Configure for any platform
|
# Use with any platform
|
||||||
export OPENAI_API_KEY="$QWEN_TOKEN"
|
|
||||||
export OPENAI_BASE_URL="https://api.qwen.ai/v1"
|
|
||||||
export OPENAI_MODEL="qwen3-coder-plus"
|
|
||||||
|
|
||||||
# Use with any platform!
|
|
||||||
openclaw # OpenClaw with FREE Qwen
|
openclaw # OpenClaw with FREE Qwen
|
||||||
nanobot # NanoBot with FREE Qwen
|
nanobot # NanoBot with FREE Qwen
|
||||||
picoclaw # PicoClaw with FREE Qwen
|
picoclaw # PicoClaw with FREE Qwen
|
||||||
zeroclaw # ZeroClaw with FREE Qwen
|
nanoclaw # NanoClaw with FREE Qwen
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -87,7 +136,7 @@ zeroclaw # ZeroClaw with FREE Qwen
|
|||||||
|
|
||||||
| Provider | Free Tier | Model | Setup |
|
| Provider | Free Tier | Model | Setup |
|
||||||
|----------|-----------|-------|-------|
|
|----------|-----------|-------|-------|
|
||||||
| **Qwen OAuth** | 2,000/day | Qwen3-Coder | `qwen && /auth` |
|
| **Qwen OAuth** | 2,000/day | Qwen3-Coder | `qwen --auth-type qwen-oauth` |
|
||||||
|
|
||||||
## Tier 2: Major AI Labs
|
## Tier 2: Major AI Labs
|
||||||
|
|
||||||
@@ -143,126 +192,29 @@ zeroclaw # ZeroClaw with FREE Qwen
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Multi-Provider Configuration
|
# Quick Import Script
|
||||||
|
|
||||||
## Full Configuration Example
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"providers": {
|
|
||||||
"qwen_oauth": {
|
|
||||||
"type": "oauth",
|
|
||||||
"free": true,
|
|
||||||
"daily_limit": 2000,
|
|
||||||
"model": "qwen3-coder-plus"
|
|
||||||
},
|
|
||||||
"anthropic": {
|
|
||||||
"apiKey": "${ANTHROPIC_API_KEY}",
|
|
||||||
"baseURL": "https://api.anthropic.com"
|
|
||||||
},
|
|
||||||
"openai": {
|
|
||||||
"apiKey": "${OPENAI_API_KEY}",
|
|
||||||
"baseURL": "https://api.openai.com/v1"
|
|
||||||
},
|
|
||||||
"google": {
|
|
||||||
"apiKey": "${GOOGLE_API_KEY}",
|
|
||||||
"baseURL": "https://generativelanguage.googleapis.com/v1"
|
|
||||||
},
|
|
||||||
"azure": {
|
|
||||||
"apiKey": "${AZURE_OPENAI_API_KEY}",
|
|
||||||
"baseURL": "${AZURE_OPENAI_ENDPOINT}"
|
|
||||||
},
|
|
||||||
"vertex": {
|
|
||||||
"projectId": "${GOOGLE_CLOUD_PROJECT}",
|
|
||||||
"location": "${GOOGLE_CLOUD_LOCATION}"
|
|
||||||
},
|
|
||||||
"bedrock": {
|
|
||||||
"region": "us-east-1",
|
|
||||||
"accessKeyId": "${AWS_ACCESS_KEY_ID}",
|
|
||||||
"secretAccessKey": "${AWS_SECRET_ACCESS_KEY}"
|
|
||||||
},
|
|
||||||
"openrouter": {
|
|
||||||
"apiKey": "${OPENROUTER_API_KEY}",
|
|
||||||
"baseURL": "https://openrouter.ai/api/v1"
|
|
||||||
},
|
|
||||||
"xai": {
|
|
||||||
"apiKey": "${XAI_API_KEY}",
|
|
||||||
"baseURL": "https://api.x.ai/v1"
|
|
||||||
},
|
|
||||||
"mistral": {
|
|
||||||
"apiKey": "${MISTRAL_API_KEY}",
|
|
||||||
"baseURL": "https://api.mistral.ai/v1"
|
|
||||||
},
|
|
||||||
"groq": {
|
|
||||||
"apiKey": "${GROQ_API_KEY}",
|
|
||||||
"baseURL": "https://api.groq.com/openai/v1"
|
|
||||||
},
|
|
||||||
"cerebras": {
|
|
||||||
"apiKey": "${CEREBRAS_API_KEY}",
|
|
||||||
"baseURL": "https://api.cerebras.ai/v1"
|
|
||||||
},
|
|
||||||
"deepinfra": {
|
|
||||||
"apiKey": "${DEEPINFRA_API_KEY}",
|
|
||||||
"baseURL": "https://api.deepinfra.com/v1"
|
|
||||||
},
|
|
||||||
"cohere": {
|
|
||||||
"apiKey": "${COHERE_API_KEY}",
|
|
||||||
"baseURL": "https://api.cohere.ai/v1"
|
|
||||||
},
|
|
||||||
"together": {
|
|
||||||
"apiKey": "${TOGETHER_API_KEY}",
|
|
||||||
"baseURL": "https://api.together.xyz/v1"
|
|
||||||
},
|
|
||||||
"perplexity": {
|
|
||||||
"apiKey": "${PERPLEXITY_API_KEY}",
|
|
||||||
"baseURL": "https://api.perplexity.ai"
|
|
||||||
},
|
|
||||||
"ollama": {
|
|
||||||
"baseURL": "http://localhost:11434/v1",
|
|
||||||
"apiKey": "ollama"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"agents": {
|
|
||||||
"defaults": {
|
|
||||||
"model": "anthropic/claude-sonnet-4-5",
|
|
||||||
"temperature": 0.7
|
|
||||||
},
|
|
||||||
"free": {
|
|
||||||
"model": "qwen/qwen3-coder-plus"
|
|
||||||
},
|
|
||||||
"fast": {
|
|
||||||
"model": "groq/llama-3.3-70b-versatile"
|
|
||||||
},
|
|
||||||
"local": {
|
|
||||||
"model": "ollama/llama3.2:70b"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Fetch Available Models
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# OpenRouter - All 100+ models
|
#!/bin/bash
|
||||||
curl -s https://openrouter.ai/api/v1/models \
|
# Usage: source import-qwen-oauth.sh [platform]
|
||||||
-H "Authorization: Bearer $OPENROUTER_API_KEY" | jq '.data[].id'
|
|
||||||
|
|
||||||
# OpenAI - GPT models
|
CREDS_FILE="$HOME/.qwen/oauth_creds.json"
|
||||||
curl -s https://api.openai.com/v1/models \
|
PLATFORM="${1:-zeroclaw}"
|
||||||
-H "Authorization: Bearer $OPENAI_API_KEY" | jq '.data[].id'
|
|
||||||
|
|
||||||
# Groq - Fast inference models
|
QWEN_TOKEN=$(cat "$CREDS_FILE" | jq -r '.access_token')
|
||||||
curl -s https://api.groq.com/openai/v1/models \
|
|
||||||
-H "Authorization: Bearer $GROQ_API_KEY" | jq '.data[].id'
|
|
||||||
|
|
||||||
# Ollama - Local models
|
case "$PLATFORM" in
|
||||||
curl -s http://localhost:11434/api/tags | jq '.models[].name'
|
zeroclaw)
|
||||||
|
# Native provider - just set config
|
||||||
# Anthropic (static list)
|
sed -i 's/^default_provider = .*/default_provider = "qwen-oauth"/' ~/.zeroclaw/config.toml
|
||||||
# claude-opus-4-5-20250219, claude-sonnet-4-5-20250219, claude-3-5-sonnet-20241022
|
sed -i 's/^default_model = .*/default_model = "qwen3-coder-plus"/' ~/.zeroclaw/config.toml
|
||||||
|
;;
|
||||||
# Google Gemini
|
*)
|
||||||
curl -s "https://generativelanguage.googleapis.com/v1/models?key=$GOOGLE_API_KEY"
|
# OpenAI-compatible
|
||||||
|
export OPENAI_API_KEY="$QWEN_TOKEN"
|
||||||
|
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -272,7 +224,7 @@ curl -s "https://generativelanguage.googleapis.com/v1/models?key=$GOOGLE_API_KEY
|
|||||||
## Qwen Code (Native FREE OAuth)
|
## Qwen Code (Native FREE OAuth)
|
||||||
```bash
|
```bash
|
||||||
npm install -g @qwen-code/qwen-code@latest
|
npm install -g @qwen-code/qwen-code@latest
|
||||||
qwen && /auth
|
qwen --auth-type qwen-oauth -p "test"
|
||||||
```
|
```
|
||||||
|
|
||||||
## OpenClaw
|
## OpenClaw
|
||||||
@@ -313,8 +265,24 @@ chmod +x zeroclaw-linux-amd64 && sudo mv zeroclaw-linux-amd64 /usr/local/bin/zer
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Automation Scripts
|
# Troubleshooting
|
||||||
|
|
||||||
See `scripts/` directory:
|
## Token Expired
|
||||||
- `import-qwen-oauth.sh` - Import FREE Qwen OAuth to any platform
|
|
||||||
- `fetch-models.sh` - Fetch available models from all providers
|
```bash
|
||||||
|
# ZeroClaw: Automatic refresh (no action needed)
|
||||||
|
|
||||||
|
# Other platforms: Re-authenticate and re-export
|
||||||
|
qwen --auth-type qwen-oauth -p "test"
|
||||||
|
export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token')
|
||||||
|
```
|
||||||
|
|
||||||
|
## API Test
|
||||||
|
|
||||||
|
```bash
|
||||||
|
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"}]}'
|
||||||
|
```
|
||||||
|
|||||||
@@ -1,99 +1,202 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# import-qwen-oauth.sh - Import Qwen OAuth to any platform
|
# Import FREE Qwen OAuth to any Claw platform
|
||||||
# Usage: source import-qwen-oauth.sh && <platform-command>
|
# Usage: source import-qwen-oauth.sh [platform]
|
||||||
|
#
|
||||||
|
# Platforms:
|
||||||
|
# zeroclaw - Native qwen-oauth provider (recommended, auto token refresh)
|
||||||
|
# picoclaw - OpenAI-compatible import
|
||||||
|
# openclaw - OpenAI-compatible import
|
||||||
|
# nanobot - OpenAI-compatible import
|
||||||
|
# nanoclaw - OpenAI-compatible import
|
||||||
|
#
|
||||||
|
# Requirements:
|
||||||
|
# - qwen-code CLI installed: npm install -g @qwen-code/qwen-code@latest
|
||||||
|
# - jq for JSON parsing
|
||||||
|
# - Authenticated: qwen --auth-type qwen-oauth -p "test"
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "╔═══════════════════════════════════════════════════════════════╗"
|
CREDS_FILE="$HOME/.qwen/oauth_creds.json"
|
||||||
echo "║ QWEN OAUTH CROSS-PLATFORM IMPORTER ║"
|
PLATFORM="${1:-zeroclaw}"
|
||||||
echo "║ FREE: 2,000 requests/day, 60 req/min ║"
|
|
||||||
echo "╚═══════════════════════════════════════════════════════════════╝"
|
|
||||||
|
|
||||||
# Check if Qwen Code is installed
|
# Colors
|
||||||
if ! command -v qwen &> /dev/null; then
|
RED='\033[0;31m'
|
||||||
echo "📦 Qwen Code not found. Installing..."
|
GREEN='\033[0;32m'
|
||||||
npm install -g @qwen-code/qwen-code@latest
|
YELLOW='\033[1;33m'
|
||||||
fi
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
# Check if Qwen Code is authenticated
|
echo "🦞 Claw Setup - Qwen OAuth Import"
|
||||||
if [ ! -d ~/.qwen ]; then
|
echo "=================================="
|
||||||
echo ""
|
echo ""
|
||||||
echo "❌ Qwen Code not authenticated."
|
|
||||||
|
# Check for credentials file
|
||||||
|
if [ ! -f "$CREDS_FILE" ]; then
|
||||||
|
echo -e "${RED}Error: Qwen OAuth credentials not found${NC}"
|
||||||
|
echo "File expected at: $CREDS_FILE"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Please run:"
|
echo "To authenticate, run:"
|
||||||
echo " qwen"
|
echo " npm install -g @qwen-code/qwen-code@latest"
|
||||||
echo " /auth # Select 'Qwen OAuth'"
|
echo " qwen --auth-type qwen-oauth -p 'test'"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Then run this script again."
|
echo "This will open a browser for FREE OAuth login."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Find OAuth token file
|
# Check for jq
|
||||||
TOKEN_FILES=$(find ~/.qwen -name "*.json" -type f 2>/dev/null)
|
if ! command -v jq &> /dev/null; then
|
||||||
if [ -z "$TOKEN_FILES" ]; then
|
echo -e "${YELLOW}Warning: jq not found, using grep/sed fallback${NC}"
|
||||||
echo "❌ No OAuth token found in ~/.qwen/"
|
QWEN_TOKEN=$(cat "$CREDS_FILE" | grep -o '"access_token"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/.*"access_token"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/')
|
||||||
echo " Please authenticate first: qwen && /auth"
|
else
|
||||||
exit 1
|
QWEN_TOKEN=$(cat "$CREDS_FILE" | jq -r '.access_token')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Try to extract token from various file formats
|
|
||||||
QWEN_TOKEN=""
|
|
||||||
for TOKEN_FILE in $TOKEN_FILES; do
|
|
||||||
# Try different JSON structures
|
|
||||||
QWEN_TOKEN=$(cat "$TOKEN_FILE" | jq -r '.access_token // .token // .accessToken // .credentials?.token // empty' 2>/dev/null)
|
|
||||||
if [ -n "$QWEN_TOKEN" ] && [ "$QWEN_TOKEN" != "null" ]; then
|
|
||||||
echo "✅ Found token in: $TOKEN_FILE"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -z "$QWEN_TOKEN" ] || [ "$QWEN_TOKEN" = "null" ]; then
|
if [ -z "$QWEN_TOKEN" ] || [ "$QWEN_TOKEN" = "null" ]; then
|
||||||
echo "❌ Could not extract OAuth token"
|
echo -e "${RED}Error: Could not extract access_token from credentials${NC}"
|
||||||
echo " Token files found but no valid token structure"
|
echo "Credentials file may be corrupted. Try re-authenticating:"
|
||||||
echo " Try re-authenticating: qwen && /auth"
|
echo " qwen --auth-type qwen-oauth -p 'test'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Export environment variables
|
echo "Platform: $PLATFORM"
|
||||||
|
echo "Token: ${QWEN_TOKEN:0:20}..."
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
case "$PLATFORM" in
|
||||||
|
zeroclaw)
|
||||||
|
# ZeroClaw uses native qwen-oauth provider
|
||||||
|
CONFIG_FILE="$HOME/.zeroclaw/config.toml"
|
||||||
|
|
||||||
|
if [ ! -f "$CONFIG_FILE" ]; then
|
||||||
|
echo -e "${YELLOW}ZeroClaw config not found, creating...${NC}"
|
||||||
|
mkdir -p "$HOME/.zeroclaw"
|
||||||
|
cat > "$CONFIG_FILE" << 'EOF'
|
||||||
|
default_provider = "qwen-oauth"
|
||||||
|
default_model = "qwen3-coder-plus"
|
||||||
|
default_temperature = 0.7
|
||||||
|
|
||||||
|
[autonomy]
|
||||||
|
level = "supervised"
|
||||||
|
workspace_only = true
|
||||||
|
|
||||||
|
[memory]
|
||||||
|
backend = "sqlite"
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
# Update existing config
|
||||||
|
sed -i 's/^default_provider = .*/default_provider = "qwen-oauth"/' "$CONFIG_FILE"
|
||||||
|
sed -i 's/^default_model = .*/default_model = "qwen3-coder-plus"/' "$CONFIG_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${GREEN}✅ ZeroClaw configured with native qwen-oauth provider${NC}"
|
||||||
|
echo ""
|
||||||
|
echo "ZeroClaw automatically:"
|
||||||
|
echo " • Reads ~/.qwen/oauth_creds.json"
|
||||||
|
echo " • Refreshes expired tokens"
|
||||||
|
echo " • Uses correct DashScope API endpoint"
|
||||||
|
echo ""
|
||||||
|
echo "Test with:"
|
||||||
|
echo " zeroclaw agent -m 'Hello!'"
|
||||||
|
;;
|
||||||
|
|
||||||
|
picoclaw)
|
||||||
export OPENAI_API_KEY="$QWEN_TOKEN"
|
export OPENAI_API_KEY="$QWEN_TOKEN"
|
||||||
export OPENAI_BASE_URL="https://api.qwen.ai/v1"
|
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
|
|
||||||
|
echo -e "${GREEN}✅ PicoClaw environment configured${NC}"
|
||||||
|
echo ""
|
||||||
|
echo "Environment variables set:"
|
||||||
|
echo " OPENAI_API_KEY=${QWEN_TOKEN:0:20}..."
|
||||||
|
echo " OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
|
echo ""
|
||||||
|
echo "Test with:"
|
||||||
|
echo " picoclaw agent -m 'Hello!'"
|
||||||
|
;;
|
||||||
|
|
||||||
|
openclaw)
|
||||||
|
export OPENAI_API_KEY="$QWEN_TOKEN"
|
||||||
|
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
|
|
||||||
|
echo -e "${GREEN}✅ OpenClaw environment configured${NC}"
|
||||||
|
echo ""
|
||||||
|
echo "Environment variables set:"
|
||||||
|
echo " OPENAI_API_KEY=${QWEN_TOKEN:0:20}..."
|
||||||
|
echo " OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
|
echo ""
|
||||||
|
echo "Test with:"
|
||||||
|
echo " openclaw"
|
||||||
|
;;
|
||||||
|
|
||||||
|
nanobot)
|
||||||
|
export OPENAI_API_KEY="$QWEN_TOKEN"
|
||||||
|
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
export OPENAI_MODEL="qwen3-coder-plus"
|
export OPENAI_MODEL="qwen3-coder-plus"
|
||||||
|
|
||||||
# Save to .env for persistence
|
echo -e "${GREEN}✅ NanoBot environment configured${NC}"
|
||||||
mkdir -p ~/.qwen
|
echo ""
|
||||||
cat > ~/.qwen/.env << ENVEOF
|
echo "Environment variables set:"
|
||||||
# Qwen OAuth Configuration for Cross-Platform Use
|
echo " OPENAI_API_KEY=${QWEN_TOKEN:0:20}..."
|
||||||
# Generated: $(date)
|
echo " OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
OPENAI_API_KEY=$QWEN_TOKEN
|
echo " OPENAI_MODEL=qwen3-coder-plus"
|
||||||
OPENAI_BASE_URL=https://api.qwen.ai/v1
|
echo ""
|
||||||
OPENAI_MODEL=qwen3-coder-plus
|
echo "Test with:"
|
||||||
|
echo " nanobot"
|
||||||
|
;;
|
||||||
|
|
||||||
# Usage:
|
nanoclaw)
|
||||||
# source ~/.qwen/.env && openclaw
|
export OPENAI_API_KEY="$QWEN_TOKEN"
|
||||||
# source ~/.qwen/.env && nanobot gateway
|
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
# source ~/.qwen/.env && picoclaw gateway
|
|
||||||
# source ~/.qwen/.env && zeroclaw gateway
|
|
||||||
ENVEOF
|
|
||||||
|
|
||||||
chmod 600 ~/.qwen/.env
|
echo -e "${GREEN}✅ NanoClaw environment configured${NC}"
|
||||||
|
echo ""
|
||||||
|
echo "Environment variables set:"
|
||||||
|
echo " OPENAI_API_KEY=${QWEN_TOKEN:0:20}..."
|
||||||
|
echo " OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
|
echo ""
|
||||||
|
echo "Test with:"
|
||||||
|
echo " nanoclaw"
|
||||||
|
;;
|
||||||
|
|
||||||
|
all)
|
||||||
|
# Configure all platforms
|
||||||
|
echo "Configuring all platforms..."
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# ZeroClaw
|
||||||
|
CONFIG_FILE="$HOME/.zeroclaw/config.toml"
|
||||||
|
if [ -f "$CONFIG_FILE" ]; then
|
||||||
|
sed -i 's/^default_provider = .*/default_provider = "qwen-oauth"/' "$CONFIG_FILE"
|
||||||
|
sed -i 's/^default_model = .*/default_model = "qwen3-coder-plus"/' "$CONFIG_FILE"
|
||||||
|
echo -e "${GREEN}✅ ZeroClaw${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set environment for other platforms
|
||||||
|
export OPENAI_API_KEY="$QWEN_TOKEN"
|
||||||
|
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
|
|
||||||
|
echo -e "${GREEN}✅ PicoClaw, OpenClaw, NanoBot, NanoClaw${NC}"
|
||||||
|
echo ""
|
||||||
|
echo "Environment exported for current session."
|
||||||
|
echo "Add to ~/.bashrc for persistence:"
|
||||||
|
echo ""
|
||||||
|
echo 'export OPENAI_API_KEY="$(cat ~/.qwen/oauth_creds.json | jq -r '\''.access_token'\'')"' >> ~/.bashrc
|
||||||
|
echo 'export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"' >> ~/.bashrc
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
# Generic - set environment variables
|
||||||
|
export OPENAI_API_KEY="$QWEN_TOKEN"
|
||||||
|
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
|
|
||||||
|
echo -e "${GREEN}✅ Generic environment configured for $PLATFORM${NC}"
|
||||||
|
echo ""
|
||||||
|
echo "Environment variables set:"
|
||||||
|
echo " OPENAI_API_KEY=${QWEN_TOKEN:0:20}..."
|
||||||
|
echo " OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "✅ Qwen OAuth imported successfully!"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
echo ""
|
echo "FREE Qwen OAuth: 2,000 requests/day, 60 req/min"
|
||||||
echo " OPENAI_API_KEY=***${QWEN_TOKEN: -8}"
|
echo "API Endpoint: https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
echo " OPENAI_BASE_URL=$OPENAI_BASE_URL"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
echo " OPENAI_MODEL=$OPENAI_MODEL"
|
|
||||||
echo ""
|
|
||||||
echo "✅ Configuration saved to ~/.qwen/.env"
|
|
||||||
echo ""
|
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
||||||
echo "Usage with platforms:"
|
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
||||||
echo ""
|
|
||||||
echo " source ~/.qwen/.env && openclaw"
|
|
||||||
echo " source ~/.qwen/.env && nanobot gateway"
|
|
||||||
echo " source ~/.qwen/.env && picoclaw gateway"
|
|
||||||
echo " source ~/.qwen/.env && zeroclaw gateway"
|
|
||||||
echo ""
|
|
||||||
echo "Free tier limits: 2,000 requests/day, 60 requests/minute"
|
|
||||||
echo ""
|
|
||||||
|
|||||||
Reference in New Issue
Block a user