# Qwen-Agent — Build AI Agents on Qwen Models > Agent framework by Alibaba with function calling, code interpreter, RAG, and MCP support. Built for Qwen 3.0+. 15K+ stars. ## Install Save as a script file and run: # Qwen-Agent — Build AI Agents on Qwen Models ## Quick Use ```bash pip install -U "qwen-agent[gui,rag,code_interpreter,mcp]" ``` ```python from qwen_agent.agents import Assistant # Create an agent with tools agent = Assistant( llm={"model": "qwen-max", "api_key": "YOUR_KEY"}, function_list=["code_interpreter", "web_search"], system_message="You are a helpful data analyst." ) # Run a task messages = [{"role": "user", "content": "Analyze the trend of AI funding in 2025"}] for response in agent.run(messages): print(response) ``` --- ## Intro Qwen-Agent is an open-source agent framework by the Alibaba Qwen team, designed to build LLM-powered applications on top of Qwen models (3.0+). With 15,800+ GitHub stars, it provides native function calling, a sandboxed code interpreter running in Docker, RAG pipelines for document understanding, MCP tool discovery, and a built-in Gradio GUI for rapid prototyping. It's the official way to build agents with Qwen — the leading open-weight LLM family from China. Works with: Qwen models (qwen-max, qwen-plus, qwen-turbo), DashScope API, local Qwen deployments. Best for developers building AI agents on the Qwen ecosystem. Setup time: under 5 minutes. --- ## Qwen-Agent Architecture & Features ### Core Components ``` ┌─────────────────────────────────────┐ │ Agent Layer │ │ Assistant │ ReActChat │ Router │ ├─────────────────────────────────────┤ │ Tool Layer │ │ Function Calling │ Code Interpreter│ │ Web Search │ MCP Tools │ Custom │ ├─────────────────────────────────────┤ │ LLM Layer │ │ Qwen-Max │ Qwen-Plus │ Local Qwen │ └─────────────────────────────────────┘ ``` ### Function Calling Native function calling with automatic schema parsing: ```python from qwen_agent.tools import BaseTool, register_tool @register_tool("get_weather") class WeatherTool(BaseTool): description = "Get weather for a city" parameters = [{"name": "city", "type": "string", "required": True}] def call(self, params, **kwargs): city = params["city"] return f"Weather in {city}: 25°C, sunny" ``` ### Code Interpreter Executes Python code in an isolated Docker sandbox: - Matplotlib/Seaborn chart generation - Pandas data analysis - File I/O in sandboxed environment - Automatic output capture and display ### RAG (Retrieval Augmented Generation) Built-in document understanding pipeline: - PDF, DOCX, HTML, Markdown parsing - Chunking with configurable overlap - Vector similarity search - Citation tracking in responses ### MCP Support Connect external tools via Model Context Protocol: ```python agent = Assistant( llm={"model": "qwen-max"}, mcp_servers=[{ "url": "http://localhost:8080/mcp", "tools": ["search", "calculator"] }] ) ``` ### Built-in GUI Launch a Gradio chat interface instantly: ```python from qwen_agent.gui import WebUI WebUI(agent).run(server_port=7860) ``` ### Multi-Agent Orchestration Route tasks to specialized agents: ```python from qwen_agent.agents import GroupChat, Router agents = [coder_agent, researcher_agent, writer_agent] router = Router(llm=llm, agents=agents) ``` --- ## FAQ **Q: What is Qwen-Agent?** A: Qwen-Agent is an open-source Python framework by Alibaba for building AI agents on Qwen models, featuring function calling, code interpretation, RAG, and MCP support. 15,800+ GitHub stars. **Q: Can I use Qwen-Agent with non-Qwen models?** A: It's optimized for Qwen models but supports any OpenAI-compatible API endpoint. Best results come from Qwen-Max and Qwen-Plus which have native function calling. **Q: Is Qwen-Agent free?** A: Yes, Apache-2.0 licensed. The Qwen models themselves have varying licenses — Qwen 3.0 is Apache-2.0 for most sizes. --- ## Source & Thanks > Created by [QwenLM](https://github.com/QwenLM) (Alibaba Qwen Team). Licensed under Apache-2.0. > > [Qwen-Agent](https://github.com/QwenLM/Qwen-Agent) — ⭐ 15,800+ Thanks to the Qwen team at Alibaba for open-sourcing both the models and the agent framework. --- ## 快速使用 ```bash pip install -U "qwen-agent[gui,rag,code_interpreter,mcp]" ``` ```python from qwen_agent.agents import Assistant agent = Assistant( llm={"model": "qwen-max", "api_key": "YOUR_KEY"}, function_list=["code_interpreter", "web_search"], system_message="你是一个数据分析师。" ) messages = [{"role": "user", "content": "分析 2025 年 AI 融资趋势"}] for response in agent.run(messages): print(response) ``` --- ## 简介 Qwen-Agent 是阿里巴巴通义千问团队开源的 AI 代理框架,基于 Qwen 模型(3.0+)构建。拥有 15,800+ GitHub stars,提供原生函数调用、Docker 沙盒代码解释器、RAG 文档理解管线、MCP 工具发现和内置 Gradio 界面。这是在千问生态中构建 AI Agent 的官方方式。 适用于:Qwen 系列模型(qwen-max、qwen-plus、qwen-turbo)、DashScope API、本地 Qwen 部署。适合在千问生态中开发 AI 代理的开发者。 --- ## 核心功能 ### 函数调用 原生函数调用,自动解析工具 schema,支持自定义工具注册。 ### 代码解释器 在隔离的 Docker 沙盒中执行 Python 代码,支持数据分析和图表生成。 ### RAG 文档理解 内置文档解析、分块、向量检索和引用追踪。 ### MCP 支持 通过模型上下文协议连接外部工具和数据源。 ### 多 Agent 协作 支持 GroupChat 和 Router 模式,将任务路由到专门的代理。 --- ## 来源与感谢 > Created by [QwenLM](https://github.com/QwenLM) (Alibaba Qwen Team). Licensed under Apache-2.0. > > [Qwen-Agent](https://github.com/QwenLM/Qwen-Agent) — ⭐ 15,800+ --- Source: https://tokrepo.com/en/workflows/d95df987-a5d5-4578-90d7-45e4c8b34f93 Author: TokRepo精选