Thinking Agent

Enable DashScope's thinking mode to reason over an image before responding.

Code

from agno.agent import Agent
from agno.media import Image
from agno.models.dashscope import DashScope

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,
)

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/activate

Set your API key

export DASHSCOPE_API_KEY=xxx

Install dependencies

uv pip install -U openai agno

Run Agent

Save the code above as thinking_agent.py, then run:

python thinking_agent.py