DashScope
Use Alibaba DashScope Qwen models with Agno agents.
Use Alibaba DashScope's Qwen models with Agno agents.
DashScope supports a wide range of models.
We recommend experimenting to find the best-suited model for your use-case. Here are some general recommendations:
qwen-plusmodel is good for most use-cases.
Installation
uv pip install -U openai agnoAuthentication
Set your DASHSCOPE_API_KEY environment variable.
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.
export DASHSCOPE_API_KEY="YOUR_API_KEY"Example
Use DashScope with your Agent:
from agno.agent import Agent
from agno.models.dashscope import DashScope
agent = Agent(
model=DashScope(id="qwen-plus"),
markdown=True
)
# Print the response in the terminal
agent.print_response("Share a 2 sentence horror story.")
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
id | str | "qwen-plus" | The id of the Qwen model to use |
name | str | "Qwen" | The name of the model |
provider | str | "Dashscope" | The provider of the model |
api_key | Optional[str] | None | The API key for DashScope (defaults to the DASHSCOPE_API_KEY env var, falling back to QWEN_API_KEY) |
base_url | str | "https://dashscope-intl.aliyuncs.com/compatible-mode/v1" | The endpoint for the service region that issued your key. The default is Singapore; use a matching regional endpoint for other keys. |
enable_thinking | bool | False | Enable thinking process for reasoning models |
include_thoughts | Optional[bool] | None | Alias for enable_thinking; overrides it when not None |
thinking_budget | Optional[int] | None | Budget for thinking tokens in reasoning models |
DashScope extends the OpenAI-compatible interface and supports most parameters from the OpenAI model.
For a Beijing-region key, set the endpoint explicitly:
DashScope(id="qwen-plus", base_url="https://dashscope.aliyuncs.com/compatible-mode/v1")Thinking Models
DashScope supports reasoning models with thinking capabilities:
from agno.agent import Agent
from agno.models.dashscope import DashScope
agent = Agent(
model=DashScope(
id="qwen-plus",
enable_thinking=True,
thinking_budget=5000
),
markdown=True
)