Skip to main content

🔴 Qwen Models

Qwen (通义千问) is Alibaba Cloud's family of large language models, offering excellent performance in both Chinese and English, with strong capabilities in reasoning, coding, and creative tasks. Qwen models are known for their efficiency and multilingual support.

🌟 Why Choose Qwen?

Qwen Advantages

📊 Available Models

ModelParametersContext WindowBest ForPricing
Qwen2.5 72B72B32K tokensHigh-quality, complex tasks$0.60/1M input, $2.40/1M output
Qwen2.5 32B32B32K tokensBalanced performance$0.30/1M input, $1.20/1M output
Qwen2.5 14B14B32K tokensFast, cost-effective$0.15/1M input, $0.60/1M output
Qwen2.5 7B7B32K tokensLightweight tasks$0.08/1M input, $0.32/1M output
Qwen2.5 1.5B1.5B32K tokensUltra-fast inference$0.02/1M input, $0.08/1M output

Source: Alibaba Cloud Qwen Pricing

🚀 Getting Started

Step 1: Create Alibaba Cloud Account

  1. Visit Alibaba Cloud Console
  2. Sign up with your email
  3. Verify your account
  4. Complete profile setup

Step 2: Enable DashScope Service

  1. Go to DashScope Console
  2. Enable the service
  3. Set up billing (required for API access)

Step 3: Get API Key

  1. Go to API Keys section
  2. Click "Create API Key"
  3. Give it a descriptive name
  4. Copy the key and store securely

Step 4: Configure in MCP for WP

  1. Go to MCP for WP > Settings
  2. Set Provider to "Qwen"
  3. Enter your API key
  4. Select default model (e.g., qwen2.5-14b)
  5. Click "Test Connection"
  6. Save settings

Option 2: Self-Hosting Qwen2

Step 1: Install Ollama

bash
# macOS/Linux
curl -fsSL https://ollama.ai/install.sh | sh

# Windows
# Download from https://ollama.ai/download

Step 2: Pull Qwen Model

bash
# Pull Qwen2.5 7B
ollama pull qwen2.5:7b

# Or Qwen2.5 14B
ollama pull qwen2.5:14b

Step 3: Start Ollama Server

bash
ollama serve

Step 4: Configure in MCP for WP

  1. Set Provider to "Qwen"
  2. Set API Endpoint: http://localhost:11434
  3. Set Model: qwen2.5:7b
  4. Test connection

⚙️ Model Configuration

Default Settings

json
{
  "model": "qwen2.5-14b",
  "max_tokens": 2048,
  "temperature": 0.7,
  "top_p": 0.9,
  "top_k": 40,
  "repetition_penalty": 1.1
}

Parameter Guide

Model Selection

  • qwen2.5-72b: Best for complex reasoning, high-quality outputs
  • qwen2.5-32b: Balanced performance and cost
  • qwen2.5-14b: Good for most tasks, cost-effective
  • qwen2.5-7b: Fast, lightweight tasks
  • qwen2.5-1.5b: Ultra-fast, simple tasks

Max Tokens

  • Range: 1 to 32768 (varies by model)
  • Recommendation: Start with 2048, adjust as needed

Temperature

  • Range: 0.0 to 1.0
  • 0.0: Deterministic
  • 0.7: Balanced
  • 1.0: Creative

Top P

  • Range: 0.0 to 1.0
  • 1.0: All tokens
  • 0.9: Top 90% probability mass

Top K

  • Range: 1 to 100
  • 40: Good balance
  • Lower: More focused
  • Higher: More diverse

Repetition Penalty

  • Range: 1.0 to 2.0
  • 1.0: No penalty
  • 1.1: Slight penalty
  • Higher: Stronger penalty

💰 Pricing & Usage

Alibaba Cloud DashScope Pricing

ModelInput CostOutput CostFree Tier
Qwen2.5 72B$0.60/1M tokens$2.40/1M tokens$10 credit
Qwen2.5 32B$0.30/1M tokens$1.20/1M tokens$10 credit
Qwen2.5 14B$0.15/1M tokens$0.60/1M tokens$10 credit
Qwen2.5 7B$0.08/1M tokens$0.32/1M tokens$10 credit
Qwen2.5 1.5B$0.02/1M tokens$0.08/1M tokens$10 credit

Self-Hosting Costs

ModelRAM RequiredGPU RequiredMonthly Cost
Qwen2.5 72B144GBRequired$300-800
Qwen2.5 32B64GBRecommended$150-400
Qwen2.5 14B28GBOptional$50-150
Qwen2.5 7B14GBOptional$20-80
Qwen2.5 1.5B3GBNo$0-30

Cost Optimization Tips

  1. Use smaller models for simple tasks
  2. Choose appropriate model for task complexity
  3. Monitor token usage
  4. Self-host for high-volume usage

🔧 Advanced Configuration

System Instructions

json
{
  "system_instruction": "You are a helpful assistant."
}

Function Calling

json
{
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get weather information",
        "parameters": {
          "type": "object",
          "properties": {
            "location": { "type": "string" }
          }
        }
      }
    }
  ]
}

Multilingual Support

Qwen excels at Chinese and English. Configure your tool for multilingual use:

json
{
  "input_schema": {
    "type": "object",
    "properties": {
      "text": { "type": "string", "description": "Text to process" },
      "language": { "type": "string", "enum": ["auto", "zh", "en"] }
    },
    "required": ["text"]
  }
}

🛠️ Use Cases & Examples

Chinese-English Translation

Tool Configuration:

json
{
  "input_schema": {
    "type": "object",
    "properties": {
      "text": { "type": "string", "description": "Text to translate" },
      "source_language": { "type": "string", "enum": ["zh", "en"] },
      "target_language": { "type": "string", "enum": ["zh", "en"] },
      "style": { "type": "string", "enum": ["formal", "casual", "technical"] }
    },
    "required": ["text", "target_language"]
  }
}

Recommended Settings:

  • Model: qwen2.5-14b
  • Temperature: 0.3
  • Max Tokens: 1024

Code Generation

Tool Configuration:

json
{
  "input_schema": {
    "type": "object",
    "properties": {
      "language": { "type": "string", "description": "Programming language" },
      "task": { "type": "string", "description": "What to code" },
      "complexity": { "type": "string", "enum": ["simple", "medium", "complex"] }
    },
    "required": ["language", "task"]
  }
}

Recommended Settings:

  • Model: qwen2.5-14b
  • Temperature: 0.3
  • Max Tokens: 2048

Content Analysis

Tool Configuration:

json
{
  "input_schema": {
    "type": "object",
    "properties": {
      "content": { "type": "string", "description": "Content to analyze" },
      "analysis_type": { "type": "string", "enum": ["sentiment", "summary", "keywords"] },
      "language": { "type": "string", "enum": ["auto", "zh", "en"] }
    },
    "required": ["content", "analysis_type"]
  }
}

Recommended Settings:

  • Model: qwen2.5-7b
  • Temperature: 0.3
  • Max Tokens: 1024

🔍 Troubleshooting

Common Issues

  • API Key Invalid: Check Alibaba Cloud console
  • Rate Limit Exceeded: Check usage limits
  • Model Not Available: Verify model name
  • Connection Failed: Check network connectivity

Debugging Tips

  1. Check API key in Alibaba Cloud console
  2. Monitor usage and billing
  3. Review request logs in MCP for WP
  4. Test with DashScope playground
  5. Check quotas and limits

Performance Optimization

  1. Choose appropriate model size
  2. Optimize prompt length
  3. Use caching when possible
  4. Implement rate limiting

📚 Additional Resources

🔐 Security Best Practices

  • Keep API keys secure
  • Monitor usage for anomalies
  • Use environment variables
  • Implement rate limiting
  • Regular security audits

📞 Support


Ready to get started? Configure your Qwen integration or explore other providers!