@polyweave/qwen (1.0.2)
Installation
@polyweave:registry=https://hub.kl1.tenere.ai/api/packages/Polyweave/npm/npm install @polyweave/qwen@1.0.2"@polyweave/qwen": "1.0.2"About this package
Qwen (Alibaba)
Alibaba Qwen adapter for Polyweave. Widest model catalog, multimodal, 1M context.
Published as @polyweave/qwen.
Synopsis
import { createQwenAdapter } from '@polyweave/qwen';
import { createTextFrame, createFrameSink } from '@polyweave/core';
var adapter = createQwenAdapter({ apiKey: process.env.DASHSCOPE_API_KEY, model: 'qwen3-max' });
adapter.source.pipe(createFrameSink(function(frame) {
if (frame.type === 'TEXT') console.log(frame.content.text);
}));
adapter.sink.write(createTextFrame('Explain the theory of relativity'));
Install
npm install @polyweave/qwen
Description
Alibaba Qwen adapter with OpenAI-compatible chat completions, thinking mode (CoT up to 81,920 tokens), multimodal input (text+image+video for Qwen3.5-Plus), embeddings, and streaming SSE. Supports International, Global, US, EU, HK, and China deployment regions via baseURL.
Models: qwen3-max, qwen3.5-plus, qwen3.5-flash, qwen-plus, qwen-flash, qwen-vl-max, qwen-vl-plus, qwen-omni, qwen-coder-plus, qwen3-embedding.
API
createQwenAdapter(config)
| Parameter | Type | Default | Description |
|---|---|---|---|
config.apiKey |
string |
process.env.DASHSCOPE_API_KEY |
API key |
config.baseURL |
string |
https://dashscope-intl.aliyuncs.com/compatible-mode/v1 |
Base URL |
config.model |
string |
qwen3-max |
Default model |
config.budget |
number |
0 | Budget cap |
config.name |
string |
null | Node name for PARAM targeting |
config.timeout |
number |
120000 | Request timeout in ms |
Returns an IFrameDuplex with source and sink.
Frame Protocol
| Inbound | Outbound |
|---|---|
| TEXT, IMAGE, EMBEDDING | TEXT, IMAGE, EMBEDDING, TOOL_CALL, RECEIPT, ERROR, END |
| PARAM | — |
| COST_CHECK | COST |
PARAM Keys
model, max_tokens, temperature, top_p, stream, enable_thinking, system, tools, tool_choice, response_format, embedding_model, budget, apiKey
Tests
npm test
Covers adapter construction and frame buffering.
Requirements
Node.js 18 or later. ESM only.
Caveats
Qwen uses tiered pricing by input size for some models. The international endpoint (dashscope-intl.aliyuncs.com) is used by default. For China deployment, use the China-specific endpoint. Thinking mode is toggled via PARAM enable_thinking (boolean).
See Also
License
MIT
Dependencies
Development Dependencies
| ID | Version |
|---|---|
| @rigor/core | * |
Peer Dependencies
| ID | Version |
|---|---|
| @polyweave/core | * |
| @polyweave/costs | * |