@zhivex-ai/qwen 0.19.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +114 -77
- package/dist/index.js.map +1 -1
- package/dist/qwen4.d.ts +9 -0
- package/dist/qwen4.d.ts.map +1 -0
- package/dist/qwen4.js +97 -0
- package/dist/qwen4.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,6 +32,52 @@ Supported region values are `singapore`, `beijing`, `hong-kong`, `tokyo`, `frank
|
|
|
32
32
|
|
|
33
33
|
Qwen speech downloads accept HTTPS audio URLs only, validate every redirect manually, and never forward the provider API key to the media host.
|
|
34
34
|
|
|
35
|
+
## Qwen4-Max
|
|
36
|
+
|
|
37
|
+
Use `qwen("qwen4-max")` with standard Model Studio credentials. Both Chat Completions and Responses support generation, streaming, text/image/video input, callable tools, and parallel tool calls. Native JSON Schema uses Chat; hosted tools use Responses. Audio and document-file input are rejected; output is text. Availability still depends on the account and region.
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
const result = await generateText({
|
|
41
|
+
model: qwen("qwen4-max"),
|
|
42
|
+
prompt: "Compute 17 times 23.",
|
|
43
|
+
reasoning: { effort: "low" },
|
|
44
|
+
maxTokens: 2048,
|
|
45
|
+
providerOptions: {
|
|
46
|
+
apiMode: "responses",
|
|
47
|
+
thinking_display: "summarized",
|
|
48
|
+
store: false,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Thinking is enabled by default. The final model uses `low`, `high`, and `xhigh`: Chat maps `minimal` to `low`, `medium` to `high`, and `max` to `xhigh`; `none` disables thinking. Responses sends the shared effort directly. With no controls, upstream uses `high` with a 131072-token thinking budget. A budget-only request preserves the supplied budget and leaves upstream to select the effort. Use either effort or budget, not both. Thinking budgets are 1–262144. Chat always preserves thinking history. Forced callable-tool selection requires thinking to be disabled.
|
|
54
|
+
|
|
55
|
+
`maxTokens` bounds reasoning plus the final answer: at most 262144 tokens with thinking, or 131072 without it. Chat sends `max_completion_tokens`; Responses sends `max_output_tokens`. Native schema output requires Chat. Qwen Responses only documents `text.format.type: "text"`, and live requests with `json_schema` can return invalid JSON despite `strict: true`. Native schemas combined with Responses, hosted tools, or `max_output_tokens` are rejected before fetching. For hosted tools with structured output, use `generateObject({ mode: "prompted", ... })` and local schema validation; this does not provide server-enforced JSON Schema. See the [Responses API contract](https://docs.qwencloud.com/api-reference/chat/openai-responses). Video uses a `FilePart` with a `video/*` MIME type; both APIs accept public URLs, data URLs, or raw base64.
|
|
56
|
+
|
|
57
|
+
### Thinking summaries and encrypted history
|
|
58
|
+
|
|
59
|
+
Set `providerOptions.thinking_display: "summarized"` for either API, or `providerOptions.reasoning: { summary: "auto" }`. The adapter translates this to Chat `thinking_display` plus `enable_thinking`, or Responses `reasoning.summary`. Summaries require thinking enabled and are specific to the final `qwen4-max` model.
|
|
60
|
+
|
|
61
|
+
Keep the complete returned `messages`, including `provider-data`, for subsequent turns and tool loops. Chat stores ciphertext as Qwen provider data with `type: "encrypted_content"` and `encryptedContent`; replay maps it back to the assistant's `encrypted_content`. Responses retains complete `reasoning` items. Streamed Responses summary deltas use `type: "reasoning_summary"`; the completed reasoning snapshot is the replayable history, not those display deltas. Ciphertext-only frames are retained and final snapshots do not duplicate the reasoning item. Never concatenate ciphertext or put it in visible text. Missing ciphertext remains missing; the SDK does not reconstruct reasoning from a summary.
|
|
62
|
+
|
|
63
|
+
Use the same API mode and summary setting on each turn. With `store: false`, Responses replays the supplied full history without `previous_response_id`; otherwise the existing server-side continuation behavior remains available. Persist original images/video along with the returned messages because ciphertext contains reasoning, not the original input media.
|
|
64
|
+
|
|
65
|
+
### Qwen4 explicit prompt cache
|
|
66
|
+
|
|
67
|
+
`providerOptions.prompt_cache_options` supports `{ mode: "implicit" | "explicit", ttl: "5m" | "1h" }`; an empty object enables automatic caching. For manual breakpoints, put `providerMetadata: { prompt_cache_breakpoint: { mode: "explicit" } }` on a text or image part. Chat also preserves the compatible `cache_control: { type: "ephemeral", ttl: "1h" }` marker. Do not mix marker styles in a request. The adapter keeps text-only marked content as an array, forwards supported visual options (`min_pixels`, `max_pixels`, `fps`) from part metadata, and reports cache reads/writes in `usage.cachedInputTokens` and `usage.cacheWriteTokens`. Cache creation requires a sufficiently long prefix (at least 1024 tokens); account and upstream billing rules apply.
|
|
68
|
+
|
|
69
|
+
### Qwen4-Max-Preview
|
|
70
|
+
|
|
71
|
+
`qwen4-max-preview` remains a separate contract. It requires the exact `QWEN_TOKEN_PLAN_BASE_URL` (or the existing legacy Token Plan endpoint) and a dedicated plan key. It supports hybrid reasoning, text/image/video, tools and native schemas, but retains `low` / `medium` / `xhigh` Chat effort mapping and a combined output maximum of 393216. Final-model summary encryption and explicit-cache options are not inferred for the preview. Upstream schedules preview retirement for November 25, 2026, 24:00 UTC+8. The SDK never silently rewrites the model ID.
|
|
72
|
+
|
|
73
|
+
Sources: [Chat API](https://docs.qwencloud.com/api-reference/chat/openai-chat), [thinking summaries](https://docs.qwencloud.com/developer-guides/text-generation/cot-summary), [explicit cache](https://docs.qwencloud.com/developer-guides/run-and-scale/explicit-cache-qwen4), [preview contract and lifecycle](https://docs.qwencloud.com/developer-guides/getting-started/latest-model).
|
|
74
|
+
|
|
75
|
+
Opt-in live verification (standard credentials, final model):
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
QWEN4_INTEGRATION=1 bun --env-file=.env run test:integration packages/qwen/tests/qwen4.integration.test.ts
|
|
79
|
+
```
|
|
80
|
+
|
|
35
81
|
### Qwen3.8 Omni Flash
|
|
36
82
|
|
|
37
83
|
`qwen3.8-omni-flash` accepts text, images, audio, and video and returns **text only** over HTTP. It uses standard Model Studio credentials, including the default Singapore endpoint or a regional workspace endpoint. Both Chat Completions and Responses support streaming and non-streaming generation. This is a separate contract from streaming-only Omni 3/3.5 and from the Realtime model.
|
package/dist/index.d.ts
CHANGED
|
@@ -53,6 +53,18 @@ export interface QwenLanguageModelOptions {
|
|
|
53
53
|
"x-dashscope-session-cache"?: "enable" | "disable";
|
|
54
54
|
enable_thinking?: boolean;
|
|
55
55
|
thinking_budget?: number;
|
|
56
|
+
/** Qwen4-Max: return a display summary and replayable encrypted reasoning. */
|
|
57
|
+
thinking_display?: "summarized";
|
|
58
|
+
/** Responses reasoning summary; mapped from thinking_display for Qwen4-Max too. */
|
|
59
|
+
reasoning?: {
|
|
60
|
+
effort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
61
|
+
summary?: "auto";
|
|
62
|
+
};
|
|
63
|
+
/** Qwen4-Max explicit cache settings. Content breakpoints use part.providerMetadata. */
|
|
64
|
+
prompt_cache_options?: {
|
|
65
|
+
mode?: "implicit" | "explicit";
|
|
66
|
+
ttl?: "5m" | "1h";
|
|
67
|
+
};
|
|
56
68
|
preserve_thinking?: boolean;
|
|
57
69
|
reasoning_effort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
58
70
|
parallel_tool_calls?: boolean;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC1E,mBAAmB,uBAAuB,CAAC;AAC3C,OAAO,EAAiC,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAClG,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9G,OAAO,EAAwE,KAAK,0BAA0B,EA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