Terminal AI coding assistant
OpenCode is a terminal-based AI coding assistant that helps you write, debug, and refactor code directly from the command line. Connect it to Qwen Cloud's pay-as-you-go API for intelligent coding assistance powered by Qwen models.
Get running in a few minutes:
You should see: OpenCode analyzes your project and creates a README
Configure OpenCode to use Qwen Cloud:
Then:
OpenCode automatically reads your project structure. For better results:
"Cannot find module opencode-ai"
Reduce usage by:
Quick start
Get running in a few minutes:
Configuration
Basic setup
Configure OpenCode to use Qwen Cloud:
- Provider: Alibaba
- Authentication: API key required
- Model selection: Choose from available Qwen models
Free quota and billing:
- First-time users get a free quota (valid for 90 days)
- Enable Free quota only to prevent unexpected charges
For Coding Plan users: Use your exclusive base URL and API key instead. See Coding Plan for OpenCode.
Prerequisites
- Node.js 18 or later (download)
- API key
Step-by-step setup
1
Install OpenCode
2
Navigate to project
3
Connect to Qwen Cloud
- Search provider: Type
alibaba - Select:
Alibaba - Enter: Your API key
- Choose: Model (e.g.,
qwen3.5-plus)
Model recommendations
| Task | Model | Why |
|---|---|---|
| Quick edits | qwen3.5-plus | Balanced speed and quality |
| Code generation | qwen3-coder-plus | Specialized for coding |
| Complex refactoring | qwen3-coder-plus | Deep code understanding |
| Architecture design | qwen3-max | Advanced reasoning |
Limitations
- Terminal only: No GUI interface
- Project context: Works best when started in project root
- Token usage: Large projects consume more tokens
Examples
Generate code
Explain code
Refactor existing code
Write tests
Fix bugs
Commands
| Command | Description |
|---|---|
/connect | Connect to API provider |
/disconnect | Disconnect from provider |
/model | Switch to different model |
/clear | Clear conversation context |
/help | Show available commands |
/exit | Exit OpenCode |
Advanced features
Context management
OpenCode automatically reads your project structure. For better results:
- Start OpenCode in your project root
- Keep project files organized
- Use clear file and folder names
Multi-file operations
Code review
Documentation generation
Troubleshooting
"Cannot find module opencode-ai"
Solution: Ensure global npm installation:"Invalid API key"
Solution:"Model not available"
- Verify API key is correct
- Check you selected "Alibaba" provider
- Ensure API key has quota
Solution:High token consumption
- Check model access permissions
- Try a different model
- See Model list
Solution:Connection timeout
- Start OpenCode in specific subdirectories
- Use
/clearto reset context- Choose appropriate models for tasks
Solution:
- Check network connection
- Verify API endpoint accessibility
- Try reconnecting with
/connect
Token optimization
Reduce usage by:
- Focused context: Start OpenCode in specific project subdirectories
- Clear prompts: Be specific about what you need
- Context clearing: Use
/clearbetween unrelated tasks - Model selection: Use lightweight models for simple tasks
- Batch operations: Combine related requests
Related resources
- Coding Plan: Setup with subscription →
- Models: Available models → | Pricing →
- API docs: DashScope API reference →
- OpenCode docs: Official documentation →