Qwen Code integration guide
AI codingUpdated: 2025-11-27Introduction
Qwen Code (Tongyi Lingma) is Alibaba Cloud's AI coding assistant built on the Qwen models. It offers line- and function-level completion, natural language to code, unit test generation, comment generation, code explanation, developer Q&A and error diagnosis.
Key capabilities
- 🚀 Smart completion — real-time line- and function-level completion
- 💡 Natural language to code — describe what you want and get code
- 🔍 Explanation and optimization — analyze logic and suggest improvements
- 🧪 Unit test generation — produce complete test cases in one step
- 🐛 Smart debugging — locate and fix errors quickly
- 💬 Developer Q&A — ask programming questions any time
Why connect it to SeaWhale AI?
Through SeaWhale AI, Qwen Code gains:
- ✅ 200+ models — GPT-4, Claude, Gemini and other top models
- ✅ Pay as you go — no subscription, pay only for what you use
- ✅ Automatic failover — switches models automatically to stay available
- ✅ OpenAI-compatible — drops into your existing workflow
Supported IDEs
Qwen Code works with the major IDEs:
| IDE | Version | Download |
|---|---|---|
| Visual Studio Code | 1.75.0+ | VSCode marketplace |
| JetBrains IDEs | 2022.1+ | JetBrains marketplace |
| IntelliJ IDEA | 2022.1+ | As above |
| PyCharm | 2022.1+ | As above |
| WebStorm | 2022.1+ | As above |
| GoLand | 2022.1+ | As above |
Compatibility
This guide uses Visual Studio Code for its examples. The steps for JetBrains IDEs are similar.
Before you begin
Make sure you have:
- ✅ A supported IDE installed (the latest version is recommended)
- ✅ A SeaWhale AI API key (how to get one)
- ✅ Enough account balance to call model services
- ✅ Network access to the SeaWhale AI API endpoint
Important
Qwen Code uses Alibaba Cloud's own service by default. This guide walks through pointing it at SeaWhale AI instead, for a wider model choice and flexible billing.
Installation and configuration
Step 1: install the Qwen Code plugin
VSCode
Option 1: the marketplace (recommended)
- Open VSCode
- Click the Extensions icon in the activity bar (or press
Ctrl+Shift+X/Cmd+Shift+X) - Search for
Tongyi Lingma - Find the Alibaba Cloud - Tongyi Lingma extension
- Click Install
Option 2: the command line
code --install-extension Alibaba-Cloud.tongyi-lingmaJetBrains
- Open IntelliJ IDEA / PyCharm / WebStorm
- Go to File → Settings (Windows/Linux) or Preferences (macOS)
- Choose Plugins → Marketplace
- Search for
Tongyi Lingma - Click Install and restart the IDE
Step 2: point it at SeaWhale AI
Qwen Code defaults to Alibaba Cloud's service, so you need to change the endpoint.
VSCode
Open settings
- Click the gear icon in the bottom left → Settings
- Or press
Ctrl+,(Windows/Linux) /Cmd+,(macOS)
Find the Qwen Code settings
- Search for
tongyi - Locate the
Tongyi Lingmasettings
- Search for
Configure the endpoint
| Setting | Description | Value |
|---|---|---|
| API Base URL | The SeaWhale AI API address | https://api.your-domain.com/v1 |
| API Key | Your SeaWhale AI API key | sk-xxxxxxxxxxxxxxxx |
| Model | The model to use | gpt-4 / claude-3-opus etc. |
Example settings.json
You can also edit VSCode's settings.json directly:
{
"tongyi.apiBaseUrl": "https://api.your-domain.com/v1",
"tongyi.apiKey": "sk-xxxxxxxxxxxxxxxx",
"tongyi.model": "gpt-4-turbo",
"tongyi.enableCodeCompletion": true,
"tongyi.enableInlineCompletion": true,
"tongyi.temperature": 0.3,
"tongyi.maxTokens": 2048
}JetBrains
- Open File → Settings → Tools → Tongyi Lingma
- Configure:
- API Base URL:
https://api.your-domain.com/v1 - API Key: your SeaWhale AI API key
- Model: select or type a model ID (such as
gpt-4-turbo)
- API Base URL:
- Click Test Connection
- Click OK to save
Step 3: choose a model
SeaWhale AI supports many models, each suited to different work:
Recommended configurations
| Use case | Recommended model | Model ID | Why |
|---|---|---|---|
| Everyday coding | GPT-3.5 Turbo | gpt-3.5-turbo | Fast and inexpensive, good for completion |
| Complex tasks | GPT-4 Turbo | gpt-4-turbo | Strong reasoning, high code quality |
| Code review | Claude 3 Opus | claude-3-opus | Excellent at understanding code |
| Python development | DeepSeek Coder | deepseek-coder | A model tuned specifically for code |
| Frontend work | GPT-4 | gpt-4 | Broad web technology knowledge |
Switching models
- Use GPT-3.5 Turbo for completion and simple tasks — fast and cheap
- Use GPT-4 Turbo or Claude 3 Opus for complex algorithms and design
- See the full model list for more options
Using the main features
1. Smart code completion
Qwen Code offers line-level and function-level completion.
Line completion
As you type, Qwen Code predicts the next line:
# Write a comment and the code follows
# Compute the nth Fibonacci number
# Qwen Code completes:
def fibonacci(n):
if n <= 1:
return n
return fibonacci(n-1) + fibonacci(n-2)Function completion
Write a signature and a comment, and it fills in the body:
/**
* Check whether an email address is valid
* @param email the email address
* @returns whether it is valid
*/
function validateEmail(email: string): boolean {
// Qwen Code completes the implementation
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
return emailRegex.test(email)
}Tips
- Accept a suggestion: press
Tab - Next suggestion: press
Alt+](Windows/Linux) orOption+](macOS) - Dismiss it: keep typing or press
Esc
2. Natural language to code
Describe what you want and let the model write it.
How to use it
VSCode:
- Select a region, or place the cursor where you want the code
- Press
Ctrl+Shift+L(Windows/Linux) orCmd+Shift+L(macOS) - Describe what you need in the dialog
- The model generates the code
JetBrains:
- Right-click in the editor
- Choose Tongyi Lingma → Generate Code
- Type your description
Example
The request:
Create a user login endpoint that takes a username and password and returns a JWT tokenThe generated code:
const express = require('express')
const jwt = require('jsonwebtoken')
const router = express.Router()
router.post('/login', async (req, res) => {
const {username, password} = req.body
// Validate the credentials (a real project would query the database)
if (!username || !password) {
return res.status(400).json({error: 'Username and password are required'})
}
// Issue a JWT
const token = jwt.sign({username}, process.env.JWT_SECRET, {expiresIn: '24h'})
res.json({token, message: 'Signed in'})
})
module.exports = router3. Explaining and optimizing code
Explain code
Select some code and use Explain Code to get a detailed walkthrough.
Shortcuts:
- VSCode:
Ctrl+Shift+E/Cmd+Shift+E - JetBrains: right-click → Tongyi Lingma → Explain Code
Optimize code
Select code and use Optimize Code for improvement suggestions.
Example:
Before:
def find_max(numbers):
max_num = numbers[0]
for i in range(len(numbers)):
if numbers[i] > max_num:
max_num = numbers[i]
return max_numAfter:
def find_max(numbers):
"""Return the largest value in the list"""
return max(numbers) if numbers else None4. Generating unit tests
Qwen Code can generate tests for your functions automatically.
How to use it
- Place the cursor inside the function
- Use the shortcut or right-click → Generate Unit Test
- Complete test cases are generated
Example
The function:
def calculate_discount(price, discount_rate):
"""Calculate the discounted price"""
if discount_rate < 0 or discount_rate > 1:
raise ValueError("The discount rate must be between 0 and 1")
return price * (1 - discount_rate)The generated tests:
import unittest
class TestCalculateDiscount(unittest.TestCase):
def test_normal_discount(self):
"""A typical discount"""
self.assertEqual(calculate_discount(100, 0.2), 80)
def test_zero_discount(self):
"""No discount"""
self.assertEqual(calculate_discount(100, 0), 100)
def test_full_discount(self):
"""A full discount"""
self.assertEqual(calculate_discount(100, 1), 0)
def test_invalid_discount_negative(self):
"""A negative discount rate"""
with self.assertRaises(ValueError):
calculate_discount(100, -0.1)
def test_invalid_discount_over_one(self):
"""A discount rate above 1"""
with self.assertRaises(ValueError):
calculate_discount(100, 1.5)
if __name__ == '__main__':
unittest.main()5. Debugging and fixing errors
When your code errors, Qwen Code helps locate and fix the problem.
How to use it
- Click Fix on the error, or use the shortcut
- The model analyzes the cause and suggests a fix
- Apply the fix in one click
Example
The broken code:
const users = [
{name: 'Alice', age: 25},
{name: 'Bob', age: 30},
]
const totalAge = users.reduce((sum, user) => sum + user.age)
// TypeError: Cannot read property 'age' of undefinedThe diagnosis:
Cause: reduce has no initial value, so on the first iteration sum is an
object rather than a number.
Suggested fix:The fix:
const totalAge = users.reduce((sum, user) => sum + user.age, 0)
// Correct result: 556. Developer Q&A
Qwen Code includes a chat assistant for programming questions.
Opening the chat panel
VSCode:
- Click the Qwen Code icon in the activity bar
- Or press
Ctrl+Shift+T/Cmd+Shift+T
JetBrains:
- Click the Qwen Code icon in the right toolbar
- Or go to Tools → Tongyi Lingma Chat
Common question types
| Type | Example |
|---|---|
| API usage | "How do I use Python's asyncio for concurrent work?" |
| Troubleshooting | "Why does my React component render infinitely?" |
| Best practices | "How should I handle async errors in Node.js?" |
| Technology choice | "Should I use MySQL or PostgreSQL?" |
| Code review | "What security issues does this code have?" |
Advanced configuration
Tuning completion parameters
You can fine-tune behavior in VSCode's settings.json:
{
// Completion settings
"tongyi.enableCodeCompletion": true, // Enable completion
"tongyi.enableInlineCompletion": true, // Enable inline completion
"tongyi.completionDelay": 300, // Delay in milliseconds
// Model parameters
"tongyi.temperature": 0.3, // Randomness (0–1)
"tongyi.maxTokens": 2048, // Maximum generation length
"tongyi.topP": 0.95, // Nucleus sampling
// Behavior
"tongyi.autoAcceptSuggestions": false, // Accept suggestions automatically
"tongyi.showInlineReferences": true, // Show reference sources
// Filters
"tongyi.excludedFiles": [
// File types to skip
"*.log",
"*.md",
"node_modules/**"
]
}Parameter reference
| Parameter | Description | Suggested value |
|---|---|---|
| temperature | Controls diversity • Lower: deterministic, good for code • Higher: creative, good for brainstorming | 0.2–0.4 (code) 0.6–0.8 (creative) |
| maxTokens | Maximum length of a single generation | 1024–2048 |
| completionDelay | Delay before completion triggers (milliseconds) | 200–500 |
Optimizing token usage
How token billing works
SeaWhale AI bills per token, and different operations cost different amounts:
| Operation | Tokens | Suggestion |
|---|---|---|
| Line completion | 50–200 | Happens often — use a lightweight model |
| Function completion | 200–500 | Moderate cost, use judiciously |
| Code generation | 500–2000 | Describe requirements precisely |
| Code explanation | 300–800 | Use it only on the code that matters |
| Chat Q&A | 100–1000 | Keep questions specific |
Ways to save tokens
Best practices
Pick the right model
- Simple completion:
gpt-3.5-turbo - Complex tasks:
gpt-4-turbo - Specialized code work:
deepseek-coder
- Simple completion:
Reduce unnecessary completions
json{ "tongyi.completionDelay": 500, // Longer delay "tongyi.excludedFiles": ["*.md", "*.txt"] // Skip text files }Write better prompts
- ❌ Weak: "write a function"
- ✅ Strong: "write a JavaScript function that validates an email with a regex and returns a boolean"
Control the context length
- You rarely need to pass the whole file
- Provide only the context that matters
Batch related work
- Generate several related functions at once
- Fewer API calls overall :::
Monitoring token usage
Check your consumption regularly:
- Open the SeaWhale AI console
- Go to Usage → Token consumption
- Look for high-cost patterns and optimize them
FAQ
Q1: How do I switch models?
VSCode:
- Open settings (
Ctrl+,/Cmd+,) - Search for
tongyi.model - Change it to another model ID (such as
claude-3-opus)
JetBrains:
- Settings → Tools → Tongyi Lingma
- Select or type a model ID in the Model dropdown
See the model list for supported models.
Q2: Completion is slow
Possible causes:
- Network latency
- High model load
- Too much context
Fixes:
Reduce the completion delay
json{ "tongyi.completionDelay": 200 // Down to 200ms }Switch to a faster model
json{ "tongyi.model": "gpt-3.5-turbo" // A lighter model }Limit the context
json{ "tongyi.maxContextLines": 50 // Cap the context lines }
Q3: How do I disable completion for certain files?
Configure exclusions in settings.json:
{
"tongyi.excludedFiles": [
"*.md", // Markdown
"*.txt", // Text files
"*.log", // Logs
"node_modules/**", // Dependencies
"dist/**", // Build output
".git/**" // Git internals
]
}Q4: The generated code isn't good enough
Improving quality
Use a stronger model
- Move from
gpt-3.5-turbotogpt-4-turbo - Or use
claude-3-opusfor better reasoning
- Move from
Provide more context
- Write clear comments describing what you want
- Include type definitions and interfaces
- Give example inputs and outputs
Tune the generation parameters
json{ "tongyi.temperature": 0.2, // Less randomness "tongyi.maxTokens": 2048 // Allow longer output }Iterate
- Generate a first version
- Improve it with "Optimize Code"
- Use "Explain Code" to check the logic :::
Q5: How do I handle API failures?
Error: 401 Unauthorized
Cause: the API key is invalid or expired.
Fix:
- Check the API key is correct
- Confirm your account is in good standing
- Regenerate the API key
Error: 429 Too Many Requests
Cause: requests are too frequent.
Fix:
- Increase
completionDelay - Trigger completion less often
- Increase your account quota
Error: 500 Internal Server Error
Cause: a server-side error.
Fix:
- Retry later
- Switch to a fallback model
- Contact support
Q6: Which programming languages are supported?
Qwen Code supports all mainstream languages:
| Category | Languages |
|---|---|
| Backend | Python, Java, Go, Node.js, C/C++, C#, PHP, Ruby, Rust |
| Frontend | JavaScript, TypeScript, HTML, CSS, Vue, React, Angular |
| Mobile | Swift, Kotlin, Dart (Flutter), Java (Android) |
| Data science | Python (NumPy, Pandas), R, Julia, MATLAB |
| Other | SQL, Shell, YAML, JSON, Markdown |
Best practices
1. Getting the most from completion
Completion tips
✅ Do:
Write clear comments
python# Binary search for a target value in a sorted array # Time complexity: O(log n) def binary_search(arr, target): # The model generates the right implementation from the commentDefine explicit signatures
typescriptinterface User { id: string; name: string; email: string; } // With types available, the model generates type-safe code function validateUser(user: User): boolean {Give example data
javascript// Example input: [1, 2, 3, 4, 5] // Expected output: [1, 4, 9, 16, 25] function squareArray(numbers) {
❌ Avoid:
Vague descriptions
python# process data ❌ too vague def process(data):Missing type information
javascriptfunction calculate(a, b) { // ❌ numbers or strings?Meaningless names
pythondef func1(x, y, z): // ❌ names carry no meaning
2. Getting the most from code generation
Describe requirements the SMART way
- Specific: spell out the details
- Measurable: give expected inputs and outputs
- Achievable: keep the scope reasonable
- Relevant: match the surrounding context
- Time-bound: state any performance requirements
Comparison
❌ A weak description:
Write a user management system✅ A strong description:
Create an Express.js user management API with:
1. POST /users - create a user (name, email, password)
2. GET /users/:id - fetch a user
3. PUT /users/:id - update a user
4. DELETE /users/:id - delete a user
Store data in MongoDB, hash passwords with bcrypt, return JSON3. Working as a team
Team conventions
Share configuration
- Create a shared
settings.jsontemplate - Use the same model and parameters
- Keep code style consistent
- Create a shared
Review the output
- Generated code still needs human review
- Watch for security and performance issues
- Add the tests that matter
Version control
- Add
.vscode/settings.jsonto.gitignoreif it holds an API key - Manage secrets through environment variables
- Note which code was AI-assisted
- Add
Cost control
- Monitor the team's total token usage
- Assign different models to different roles
- Review high-cost patterns regularly :::
4. Security
Security reminders
Protect secrets
- Never put real API keys or passwords in comments
- Manage secrets with environment variables and config files
- The model may reuse sensitive values it sees in context
Review generated code
- AI-generated code can contain vulnerabilities
- Pay particular attention to SQL injection and XSS
- Run security scanners over generated code
License compliance
- Generated code may inadvertently reproduce open-source code
- Make sure it is compatible with your project's license
- Do not ship unreviewed snippets
Data privacy
- Do not feed user personal data to the model
- Be careful sending internal code to a cloud service
- Consider a local deployment if you need to :::
Going further
1. Custom prompt templates
Save frequently used prompts as templates:
// .vscode/settings.json
{
"tongyi.customPrompts": {
"generateAPI": "Create a RESTful API with CRUD operations using the {framework} framework and {database} database",
"addTests": "Generate complete unit tests for the following function using {testFramework}, with 90%+ coverage",
"refactor": "Refactor the following code for performance and readability, following {language} best practices"
}
}2. Working alongside other tools
Compared with GitHub Copilot
| Feature | Qwen Code (SeaWhale AI) | GitHub Copilot |
|---|---|---|
| Model choice | 200+ models | Fixed model |
| Billing | Per token | Fixed monthly |
| Custom endpoint | Supported | Not supported |
Pairs well with
- ESLint / Prettier — format generated code automatically
- GitLens — track the history of generated code
- Code Spell Checker — catch typos in generated comments
3. Performance tips
Performance checklist
Caching:
{
"tongyi.enableCache": true, // Enable local caching
"tongyi.cacheExpiryTime": 3600 // Cache for an hour
}Concurrency:
{
"tongyi.maxConcurrentRequests": 3, // At most 3 in flight
"tongyi.requestTimeout": 10000 // 10-second timeout
}Selective enablement:
{
"tongyi.enabledLanguages": [
// Only for these languages
"python",
"javascript",
"typescript"
]
}Related resources
Recommended reading
- 📚 Quick start — SeaWhale AI API basics
- 🔧 API reference — the complete API documentation
- 🎯 Model list — every available model
Other AI coding tools
| Tool | Platforms | Characteristics |
|---|---|---|
| Qwen Code | VSCode/JetBrains | Broad feature set |
| Cline | VSCode | Plans and runs multi-step tasks |
| Claude Code | CLI | Terminal-based, good for scripting |
| Cursor | Standalone IDE | Deep integration, new editing model |
Support
Getting help
We offer several support channels:
| Channel | Response time | Best for |
|---|---|---|
| 📖 Documentation | Immediate | Common questions and usage guides |
| 💬 Live support | Weekdays 9:00–18:00 | Real-time technical questions |
| 📧 Email support | Within 24 hours | Detailed reports and feedback |
| 🐛 Bug reports | Within 48 hours | Bugs and feature requests |
Quick links
Changelog
2025-11-27
- ✨ Added the Qwen Code integration guide
- 📝 Improved SEO metadata
- 🎨 Refined the document structure
© 2024 SeaWhale AI. All rights reserved.
Last updated 2025-11-27