@arnilo/prism-provider-zai 0.0.1 → 0.0.2

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/CHANGELOG.md CHANGED
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.0.2] - 2026-07-05
11
+
10
12
  ### Added
11
13
 
12
14
  - Added `LICENSE` (MIT) and `CHANGELOG.md`.
package/README.md CHANGED
@@ -18,3 +18,8 @@ Security defaults:
18
18
  - No network calls during import, setup, build, or default tests.
19
19
  - No automatic environment, file, keychain, or shell credential lookup.
20
20
  - API keys are resolved per request from caller-supplied values or resolvers.
21
+
22
+ Cache behavior:
23
+ - `kind: "implicit"` — GLM context caching is automatic; no explicit cache payload sent regardless of cache options.
24
+ - `prompt_tokens_details.cached_tokens`/`cache_write_tokens` map to `Usage.cacheReadTokens`/`cacheWriteTokens`.
25
+ - Provider-owned headers (`content-type`, `authorization`) win over caller headers.
package/dist/models.js CHANGED
@@ -6,12 +6,14 @@ export const zaiModels = [
6
6
  model: "glm-4.7",
7
7
  displayName: "GLM-4.7",
8
8
  limits: { contextWindow: 128_000, maxOutputTokens: 32_000 },
9
+ cache: { kind: "implicit" },
9
10
  compat: { thinking: true, reasoning_effort: "medium", tool_stream: true },
10
11
  }),
11
12
  defineZaiModel({
12
13
  model: "glm-4.5",
13
14
  displayName: "GLM-4.5",
14
15
  limits: { contextWindow: 128_000, maxOutputTokens: 32_000 },
16
+ cache: { kind: "implicit" },
15
17
  compat: { thinking: true, reasoning_effort: "medium", tool_stream: true },
16
18
  }),
17
19
  ];
package/dist/provider.js CHANGED
@@ -14,7 +14,7 @@ export function createZaiProvider(options = {}) {
14
14
  try {
15
15
  const response = await (options.fetch ?? fetch)(`${baseUrl}/chat/completions`, {
16
16
  method: "POST",
17
- headers: { "content-type": "application/json", ...request.options?.headers, ...(token ? { authorization: `Bearer ${token}` } : {}) },
17
+ headers: { ...request.options?.headers, "content-type": "application/json", ...(token ? { authorization: `Bearer ${token}` } : {}) },
18
18
  body: JSON.stringify(zaiBody(request)),
19
19
  signal: request.signal,
20
20
  });
@@ -31,6 +31,7 @@ export function createZaiProvider(options = {}) {
31
31
  };
32
32
  }
33
33
  export function zaiBody(request) {
34
+ const { maxTokens, ...parameters } = request.model.parameters ?? {};
34
35
  return clean({
35
36
  model: request.model.model,
36
37
  messages: request.messages.map((message) => toMessage(message, request.model.capabilities ?? {})),
@@ -39,8 +40,8 @@ export function zaiBody(request) {
39
40
  tool_stream: zaiToolStream(request),
40
41
  thinking: zaiThinking(request),
41
42
  reasoning_effort: zaiReasoningEffort(request),
42
- max_tokens: request.model.limits?.maxOutputTokens,
43
- ...request.model.parameters,
43
+ ...parameters,
44
+ max_tokens: maxTokens ?? request.model.limits?.maxOutputTokens,
44
45
  ...request.options?.compat,
45
46
  ...request.options?.extra,
46
47
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arnilo/prism-provider-zai",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Z.AI provider package for Prism.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -25,7 +25,7 @@
25
25
  "pack:dry-run": "npm pack --dry-run"
26
26
  },
27
27
  "peerDependencies": {
28
- "@arnilo/prism": "0.0.1"
28
+ "@arnilo/prism": "0.0.2"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@arnilo/prism": "file:../.."