Dashscope Thinking Agent
Enable thinking on DashScope's QVQ Max to reason through an image problem.
"""
Dashscope Thinking Agent
========================
Cookbook example for `dashscope/thinking_agent.py`.
"""
from agno.agent import Agent
from agno.media import Image
from agno.models.dashscope import DashScope
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
model=DashScope(id="qvq-max", enable_thinking=True),
)
image_url = "https://img.alicdn.com/imgextra/i1/O1CN01gDEY8M1W114Hi3XcN_!!6000000002727-0-tps-1024-406.jpg"
agent.print_response(
"How do I solve this problem? Please think through each step carefully.",
images=[Image(url=image_url)],
stream=True,
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
passRun the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno openaiConfigure regional DashScope access
Activate Alibaba Cloud Model Studio and create an API key for your region and workspace. Agno's default endpoint is Singapore: https://dashscope-intl.aliyuncs.com/compatible-mode/v1.
export DASHSCOPE_API_KEY="your_singapore_api_key"For another region or a workspace-specific domain, pass the matching base_url to DashScope. Use the OpenAI-compatible endpoint guide to match the URL, key and available model. The documented Singapore default remains functional.
Run the example
Save the code above as thinking_agent.py, then run:
python thinking_agent.pyFull source: cookbook/90_models/dashscope/thinking_agent.py