Agent with Tools
Give a DashScope qwen-plus agent web search tools and stream the response.
Code
from agno.agent import Agent
from agno.models.dashscope import DashScope
from agno.tools.websearch import WebSearchTools
agent = Agent(
model=DashScope(id="qwen-plus"),
tools=[WebSearchTools()],
markdown=True,
)
agent.print_response("What's happening in AI today?", stream=True)The default endpoint is Singapore (https://dashscope-intl.aliyuncs.com/compatible-mode/v1). Use a DASHSCOPE_API_KEY issued for that service region and a model available there. Keys and endpoints must match the service region, regardless of your physical location. For another region, pass its base_url to DashScope; see Model Studio API keys and regional endpoints.
Usage
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateSet your API key
export DASHSCOPE_API_KEY=xxxInstall dependencies
uv pip install -U openai ddgs agnoRun Agent
Save the code above as tool_use.py, then run:
python tool_use.py