@shop-os/modelkit 0.21.1 → 0.23.0

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,30 @@ header in the release PR.
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [0.23.0] - Unreleased
13
+
14
+ ### Added
15
+ - `seedance-2.5-flash` (BytePlus `dreamina-seedance-2-5-flash-261115`, ENG-3990): Seedance 2.5's
16
+ faster, cheaper sibling. 480p and 720p, 4-30 s, up to 10 reference images, 5 videos and 5 audios,
17
+ edit and extend like 2.5. Limits probed on the live API on 2026-11-16.
18
+
19
+ ### Changed
20
+ - The ark adapter sends `omni_reference_task_type` for every row whose `supports` lists `taskType`,
21
+ not only for the id `seedance-2.5`. Rows without it (2.0, 2.0 Fast) are unchanged.
22
+
23
+ ## [0.22.0] - Unreleased
24
+
25
+ ### Added
26
+ - `ModelKitError` carries optional `finishReason` and `usage` (ENG-3975). google-image sets both
27
+ when Gemini answers with no image: `finishReason` is the SDK's (`"length"` when nano-banana 2.1
28
+ ran out of output before the image), and `usage` is a TEXT `tokens` event with the input and
29
+ output tokens Google still bills. The code stays `provider_rejected` (`content_blocked` when
30
+ filtered) and `retryable: false`, so consumers that branch on the code are unchanged.
31
+ - The client stamps that `usage` with the catalog id, the key that paid (`keySource`) and the call's
32
+ `latencyMs`, keeping its `tokens` unit. It is never sent to `onUsage`: a consumer records it
33
+ as a failed call. `body.rawFinishReason` keeps Gemini's own reason (`NO_IMAGE`, ...), which the
34
+ SDK folds into `"other"`.
35
+
12
36
  ## [0.21.1] - Unreleased
13
37
 
14
38
  ### Fixed
package/README.md CHANGED
@@ -342,7 +342,7 @@ const defaultKit = createDefaultModelKit({ keys: { pro: keysFromEnv(process.env)
342
342
  | Keys | Enterprise keys win only when every key the adapter (and its route, e.g. the cloudflare token for a vendor that really goes through the gateway) needs is set on the enterprise tier; a fallback to pro keys is logged once per call. |
343
343
  | Routing | Cloudflare AI Gateway for text only. Never for Gemini images or Omni. fal passthrough for geo-blocked regions; the fal direct route submits to the queue and polls, so `job.result({ timeoutMs, signal })` is live. |
344
344
  | Retry | One classifier, one policy. Never on content blocks, aborts, or 4xx except 429; SDKs with their own retry (Replicate) run under a single kit attempt; a 429 on a status poll keeps polling unless `CallContext.maxRetries` is `0`. See durable media execution above. |
345
- | Errors | `ModelKitError` with `code`, `provider`, `status`, `body`. Gemini `blockReason` and fal `body.detail` are lifted into `body`. A throw with no HTTP status (fetch failed, reset, DNS) is a retryable `network` error on every adapter. An out-of-credit provider account is `provider_billing` and is never retried: HTTP 402, a 4xx whose structured error code is a billing code (`insufficient_quota`, ...), or a 403/429 whose text names the exhausted account ("Exhausted balance", "Insufficient credit"). BytePlus Ark codes win over the status (body `{"error":{"code","message","type"}}`, and a failed task's `error.code`): 403 `AccountOverdueError` / `OperationDenied.ServiceOverdue` and 429 `QuotaExceeded` are `provider_billing`; 404 `ModelNotOpen` / `InvalidEndpointOrModel.NotFound` are `provider_rejected` with the code in the message; a plain 403 stays `auth` and another 429 `rate_limited`. Text calls go through `ai` and surface the SDK's own error instead. |
345
+ | Errors | `ModelKitError` with `code`, `provider`, `status`, `body`, and on google-image no-image answers `finishReason` plus `usage` (the tokens Google billed, a TEXT `tokens` event). Gemini `blockReason` and fal `body.detail` are lifted into `body`. A throw with no HTTP status (fetch failed, reset, DNS) is a retryable `network` error on every adapter. An out-of-credit provider account is `provider_billing` and is never retried: HTTP 402, a 4xx whose structured error code is a billing code (`insufficient_quota`, ...), or a 403/429 whose text names the exhausted account ("Exhausted balance", "Insufficient credit"). BytePlus Ark codes win over the status (body `{"error":{"code","message","type"}}`, and a failed task's `error.code`): 403 `AccountOverdueError` / `OperationDenied.ServiceOverdue` and 429 `QuotaExceeded` are `provider_billing`; 404 `ModelNotOpen` / `InvalidEndpointOrModel.NotFound` are `provider_rejected` with the code in the message; a plain 403 stays `auth` and another 429 `rate_limited`. Text calls go through `ai` and surface the SDK's own error instead. |
346
346
  | Usage | One event per call with the canonical model id and the row's `usage.unit` (adapters supply the quantity in that unit). Gemini image events carry the token counts too (`inputTokens`/`outputTokens`); Google's raw `usageMetadata` rides on `raw.providerMetadata.google`. Video usage is emitted on completion and carries the resolution the provider renders (the default it falls back to when the request has none), because pricing is keyed by it; Seedance keeps `usage`, `duration`, `framespersecond` and `resolution` from the poll on `raw`. Audio: Lyria 3 returns no duration, so it emits `unit: "images", quantity: 1` (token counts ride along as `inputTokens`/`outputTokens`); Replicate audio (Lyria 2, MMAudio) emits `unit: "compute_seconds"` with the prediction time. |
347
347
  | Media parts | `prepareMediaPart` turns a `MediaRef` into an AI SDK file part. Google inlines bytes up to 10 MiB (base64 makes them ~4/3 larger inside Gemini's 20 MB request cap) and uploads larger payloads through the Files API; call the returned `cleanup` after the request. Other providers get the reference inline. |
348
348
 
package/dist/catalog.cjs CHANGED
@@ -90,13 +90,16 @@ __export(catalog_entry_exports, {
90
90
  module.exports = __toCommonJS(catalog_entry_exports);
91
91
 
92
92
  // src/errors.ts
93
- var ModelKitError = class extends Error {
93
+ var ModelKitError = class _ModelKitError extends Error {
94
94
  code;
95
95
  provider;
96
96
  model;
97
97
  status;
98
98
  body;
99
99
  retryable;
100
+ finishReason;
101
+ /** Set when the provider billed a call that still failed; never sent to `onUsage`. */
102
+ usage;
100
103
  constructor(init) {
101
104
  super(init.message, { cause: init.cause });
102
105
  this.name = "ModelKitError";
@@ -106,6 +109,25 @@ var ModelKitError = class extends Error {
106
109
  this.status = init.status;
107
110
  this.body = init.body;
108
111
  this.retryable = init.retryable ?? defaultRetryable(init.code);
112
+ this.finishReason = init.finishReason;
113
+ this.usage = init.usage;
114
+ }
115
+ withUsage(usage) {
116
+ const init = {
117
+ code: this.code,
118
+ message: this.message,
119
+ cause: this.cause,
120
+ retryable: this.retryable,
121
+ usage
122
+ };
123
+ if (this.provider !== void 0) init.provider = this.provider;
124
+ if (this.model !== void 0) init.model = this.model;
125
+ if (this.status !== void 0) init.status = this.status;
126
+ if (this.body !== void 0) init.body = this.body;
127
+ if (this.finishReason !== void 0) init.finishReason = this.finishReason;
128
+ const copy = new _ModelKitError(init);
129
+ if (this.stack !== void 0) copy.stack = this.stack;
130
+ return copy;
109
131
  }
110
132
  };
111
133
  function defaultRetryable(code) {
@@ -6411,6 +6433,53 @@ var VIDEO_MODELS = [
6411
6433
  },
6412
6434
  capabilities: { acceptsSourceVideo: true, videoEdit: true, ...FRAMES_EXCLUDE_REFERENCES }
6413
6435
  },
6436
+ {
6437
+ // Limits probed on the live API 2026-11-16 (1080p is refused). Extend probe: a 4 s
6438
+ // extend returned 4 s of new footage only and billed input + output tokens, as on 2.5.
6439
+ id: "seedance-2.5-flash",
6440
+ aliases: ["seedance-2-5-flash", "dreamina-seedance-2-5-flash-261115"],
6441
+ label: "Seedance 2.5 Flash",
6442
+ type: "video",
6443
+ adapter: "ark",
6444
+ providerModelId: "dreamina-seedance-2-5-flash-261115",
6445
+ lifecycle: "active",
6446
+ exposure: ["cowork", "space_builder"],
6447
+ constraints: {
6448
+ aspectRatios: [...SEEDANCE_RATIOS],
6449
+ resolutions: ["480p", "720p"],
6450
+ durations: { min: 4, max: 30 },
6451
+ references: {
6452
+ images: 10,
6453
+ videos: 5,
6454
+ audios: 5,
6455
+ videoSeconds: { min: 2, max: 30, total: 30, editMin: 4 },
6456
+ ...SEEDANCE_REFERENCE_MEDIA,
6457
+ audioSeconds: { min: 2, max: 30, total: 30 },
6458
+ audioFormats: ["wav", "mp3"],
6459
+ audioMaxBytes: 15 * 1024 * 1024
6460
+ },
6461
+ sourceVideoSeconds: { min: 2, max: 30, editMin: 4, inReferenceTotal: true },
6462
+ ratioIgnoredWith: ["firstFrame", "sourceVideo"],
6463
+ supports: ["generateAudio", "lastFrame", "watermark", "taskType", "videoExtension"],
6464
+ extension: { segmentSeconds: 30, maxTotalSeconds: 60, returns: "new" },
6465
+ prompt: SEEDANCE_PROMPT,
6466
+ audio: "optional"
6467
+ },
6468
+ defaults: {
6469
+ durationSeconds: 5,
6470
+ resolution: "720p",
6471
+ aspectRatio: "16:9",
6472
+ generateAudio: true
6473
+ },
6474
+ usage: { ...VIDEO_USAGE3 },
6475
+ pricingKind: "video_per_second",
6476
+ display: {
6477
+ provider: "bytedance",
6478
+ logo: BYTEDANCE_LOGO2,
6479
+ description: "Faster, lower-cost ByteDance Seedance 2.5 for omni-reference generation and editing; up to 20 reference assets and 4-30 second clips at up to 720p."
6480
+ },
6481
+ capabilities: { acceptsSourceVideo: true, videoEdit: true, ...FRAMES_EXCLUDE_REFERENCES }
6482
+ },
6414
6483
  {
6415
6484
  id: "grok-imagine",
6416
6485
  aliases: ["grok-imagine-video", "grokImagine"],