@vincemakes/kiso-provider-openai 0.42.1 → 0.42.3

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.
Files changed (2) hide show
  1. package/dist/index.js +7 -4
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -127,7 +127,7 @@ export function createOpenAICompatAdapter(client, adapterOpts = {}) {
127
127
  inputTokens: chunk.usage.prompt_tokens ?? null,
128
128
  outputTokens: chunk.usage.completion_tokens ?? null,
129
129
  cacheRead: details?.cached_tokens ?? null,
130
- cacheWrite: null,
130
+ cacheWrite: details?.cache_write_tokens ?? null, // 0.42.2 (#17): a gateway may report the write
131
131
  known: true,
132
132
  ...(typeof reasoning === "number" ? { reasoningTokens: reasoning } : {}),
133
133
  ...(served !== null ? { servedModel: served } : {}),
@@ -225,8 +225,11 @@ export function createOpenAICompatAdapter(client, adapterOpts = {}) {
225
225
  usageSent = true;
226
226
  // round 6: REAL cached-token data is read from the provider's
227
227
  // prompt_tokens_details — an absent value is null, NEVER
228
- // faked as a zero-cache turn. OpenAI does not report a
229
- // cache write; null is the honest answer.
228
+ // faked as a zero-cache turn. 0.42.2 (the products' request
229
+ // #17): the first-party API reports no cache write, but a
230
+ // gateway on this route does (`cache_write_tokens`, beside
231
+ // `cached_tokens`) — read when present, null otherwise. The
232
+ // accounting boundary subtracts it from the fresh count.
230
233
  const u = chunk.usage;
231
234
  const details = u.prompt_tokens_details;
232
235
  // RSN-1: the completion side of the SAME object. We have
@@ -241,7 +244,7 @@ export function createOpenAICompatAdapter(client, adapterOpts = {}) {
241
244
  inputTokens: chunk.usage.prompt_tokens ?? null,
242
245
  outputTokens: chunk.usage.completion_tokens ?? null,
243
246
  cacheRead: details?.cached_tokens ?? null,
244
- cacheWrite: null,
247
+ cacheWrite: details?.cache_write_tokens ?? null,
245
248
  known: true,
246
249
  ...(typeof reasoning === "number" ? { reasoningTokens: reasoning } : {}),
247
250
  ...(served !== null ? { servedModel: served } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vincemakes/kiso-provider-openai",
3
- "version": "0.42.1",
3
+ "version": "0.42.3",
4
4
  "description": "kiso OpenAI-compatible adapter \u2014 OpenAI + the compat family (GLM, Kimi, DeepSeek, OpenRouter) via base_url swap, reasoning dialects digested.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -21,7 +21,7 @@
21
21
  "test": "vitest run"
22
22
  },
23
23
  "dependencies": {
24
- "@vincemakes/kiso-core": "0.42.1",
24
+ "@vincemakes/kiso-core": "0.42.3",
25
25
  "openai": "^7.3.0"
26
26
  },
27
27
  "devDependencies": {