@agentor/dashscope has 1,044 recorded weekly downloads on npm, an increase of 319% over the past 30 days, ranking #1387 of 2,256 tracked listings.
About @agentor/dashscope
@agentor/dashscope
English | 中文
AI SDK provider for Alibaba Cloud DashScope (Bailian) API.
Features
• Chat Completions - /chat/completions with function calling, streaming, reasoning, and vision • Completions (FIM) - /completions for code completion with Qwen Coder models • Responses - /responses endpoint with built-in tools (web search, code interpreter, MCP, etc.) • Embedding - Text vectorization via /embeddings endpoint • Reranking - Document reranking via /reranks endpoint • Image Generation - Text-to-image via multimodal generation endpoint • Video Generation - Text-to-video and image-to-video with async polling • Speech Synthesis - Text-to-speech for CosyVoice and Qwen-TTS models • Transcription - Speech-to-text for short and long audio • Built-in Tools - Web search, code interpreter, web extractor, file search, web search image, image search, MCP integration • Thinking Mode - Enable reasoning/thinking with configurable budget • Multi-region - Beijing, Singapore, US, Germany regions • AI SDK V4 - Implements the LanguageModelV4 specification • TypeScript-First - Full type safety with comprehensive TypeScript support
Installation
Quick Start
Setup
Or use the default instance (reads DASHSCOPE_API_KEY from environment):
Basic Chat
Streaming
Function Calling
Chat Completions API
Web Search
Enable web search via providerOptions:
Options: enableSearch, searchStrategy ("enable" | "enable_with_history" | "agent_max").
Code Interpreter
Enable code interpreter (requires thinking mode):
Thinking Mode
Enable reasoning with configurable budget:
Context Cache
Applies to the Chat endpoint (dashscope(modelId)). The Responses endpoint (dashscope.responses(modelId)) caches via a session header instead — see Session Cache.
DashScope supports explicit caching to reduce cost and latency for repeated prefixes. Add cacheControl via providerOptions on messages or content parts:
Cache on user message content parts:
Implicit caching is enabled automatically for supported models — no configuration needed.
Combining with structured output
By default the schema is sent via response_format (json_schema) and never enters the messages, so a cacheControl marker anywhere — system or user message — keeps hitting across calls regardless of how the schema changes.
Only models that reject json_schema fall back to json_object + prompt injection. In that fallback the schema is injected as a user message after the system block, so it stays outside the system cache prefix and a system-side cacheControl marker still hits. Qwen3.5+ merges every system message into one cache segment and only honors a cache_control marker at the segment tail, so the schema is never injected as a system message. Prefer placing cacheControl on the system message; on user content parts in fallback mode, the injected schema lands before that content and may prevent it from being cached.
JSON Output
Structured Output with Schema
Use generateText with Output.object() to generate typed JSON:
The provider sends the schema via native response_format: { type: "json_schema" } (strict). The schema is enforced server-side and travels in response_format — it never enters the messages, so a cacheControl marker anywhere keeps hitting even as the schema varies per call. Models that reject json_schema fall back automatically to json_object + prompt injection (best-effort; validate the output).
Supported models
Structured output is supported across the Qwen family and partner models, including qwen3.7-max, qwen3-max, qwen3.7-plus, qwen-plus, qwen3.7-flash, qwen3.5-flash, qwen-flash, qwen-turbo, qwen3-coder, qwen-long, the Qwen-VL models, and partner models (Kimi, DeepSeek, GLM, Stepfun). See the official guide for the full, up-to-date list.
Thinking mode
Models marked "non-thinking" may return non-strict JSON under thinking mode. For reliable structured output, avoid combining enableThinking with Output.object, or use the two-step repair: generate with the thinking model first, then normalize the result through a fast non-thinking model (e.g. qwen-flash) with Output.object.
Avoid maxOutputTokens
Do not set maxOutputTokens (max_tokens) with structured output — capping output tokens can truncate the JSON mid-stream and break parsing.
Completions (FIM)
Use completionModel() for text/code completion via the /completions endpoint (Fill-In-the-Middle):
Responses API
Use the responses namespace for the Responses API with built-in tools:
Built-in Tools
Web Search
Options: forcedSearch, searchStrategy ("enable" | "enable_with_history").
Code Interpreter
Web Extractor
Can be used together with webSearch for enhanced results.
File Search
MCP Integration
Options: serverProtocol, serverLabel, serverUrl, serverDescription, headers.
Web Search Image
Text-to-image search. Search images based on a text description.
Image Search
Image-to-image search. Search similar images based on an input image.
Multi-turn Conversation
Options via providerOptions.dashscope: previousResponseId, enableThinking, reasoning (effort levels), conversation, instructions, includeUsage.
Use previousResponseId for multi-turn conversations:
Session Cache
The Responses endpoint caches via server-side session cache, not cache_control markers. Setting cacheControl on any message automatically sends the x-dashscope-session-cache: enable header — combine it with previousResponseId (above) to carry context across turns and hit the cache (minimum 1024 tokens, 5-minute TTL).
OCR (Qwen-OCR)
Qwen-OCR models (qwen3.5-ocr, qwen-vl-ocr, qwen-vl-ocr-latest) extract text and structured data from images and PDFs. Both endpoints accept providerOptions.dashscope.ocrOptions; the Responses endpoint officially honors the built-in tasks (and is the only one that accepts PDF). On Chat, pass the image as a file part and drive extraction through the text prompt (data is a Uint8Array):
On the Responses endpoint, set a built-in task via ocrOptions.task:…
Description from the npm listing.
- ai
- ai-sdk
- alibaba
- aliyun
- bailian
- dashscope
- qwen
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (121)Similar npm AI SDKs plugins
All 20 @agentor/dashscope alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/@agentor/dashscope. First seen Oct 16, 2026; last successful collection Oct 19, 2026. See the methodology.