@d-ai/magpie 0.1.4 → 0.1.5
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 +1 -1
- package/index.mjs +11 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -120,5 +120,5 @@ send only `Authorization: Bearer <token>` and never `x-api-key`.
|
|
|
120
120
|
model variants, and the gateway passes `reasoning_effort` through.
|
|
121
121
|
- API-key requests go out with `Authorization: Bearer <key>` plus `x-api-key`;
|
|
122
122
|
OAuth requests send only the bearer token. Both carry
|
|
123
|
-
`x-dai-client: magpie/0.1.
|
|
123
|
+
`x-dai-client: magpie/0.1.5`. Gateway requests also carry the stable Magpie
|
|
124
124
|
session as `x-dai-session`.
|
package/index.mjs
CHANGED
|
@@ -40,7 +40,7 @@ import { createHash, randomBytes } from "node:crypto";
|
|
|
40
40
|
import { createServer } from "node:http";
|
|
41
41
|
|
|
42
42
|
const PROVIDER = "dai";
|
|
43
|
-
const CLIENT = "magpie/0.1.
|
|
43
|
+
const CLIENT = "magpie/0.1.5";
|
|
44
44
|
const DEFAULT_BASE = "https://dai.itbug.shop";
|
|
45
45
|
const OPENAI_NPM = "@ai-sdk/openai-compatible";
|
|
46
46
|
const ANTHROPIC_NPM = "@ai-sdk/anthropic";
|
|
@@ -228,9 +228,18 @@ function buildModel(id, base, rate = {}) {
|
|
|
228
228
|
output: numberOr(rate.output_usd_per_1m_tokens, 0),
|
|
229
229
|
};
|
|
230
230
|
const cacheRead = cacheRate(id, rate);
|
|
231
|
-
if (cacheRead !== undefined) cost.cache_read = cacheRead;
|
|
232
231
|
const cacheWrite = positiveNumber(rules.cache_write_usd_per_1m_tokens);
|
|
232
|
+
if (cacheRead !== undefined) cost.cache_read = cacheRead;
|
|
233
233
|
if (cacheWrite !== undefined) cost.cache_write = cacheWrite;
|
|
234
|
+
// OpenCode reads the flat `cache_read` / `cache_write` above; magpie's
|
|
235
|
+
// plugin reader looks under `cache.read` / `cache.write`, so it saw every
|
|
236
|
+
// subscription model as having free cache (a real D.AI model showed
|
|
237
|
+
// 0.002 / 0.02 here and 0 / 0 in the price panel). Send both shapes.
|
|
238
|
+
if (cacheRead !== undefined || cacheWrite !== undefined) {
|
|
239
|
+
cost.cache = {};
|
|
240
|
+
if (cacheRead !== undefined) cost.cache.read = cacheRead;
|
|
241
|
+
if (cacheWrite !== undefined) cost.cache.write = cacheWrite;
|
|
242
|
+
}
|
|
234
243
|
return {
|
|
235
244
|
id,
|
|
236
245
|
name: id,
|
package/package.json
CHANGED