DashScope Image Agent
Analyze image URLs with a tool-capable Qwen3-VL model and enrich answers with web search.
Analyze two image URLs with a tool-capable Qwen3-VL model and enrich both responses with web search.
The source combines WebSearchTools with qwen-vl-plus, while Alibaba documents function calling for the Qwen3-VL families. Its second Wikimedia thumbnail URL also returns HTTP 400. Apply both migrations before running. See Alibaba's function-calling model list.
"""
Dashscope Image Agent
=====================
Cookbook example for `dashscope/image_agent.py`.
"""
import asyncio
from agno.agent import Agent
from agno.media import Image
from agno.models.dashscope import DashScope
from agno.tools.websearch import WebSearchTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
model=DashScope(id="qwen-vl-plus"),
tools=[WebSearchTools()],
markdown=True,
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
# --- Sync + Streaming ---
agent.print_response(
"Analyze this image in detail and tell me what you see. Also search for more information about the subject.",
images=[
Image(
url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg"
)
],
stream=True,
)
# --- Async + Streaming ---
async def main():
await agent.aprint_response(
"What do you see in this image? Provide a detailed description and search for related information.",
images=[
Image(
url="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg"
)
],
stream=True,
)
asyncio.run(main())Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno ddgs 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.
Use a tool-capable vision model
Replace DashScope(id="qwen-vl-plus") with DashScope(id="qwen3-vl-plus") in the saved file.
Replace the unavailable image
Replace https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg with https://agno-public.s3.amazonaws.com/images/krakow_mariacki.jpg in the saved file.
Run the example
Save the code above as image_agent.py, then run:
python image_agent.pyFull source: cookbook/90_models/dashscope/image_agent.py