@shop-os/modelkit 0.2.26 → 0.2.27

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
@@ -9,6 +9,11 @@ header in the release PR.
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [0.2.27] - Unreleased
13
+
14
+ ### Fixed
15
+ - A `sloosh` call never goes through the Cloudflare AI Gateway. With `routing.fal: "cloudflare-passthrough"` or `routing.text: "cloudflare"` the gateway's BYOK secrets are the pro provider keys, so a sloosh call through it spent the pro account and, because the tier had no gateway token, failed first with `auth` ("Missing Sloosh API key for cloudflare"). The kit now resolves the routing per tier: sloosh calls the provider directly with `keys.sloosh` (`fal`, or the vendor key); pro and enterprise keep the gateway (ENG-2990).
16
+
12
17
  ## [0.2.26] - Unreleased
13
18
 
14
19
  ### Added
package/dist/index.cjs CHANGED
@@ -8338,11 +8338,17 @@ function textUsageProvider(model, transport) {
8338
8338
  }
8339
8339
 
8340
8340
  // src/client.ts
8341
- function requiredKeys(model, config, transport) {
8342
- if (model.adapter === "fal" && config.routing?.fal === "cloudflare-passthrough")
8343
- return ["cloudflare"];
8341
+ function routingFor(config, tier) {
8342
+ const routing = config.routing ?? {};
8343
+ if (tier !== "sloosh") return routing;
8344
+ const direct = { ...routing };
8345
+ if (direct.text === "cloudflare") direct.text = "direct";
8346
+ if (direct.fal === "cloudflare-passthrough") direct.fal = "direct";
8347
+ return direct;
8348
+ }
8349
+ function requiredKeys(model, routing, transport) {
8350
+ if (model.adapter === "fal" && routing.fal === "cloudflare-passthrough") return ["cloudflare"];
8344
8351
  if (model.adapter === "ai-sdk-text") {
8345
- const routing = config.routing ?? {};
8346
8352
  const names = [textKeyName(model, transport)];
8347
8353
  if (textUsesCloudflareGateway(model, routing, transport)) names.push("cloudflare");
8348
8354
  return names;
@@ -8446,7 +8452,8 @@ function createModelKit(config, adapters) {
8446
8452
  model: model.id
8447
8453
  });
8448
8454
  const transport = resolveAnthropicTransport(model, config, call.tier, warnOnce);
8449
- const names = requiredKeys(model, config, transport);
8455
+ const routing = routingFor(config, call.tier);
8456
+ const names = requiredKeys(model, routing, transport);
8450
8457
  if (call.tier === "enterprise") {
8451
8458
  const missing = missingEnterpriseKeys(config, names);
8452
8459
  if (missing.length > 0)
@@ -8459,7 +8466,7 @@ function createModelKit(config, adapters) {
8459
8466
  const ctx = {
8460
8467
  model,
8461
8468
  keys,
8462
- routing: config.routing ?? {},
8469
+ routing,
8463
8470
  fetch: fetchImpl,
8464
8471
  logger,
8465
8472
  call,