What is the SDK?
The SDK is a TypeScript/JavaScript library that lets you:- Execute queries and get AI-powered code suggestions
- Stream responses in real-time
- Implement multi-turn conversations
- Create custom tools with MCP (Model Context Protocol)
- Control permissions and tool execution
- Manage session state and history
Key Features
Simple Query Interface
Execute single-turn queries with minimal setup:Multi-Turn Conversations
Build interactive AI assistants with conversation history:Custom Tools via MCP
Extend Qwen Code with custom functionality:Fine-Grained Permission Control
Control which operations the AI can perform:Requirements
- Node.js: >= 18.0.0
- TypeScript: >= 5.0.0 (for TypeScript projects)
Bundle Information
From SDK version 0.1.1 onwards, the Qwen Code CLI is bundled with the SDK. No separate CLI installation is required.If you’re using SDK version 0.1.0, you need to install Qwen Code CLI separately (>= 0.4.0) and ensure it’s in your PATH.
Use Cases
Application Integration
Embed AI coding assistance directly into your development tools:- Code editors and IDEs
- CI/CD pipelines
- Code review systems
- Documentation generators
Automation Scripts
Automate repetitive coding tasks:- Bulk code refactoring
- Test generation
- Code migration
- Documentation updates
Custom Workflows
Build specialized AI-powered workflows:- Interactive code tutoring systems
- Automated bug fixing bots
- Code quality analyzers
- Project scaffolding tools
Architecture
The SDK communicates with the Qwen Code CLI via a JSON-based protocol:- SDK Process: Your application using the TypeScript SDK
- CLI Process: Spawned Qwen Code CLI instance
- MCP Servers: Tools that extend functionality (can run in-process or external)
Next Steps
Installation
Install the SDK and set up your project
Quick Start
Run your first query in under 5 minutes
API Reference
Explore the complete API documentation
Examples
Learn from practical examples
