@ai-sdk/quiverai 2.0.47 → 2.0.48

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/dist/index.js CHANGED
@@ -2,6 +2,9 @@
2
2
  import {
3
3
  NoSuchModelError
4
4
  } from "@ai-sdk/provider";
5
+ import {
6
+ createOpenResponses as createOpenResponses2
7
+ } from "@ai-sdk/open-responses";
5
8
  import {
6
9
  loadApiKey,
7
10
  loadOptionalSetting,
@@ -9,33 +12,170 @@ import {
9
12
  withUserAgentSuffix
10
13
  } from "@ai-sdk/provider-utils";
11
14
 
15
+ // src/quiverai-error.ts
16
+ import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
17
+ import { z } from "zod/v4";
18
+ var quiveraiErrorSchema = z.object({
19
+ status: z.number().int(),
20
+ code: z.string().min(1),
21
+ message: z.string().min(1),
22
+ request_id: z.string().min(1)
23
+ });
24
+ var quiveraiFailedResponseHandler = createJsonErrorResponseHandler({
25
+ errorSchema: quiveraiErrorSchema,
26
+ errorToMessage: (error) => error.message,
27
+ isRetryable: (response) => response.status === 429 || response.status >= 500
28
+ });
29
+ var getQuiverAIResponseErrorMetadata = (error) => ({
30
+ statusCode: typeof error.status_code === "number" && Number.isInteger(error.status_code) && error.status_code >= 400 && error.status_code <= 599 ? error.status_code : void 0
31
+ });
32
+
33
+ // src/quiverai-language-model.ts
34
+ import {
35
+ InvalidArgumentError
36
+ } from "@ai-sdk/provider";
37
+ import {
38
+ createOpenResponses
39
+ } from "@ai-sdk/open-responses";
40
+ import {
41
+ serializeModelOptions,
42
+ WORKFLOW_DESERIALIZE,
43
+ WORKFLOW_SERIALIZE
44
+ } from "@ai-sdk/provider-utils";
45
+ var QuiverAILanguageModel = class _QuiverAILanguageModel {
46
+ constructor(model, config) {
47
+ this.model = model;
48
+ this.config = config;
49
+ this.specificationVersion = "v4";
50
+ }
51
+ static [WORKFLOW_SERIALIZE](model) {
52
+ return serializeModelOptions({
53
+ modelId: model.modelId,
54
+ config: model.config
55
+ });
56
+ }
57
+ static [WORKFLOW_DESERIALIZE](options) {
58
+ const config = {
59
+ ...options.config,
60
+ failedResponseHandler: quiveraiFailedResponseHandler,
61
+ getResponseErrorMetadata: getQuiverAIResponseErrorMetadata
62
+ };
63
+ return new _QuiverAILanguageModel(
64
+ createOpenResponses(config).languageModel(options.modelId),
65
+ config
66
+ );
67
+ }
68
+ get modelId() {
69
+ return this.model.modelId;
70
+ }
71
+ get provider() {
72
+ return this.model.provider;
73
+ }
74
+ get supportedUrls() {
75
+ return this.model.supportedUrls;
76
+ }
77
+ async doGenerate(options) {
78
+ const prepared = prepareQuiverAICall(options);
79
+ const result = await this.model.doGenerate(prepared.options);
80
+ return { ...result, warnings: [...prepared.warnings, ...result.warnings] };
81
+ }
82
+ async doStream(options) {
83
+ const prepared = prepareQuiverAICall(options);
84
+ const result = await this.model.doStream(prepared.options);
85
+ if (prepared.warnings.length === 0) return result;
86
+ return {
87
+ ...result,
88
+ stream: result.stream.pipeThrough(
89
+ new TransformStream({
90
+ transform(part, controller) {
91
+ controller.enqueue(
92
+ part.type === "stream-start" ? {
93
+ ...part,
94
+ warnings: [...prepared.warnings, ...part.warnings]
95
+ } : part
96
+ );
97
+ }
98
+ })
99
+ )
100
+ };
101
+ }
102
+ };
103
+ function prepareQuiverAICall(options) {
104
+ var _a, _b;
105
+ const { reasoningEffort, reasoningSummary } = (_b = (_a = options.providerOptions) == null ? void 0 : _a.quiverai) != null ? _b : {};
106
+ if (reasoningEffort != null && (typeof reasoningEffort !== "string" || !["low", "medium", "high", "xhigh"].includes(reasoningEffort))) {
107
+ throw new InvalidArgumentError({
108
+ argument: "providerOptions",
109
+ message: `Unsupported reasoning effort: ${reasoningEffort}`
110
+ });
111
+ }
112
+ if (reasoningSummary != null && reasoningSummary !== "auto") {
113
+ throw new InvalidArgumentError({
114
+ argument: "providerOptions",
115
+ message: `Unsupported reasoning summary: ${reasoningSummary}`
116
+ });
117
+ }
118
+ const warnings = [];
119
+ const omitReasoning = options.reasoning === "none" && reasoningEffort == null;
120
+ if (omitReasoning) {
121
+ warnings.push({ type: "unsupported", feature: "reasoning effort none" });
122
+ }
123
+ return {
124
+ warnings,
125
+ options: {
126
+ ...options,
127
+ reasoning: omitReasoning ? void 0 : options.reasoning,
128
+ prompt: options.prompt.map(
129
+ (message) => message.role !== "assistant" ? message : {
130
+ ...message,
131
+ content: message.content.map((part) => {
132
+ var _a2, _b2, _c;
133
+ if (part.type !== "reasoning") return part;
134
+ const metadata = (_c = (_a2 = part.providerOptions) == null ? void 0 : _a2.quiverai) != null ? _c : (_b2 = part.providerMetadata) == null ? void 0 : _b2.quiverai;
135
+ return {
136
+ ...part,
137
+ text: "",
138
+ providerOptions: {
139
+ ...part.providerOptions,
140
+ quiverai: {
141
+ itemId: metadata == null ? void 0 : metadata.itemId,
142
+ reasoningSummary: metadata == null ? void 0 : metadata.reasoningSummary
143
+ }
144
+ }
145
+ };
146
+ })
147
+ }
148
+ )
149
+ }
150
+ };
151
+ }
152
+
12
153
  // src/quiverai-image-model.ts
13
154
  import {
14
- InvalidArgumentError as InvalidArgumentError2
155
+ InvalidArgumentError as InvalidArgumentError3
15
156
  } from "@ai-sdk/provider";
16
157
  import {
17
158
  combineHeaders,
18
159
  convertBase64ToUint8Array as convertBase64ToUint8Array2,
19
160
  convertUint8ArrayToBase64 as convertUint8ArrayToBase642,
20
- createJsonErrorResponseHandler,
21
161
  createJsonResponseHandler,
22
162
  parseProviderOptions,
23
163
  postJsonToApi,
24
- serializeModelOptions,
25
- WORKFLOW_DESERIALIZE,
26
- WORKFLOW_SERIALIZE
164
+ serializeModelOptions as serializeModelOptions2,
165
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2,
166
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2
27
167
  } from "@ai-sdk/provider-utils";
28
- import { z as z2 } from "zod/v4";
168
+ import { z as z3 } from "zod/v4";
29
169
 
30
170
  // src/quiverai-image-model-options.ts
31
171
  import {
32
172
  lazySchema,
33
173
  zodSchema
34
174
  } from "@ai-sdk/provider-utils";
35
- import { z } from "zod/v4";
175
+ import { z as z2 } from "zod/v4";
36
176
  var quiveraiImageModelOptionsSchema = lazySchema(
37
177
  () => zodSchema(
38
- z.object({
178
+ z2.object({
39
179
  /**
40
180
  * The operation to perform. Defaults to `generate`.
41
181
  *
@@ -47,81 +187,81 @@ var quiveraiImageModelOptionsSchema = lazySchema(
47
187
  * - `edit`: Edit a single SVG from `prompt.images` using `prompt.text`
48
188
  * as the required instruction.
49
189
  */
50
- operation: z.enum(["generate", "vectorize", "animate", "edit"]).optional(),
190
+ operation: z2.enum(["generate", "vectorize", "animate", "edit"]).optional(),
51
191
  /**
52
192
  * Extra style guidance for prompt-based generation.
53
193
  */
54
- instructions: z.string().min(1).optional(),
194
+ instructions: z2.string().min(1).optional(),
55
195
  /**
56
196
  * Reasoning effort applied to generation or vectorization.
57
197
  */
58
- reasoningEffort: z.enum(["low", "medium", "high", "xhigh"]).optional(),
198
+ reasoningEffort: z2.enum(["low", "medium", "high", "xhigh"]).optional(),
59
199
  /**
60
200
  * Optional reference images for SVG editing. Use
61
201
  * `prepareQuiverAIImageReference` to convert binary inputs.
62
202
  */
63
- referenceImages: z.array(
64
- z.union([
65
- z.object({ url: z.string().min(1) }).strict(),
66
- z.object({ base64: z.string().min(1).max(16777216) }).strict()
203
+ referenceImages: z2.array(
204
+ z2.union([
205
+ z2.object({ url: z2.string().min(1) }).strict(),
206
+ z2.object({ base64: z2.string().min(1).max(16777216) }).strict()
67
207
  ])
68
208
  ).max(4).optional(),
69
209
  /**
70
210
  * Maximum number of edit review and redo steps (0-5).
71
211
  */
72
- maxReviewSteps: z.number().int().min(0).max(5).optional(),
212
+ maxReviewSteps: z2.number().int().min(0).max(5).optional(),
73
213
  /**
74
214
  * SVG root attributes requested for generation or vectorization.
75
215
  */
76
- attributes: z.object({
77
- viewBox: z.object({
78
- minX: z.number(),
79
- minY: z.number(),
80
- width: z.number().positive(),
81
- height: z.number().positive()
216
+ attributes: z2.object({
217
+ viewBox: z2.object({
218
+ minX: z2.number(),
219
+ minY: z2.number(),
220
+ width: z2.number().positive(),
221
+ height: z2.number().positive()
82
222
  }).optional()
83
223
  }).optional(),
84
224
  /**
85
225
  * Sampling temperature (0-2).
86
226
  */
87
- temperature: z.number().min(0).max(2).optional(),
227
+ temperature: z2.number().min(0).max(2).optional(),
88
228
  /**
89
229
  * Nucleus sampling top-p (0-1).
90
230
  */
91
- topP: z.number().min(0).max(1).optional(),
231
+ topP: z2.number().min(0).max(1).optional(),
92
232
  /**
93
233
  * Presence penalty (-2 to 2).
94
234
  */
95
- presencePenalty: z.number().min(-2).max(2).nullable().optional(),
235
+ presencePenalty: z2.number().min(-2).max(2).nullable().optional(),
96
236
  /**
97
237
  * Maximum number of output tokens (1 - 65536 for Arrow 2 models).
98
238
  * The legacy upper bound of 131072 is retained for other model IDs.
99
239
  */
100
- maxOutputTokens: z.number().int().min(1).max(131072).optional(),
240
+ maxOutputTokens: z2.number().int().min(1).max(131072).optional(),
101
241
  /**
102
242
  * Provider orchestrator token budget for SVG editing (1-65536).
103
243
  */
104
- orchestratorMaxOutputTokens: z.number().int().min(1).max(65536).optional(),
244
+ orchestratorMaxOutputTokens: z2.number().int().min(1).max(65536).optional(),
105
245
  /**
106
246
  * Provider shallow edit token budget for SVG editing (1-65536).
107
247
  */
108
- shallowMaxOutputTokens: z.number().int().min(1).max(65536).optional(),
248
+ shallowMaxOutputTokens: z2.number().int().min(1).max(65536).optional(),
109
249
  /**
110
250
  * Whether to auto-crop the input image before vectorization.
111
251
  * Only used when `operation` is `vectorize`.
112
252
  */
113
- autoCrop: z.boolean().optional(),
253
+ autoCrop: z2.boolean().optional(),
114
254
  /**
115
255
  * Target canvas size in pixels for vectorization (128 - 4096).
116
256
  * Only used when `operation` is `vectorize`.
117
257
  */
118
- targetSize: z.number().int().min(128).max(4096).optional()
258
+ targetSize: z2.number().int().min(128).max(4096).optional()
119
259
  })
120
260
  )
121
261
  );
122
262
 
123
263
  // src/prepare-quiverai-image-reference.ts
124
- import { InvalidArgumentError } from "@ai-sdk/provider";
264
+ import { InvalidArgumentError as InvalidArgumentError2 } from "@ai-sdk/provider";
125
265
  import {
126
266
  convertBase64ToUint8Array,
127
267
  convertUint8ArrayToBase64,
@@ -147,7 +287,7 @@ function prepareQuiverAIImageReference(input) {
147
287
  if (input.startsWith("data:")) {
148
288
  const match = /^data:([^;,]+);base64,(.+)$/s.exec(input);
149
289
  if (match == null || !supportedReferenceMediaTypes.has(match[1])) {
150
- throw new InvalidArgumentError({
290
+ throw new InvalidArgumentError2({
151
291
  argument: "input",
152
292
  message: "QuiverAI reference image data URLs must use base64 encoding and a supported image media type."
153
293
  });
@@ -167,13 +307,13 @@ function validateQuiverAIImageUrl(url) {
167
307
  try {
168
308
  parsed = new URL(url);
169
309
  } catch (e) {
170
- throw new InvalidArgumentError({
310
+ throw new InvalidArgumentError2({
171
311
  argument: "url",
172
312
  message: "QuiverAI image URLs must be valid HTTP or HTTPS URLs."
173
313
  });
174
314
  }
175
315
  if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
176
- throw new InvalidArgumentError({
316
+ throw new InvalidArgumentError2({
177
317
  argument: "url",
178
318
  message: "QuiverAI image URLs must use HTTP or HTTPS."
179
319
  });
@@ -182,7 +322,7 @@ function validateQuiverAIImageUrl(url) {
182
322
  }
183
323
  function validateQuiverAIReferenceBase64(base64, argument) {
184
324
  if (base64.length === 0 || base64.length > MAX_REFERENCE_BASE64_LENGTH) {
185
- throw new InvalidArgumentError({
325
+ throw new InvalidArgumentError2({
186
326
  argument,
187
327
  message: `QuiverAI reference images must contain 1-${MAX_REFERENCE_BASE64_LENGTH} base64 characters.`
188
328
  });
@@ -191,7 +331,7 @@ function validateQuiverAIReferenceBase64(base64, argument) {
191
331
  try {
192
332
  data = convertBase64ToUint8Array(base64);
193
333
  } catch (cause) {
194
- throw new InvalidArgumentError({
334
+ throw new InvalidArgumentError2({
195
335
  argument,
196
336
  message: "QuiverAI reference image data must be valid base64.",
197
337
  cause
@@ -201,14 +341,14 @@ function validateQuiverAIReferenceBase64(base64, argument) {
201
341
  }
202
342
  function validateQuiverAIReferenceBytes(data, argument) {
203
343
  if (data.length === 0 || data.length > MAX_REFERENCE_BYTES) {
204
- throw new InvalidArgumentError({
344
+ throw new InvalidArgumentError2({
205
345
  argument,
206
346
  message: `QuiverAI reference images must decode to 1-${MAX_REFERENCE_BYTES} bytes.`
207
347
  });
208
348
  }
209
349
  const mediaType = isSvg(data) ? "image/svg+xml" : detectMediaType({ data, topLevelType: "image" });
210
350
  if (mediaType == null || !supportedReferenceMediaTypes.has(mediaType)) {
211
- throw new InvalidArgumentError({
351
+ throw new InvalidArgumentError2({
212
352
  argument,
213
353
  message: "QuiverAI reference images must be PNG, JPEG, WebP, GIF, or SVG data."
214
354
  });
@@ -238,13 +378,13 @@ var QuiverAIImageModel = class _QuiverAIImageModel {
238
378
  get provider() {
239
379
  return this.config.provider;
240
380
  }
241
- static [WORKFLOW_SERIALIZE](model) {
242
- return serializeModelOptions({
381
+ static [WORKFLOW_SERIALIZE2](model) {
382
+ return serializeModelOptions2({
243
383
  modelId: model.modelId,
244
384
  config: model.config
245
385
  });
246
386
  }
247
- static [WORKFLOW_DESERIALIZE](options) {
387
+ static [WORKFLOW_DESERIALIZE2](options) {
248
388
  return new _QuiverAIImageModel(options.modelId, options.config);
249
389
  }
250
390
  async doGenerate({
@@ -355,13 +495,13 @@ function toQuiverAIAnimationSource(image) {
355
495
  try {
356
496
  url = new URL(image.url);
357
497
  } catch (e) {
358
- throw new InvalidArgumentError2({
498
+ throw new InvalidArgumentError3({
359
499
  argument: "files",
360
500
  message: "QuiverAI animate requires a valid HTTP or HTTPS SVG URL."
361
501
  });
362
502
  }
363
503
  if (url.protocol !== "http:" && url.protocol !== "https:") {
364
- throw new InvalidArgumentError2({
504
+ throw new InvalidArgumentError3({
365
505
  argument: "files",
366
506
  message: "QuiverAI animate requires an HTTP or HTTPS SVG URL."
367
507
  });
@@ -376,7 +516,7 @@ function toQuiverAIAnimationSource(image) {
376
516
  try {
377
517
  bytes = convertBase64ToUint8Array2(encodedData);
378
518
  } catch (e) {
379
- throw new InvalidArgumentError2({
519
+ throw new InvalidArgumentError3({
380
520
  argument: "files",
381
521
  message: "QuiverAI animate requires the source SVG string to be valid base64 or an SVG data URL."
382
522
  });
@@ -387,13 +527,13 @@ function toQuiverAIAnimationSource(image) {
387
527
  base64 = convertUint8ArrayToBase642(bytes);
388
528
  }
389
529
  if (!isSvg2(bytes)) {
390
- throw new InvalidArgumentError2({
530
+ throw new InvalidArgumentError3({
391
531
  argument: "files",
392
532
  message: "QuiverAI animate requires the input file to contain SVG data."
393
533
  });
394
534
  }
395
535
  if (base64.length > maxAnimationSourceBase64Length) {
396
- throw new InvalidArgumentError2({
536
+ throw new InvalidArgumentError3({
397
537
  argument: "files",
398
538
  message: `QuiverAI animate accepts at most ${maxAnimationSourceBase64Length} base64 characters for the source SVG.`
399
539
  });
@@ -416,7 +556,7 @@ function buildRequestBody({
416
556
  options
417
557
  }) {
418
558
  if ((modelId === "arrow-2" || modelId === "arrow-2-telos") && options.maxOutputTokens != null && options.maxOutputTokens > 65536) {
419
- throw new InvalidArgumentError2({
559
+ throw new InvalidArgumentError3({
420
560
  argument: "maxOutputTokens",
421
561
  message: `QuiverAI model "${modelId}" supports at most 65536 output tokens.`
422
562
  });
@@ -435,7 +575,7 @@ function buildRequestBody({
435
575
  }
436
576
  if (operation === "generate") {
437
577
  if (prompt == null || prompt.trim().length === 0) {
438
- throw new InvalidArgumentError2({
578
+ throw new InvalidArgumentError3({
439
579
  argument: "prompt",
440
580
  message: "QuiverAI image generation requires a non-empty prompt for generateImage."
441
581
  });
@@ -443,7 +583,7 @@ function buildRequestBody({
443
583
  const references = files == null ? void 0 : files.map(toQuiverAIImageReference);
444
584
  const maxReferences = getGenerateReferenceLimit(modelId);
445
585
  if (references != null && references.length > maxReferences) {
446
- throw new InvalidArgumentError2({
586
+ throw new InvalidArgumentError3({
447
587
  argument: "files",
448
588
  message: `QuiverAI generate supports up to ${maxReferences} reference images for model "${modelId}".`
449
589
  });
@@ -478,19 +618,19 @@ function buildRequestBody({
478
618
  });
479
619
  }
480
620
  if (files == null || files.length === 0) {
481
- throw new InvalidArgumentError2({
621
+ throw new InvalidArgumentError3({
482
622
  argument: "files",
483
623
  message: 'QuiverAI vectorize requires an input image. Pass an image in the generateImage prompt and set providerOptions.quiverai.operation to "vectorize".'
484
624
  });
485
625
  }
486
626
  if (files.length > 1) {
487
- throw new InvalidArgumentError2({
627
+ throw new InvalidArgumentError3({
488
628
  argument: "files",
489
629
  message: "QuiverAI vectorize accepts a single input image."
490
630
  });
491
631
  }
492
632
  if (n !== 1) {
493
- throw new InvalidArgumentError2({
633
+ throw new InvalidArgumentError3({
494
634
  argument: "n",
495
635
  message: "QuiverAI vectorize returns one SVG per request. Set maxImagesPerCall to 1 in generateImage to vectorize multiple times."
496
636
  });
@@ -512,37 +652,37 @@ function buildAnimationRequestBody({
512
652
  options
513
653
  }) {
514
654
  if (modelId !== "arrow-2" && modelId !== "arrow-2-telos") {
515
- throw new InvalidArgumentError2({
655
+ throw new InvalidArgumentError3({
516
656
  argument: "modelId",
517
657
  message: 'QuiverAI animate is supported by the "arrow-2" and "arrow-2-telos" models.'
518
658
  });
519
659
  }
520
660
  if (files == null || files.length === 0) {
521
- throw new InvalidArgumentError2({
661
+ throw new InvalidArgumentError3({
522
662
  argument: "files",
523
663
  message: "QuiverAI animate requires exactly one source SVG in prompt.images."
524
664
  });
525
665
  }
526
666
  if (files.length !== 1) {
527
- throw new InvalidArgumentError2({
667
+ throw new InvalidArgumentError3({
528
668
  argument: "files",
529
669
  message: "QuiverAI animate accepts exactly one source SVG in prompt.images."
530
670
  });
531
671
  }
532
672
  if (n !== 1) {
533
- throw new InvalidArgumentError2({
673
+ throw new InvalidArgumentError3({
534
674
  argument: "n",
535
675
  message: "QuiverAI animate returns one SVG per request. Set maxImagesPerCall to 1 in generateImage to animate multiple times."
536
676
  });
537
677
  }
538
678
  if (mask != null) {
539
- throw new InvalidArgumentError2({
679
+ throw new InvalidArgumentError3({
540
680
  argument: "mask",
541
681
  message: "QuiverAI animate does not support masks."
542
682
  });
543
683
  }
544
684
  if (prompt != null && prompt.trim().length === 0) {
545
- throw new InvalidArgumentError2({
685
+ throw new InvalidArgumentError3({
546
686
  argument: "prompt",
547
687
  message: "QuiverAI animate requires a non-empty prompt when an animation instruction is provided."
548
688
  });
@@ -558,7 +698,7 @@ function buildAnimationRequestBody({
558
698
  return option[1] !== void 0;
559
699
  });
560
700
  if (unsupportedOptions.length > 0) {
561
- throw new InvalidArgumentError2({
701
+ throw new InvalidArgumentError3({
562
702
  argument: `providerOptions.quiverai.${unsupportedOptions[0][0]}`,
563
703
  message: `QuiverAI animate does not support providerOptions.quiverai.${unsupportedOptions[0][0]}.`
564
704
  });
@@ -585,43 +725,43 @@ function buildEditRequestBody({
585
725
  }) {
586
726
  var _a;
587
727
  if (!editModelIds.has(modelId)) {
588
- throw new InvalidArgumentError2({
728
+ throw new InvalidArgumentError3({
589
729
  argument: "modelId",
590
730
  message: 'QuiverAI SVG editing is supported by the "arrow-2" and "arrow-2-telos" models.'
591
731
  });
592
732
  }
593
733
  if (prompt == null || prompt.trim().length === 0) {
594
- throw new InvalidArgumentError2({
734
+ throw new InvalidArgumentError3({
595
735
  argument: "prompt",
596
736
  message: "QuiverAI SVG editing requires a non-empty instruction in generateImage prompt.text."
597
737
  });
598
738
  }
599
739
  if (prompt.length > 4e3) {
600
- throw new InvalidArgumentError2({
740
+ throw new InvalidArgumentError3({
601
741
  argument: "prompt",
602
742
  message: "QuiverAI SVG editing instructions must contain at most 4000 characters."
603
743
  });
604
744
  }
605
745
  if (files == null || files.length === 0) {
606
- throw new InvalidArgumentError2({
746
+ throw new InvalidArgumentError3({
607
747
  argument: "files",
608
748
  message: "QuiverAI SVG editing requires one source SVG in generateImage prompt.images."
609
749
  });
610
750
  }
611
751
  if (files.length !== 1) {
612
- throw new InvalidArgumentError2({
752
+ throw new InvalidArgumentError3({
613
753
  argument: "files",
614
754
  message: "QuiverAI SVG editing accepts exactly one source SVG."
615
755
  });
616
756
  }
617
757
  if (n !== 1) {
618
- throw new InvalidArgumentError2({
758
+ throw new InvalidArgumentError3({
619
759
  argument: "n",
620
760
  message: "QuiverAI SVG editing returns exactly one SVG per request. Set maxImagesPerCall to 1 in generateImage to edit multiple times."
621
761
  });
622
762
  }
623
763
  if (mask != null) {
624
- throw new InvalidArgumentError2({
764
+ throw new InvalidArgumentError3({
625
765
  argument: "mask",
626
766
  message: "QuiverAI SVG editing does not support masks."
627
767
  });
@@ -635,7 +775,7 @@ function buildEditRequestBody({
635
775
  ["targetSize", options.targetSize]
636
776
  ].flatMap(([name, value]) => value == null ? [] : [name]);
637
777
  if (unsupportedOptions.length > 0) {
638
- throw new InvalidArgumentError2({
778
+ throw new InvalidArgumentError3({
639
779
  argument: "providerOptions",
640
780
  message: `QuiverAI SVG editing does not support these provider options: ${unsupportedOptions.join(
641
781
  ", "
@@ -680,7 +820,7 @@ function rejectEditOnlyOptions(operation, options) {
680
820
  ["shallowMaxOutputTokens", options.shallowMaxOutputTokens]
681
821
  ].flatMap(([name, value]) => value == null ? [] : [name]);
682
822
  if (editOnlyOptions.length > 0) {
683
- throw new InvalidArgumentError2({
823
+ throw new InvalidArgumentError3({
684
824
  argument: "providerOptions",
685
825
  message: `QuiverAI ${operation} does not support these edit-only provider options: ${editOnlyOptions.join(
686
826
  ", "
@@ -700,14 +840,14 @@ function toQuiverAIEditSource(file) {
700
840
  try {
701
841
  data = typeof file.data === "string" ? convertBase64ToUint8Array2(file.data) : file.data;
702
842
  } catch (cause) {
703
- throw new InvalidArgumentError2({
843
+ throw new InvalidArgumentError3({
704
844
  argument: "files",
705
845
  message: "QuiverAI SVG source data must be valid base64 or binary data.",
706
846
  cause
707
847
  });
708
848
  }
709
849
  if (data.length === 0 || data.length > MAX_EDIT_SVG_BYTES) {
710
- throw new InvalidArgumentError2({
850
+ throw new InvalidArgumentError3({
711
851
  argument: "files",
712
852
  message: `QuiverAI SVG source data must contain 1-${MAX_EDIT_SVG_BYTES} bytes.`
713
853
  });
@@ -716,14 +856,14 @@ function toQuiverAIEditSource(file) {
716
856
  try {
717
857
  svg = new TextDecoder("utf-8", { fatal: true }).decode(data);
718
858
  } catch (cause) {
719
- throw new InvalidArgumentError2({
859
+ throw new InvalidArgumentError3({
720
860
  argument: "files",
721
861
  message: "QuiverAI SVG source data must be valid UTF-8.",
722
862
  cause
723
863
  });
724
864
  }
725
865
  if (svg.length > MAX_EDIT_SVG_BYTES || !isSvgMarkup(svg)) {
726
- throw new InvalidArgumentError2({
866
+ throw new InvalidArgumentError3({
727
867
  argument: "files",
728
868
  message: "QuiverAI SVG source data must contain a complete SVG document."
729
869
  });
@@ -988,38 +1128,27 @@ function collectWarnings({
988
1128
  }
989
1129
  return warnings;
990
1130
  }
991
- var svgUsageSchema = z2.object({
992
- total_tokens: z2.number().int().nonnegative(),
993
- input_tokens: z2.number().int().nonnegative(),
994
- output_tokens: z2.number().int().nonnegative()
1131
+ var svgUsageSchema = z3.object({
1132
+ total_tokens: z3.number().int().nonnegative(),
1133
+ input_tokens: z3.number().int().nonnegative(),
1134
+ output_tokens: z3.number().int().nonnegative()
995
1135
  });
996
- var svgDocumentSchema = z2.object({
997
- svg: z2.string().min(1),
998
- mime_type: z2.literal("image/svg+xml"),
999
- loop_period_ms: z2.number().int().nonnegative().nullish(),
1000
- opening_animation_ms: z2.number().int().nonnegative().nullish()
1136
+ var svgDocumentSchema = z3.object({
1137
+ svg: z3.string().min(1),
1138
+ mime_type: z3.literal("image/svg+xml"),
1139
+ loop_period_ms: z3.number().int().nonnegative().nullish(),
1140
+ opening_animation_ms: z3.number().int().nonnegative().nullish()
1001
1141
  });
1002
- var svgGenerationResponseSchema = z2.object({
1003
- id: z2.string().min(1),
1004
- created: z2.number().int().nonnegative(),
1005
- data: z2.array(svgDocumentSchema).min(1),
1142
+ var svgGenerationResponseSchema = z3.object({
1143
+ id: z3.string().min(1),
1144
+ created: z3.number().int().nonnegative(),
1145
+ data: z3.array(svgDocumentSchema).min(1),
1006
1146
  usage: svgUsageSchema.nullish(),
1007
- credits: z2.number().int().nonnegative().nullish()
1008
- });
1009
- var quiveraiErrorSchema = z2.object({
1010
- status: z2.number().int(),
1011
- code: z2.string().min(1),
1012
- message: z2.string().min(1),
1013
- request_id: z2.string().min(1)
1014
- });
1015
- var quiveraiFailedResponseHandler = createJsonErrorResponseHandler({
1016
- errorSchema: quiveraiErrorSchema,
1017
- errorToMessage: (error) => error.message,
1018
- isRetryable: (response) => response.status === 429 || response.status >= 500
1147
+ credits: z3.number().int().nonnegative().nullish()
1019
1148
  });
1020
1149
 
1021
1150
  // src/version.ts
1022
- var VERSION = true ? "2.0.47" : "0.0.0-test";
1151
+ var VERSION = true ? "2.0.48" : "0.0.0-test";
1023
1152
 
1024
1153
  // src/quiverai-provider.ts
1025
1154
  var defaultBaseURL = "https://api.quiver.ai/v1";
@@ -1031,21 +1160,36 @@ function createQuiverAI(options = {}) {
1031
1160
  environmentVariableName: "QUIVERAI_BASE_URL"
1032
1161
  })
1033
1162
  )) != null ? _a : defaultBaseURL;
1034
- const getHeaders = () => withUserAgentSuffix(
1035
- {
1036
- Authorization: `Bearer ${loadApiKey({
1037
- apiKey: options.apiKey,
1038
- environmentVariableName: "QUIVERAI_API_KEY",
1039
- description: "QuiverAI"
1040
- })}`,
1041
- ...options.headers
1042
- },
1043
- `ai-sdk/quiverai/${VERSION}`
1163
+ const getHeaders = () => ({
1164
+ Authorization: `Bearer ${loadApiKey({
1165
+ apiKey: options.apiKey,
1166
+ environmentVariableName: "QUIVERAI_API_KEY",
1167
+ description: "QuiverAI"
1168
+ })}`,
1169
+ ...options.headers
1170
+ });
1171
+ const getImageHeaders = () => withUserAgentSuffix(getHeaders(), `ai-sdk/quiverai/${VERSION}`);
1172
+ const responsesConfig = {
1173
+ name: "quiverai",
1174
+ url: `${baseURL}/responses`,
1175
+ headers: getHeaders,
1176
+ fetch: options.fetch,
1177
+ failedResponseHandler: quiveraiFailedResponseHandler,
1178
+ getResponseErrorMetadata: getQuiverAIResponseErrorMetadata,
1179
+ strictResponseInput: true,
1180
+ customToolId: "quiverai.custom",
1181
+ structuredOutputs: false,
1182
+ userAgentSuffix: `ai-sdk/quiverai/${VERSION}`
1183
+ };
1184
+ const responsesProvider = createOpenResponses2(responsesConfig);
1185
+ const createLanguageModel = (modelId) => new QuiverAILanguageModel(
1186
+ responsesProvider.languageModel(modelId),
1187
+ responsesConfig
1044
1188
  );
1045
1189
  const createImageModel = (modelId) => new QuiverAIImageModel(modelId, {
1046
1190
  provider: "quiverai.image",
1047
1191
  baseURL,
1048
- headers: getHeaders,
1192
+ headers: getImageHeaders,
1049
1193
  fetch: options.fetch
1050
1194
  });
1051
1195
  const embeddingModel = (modelId) => {
@@ -1054,19 +1198,17 @@ function createQuiverAI(options = {}) {
1054
1198
  modelType: "embeddingModel"
1055
1199
  });
1056
1200
  };
1057
- return {
1058
- specificationVersion: "v4",
1059
- image: createImageModel,
1060
- imageModel: createImageModel,
1061
- languageModel: (modelId) => {
1062
- throw new NoSuchModelError({
1063
- modelId,
1064
- modelType: "languageModel"
1065
- });
1066
- },
1067
- embeddingModel,
1068
- textEmbeddingModel: embeddingModel
1201
+ const provider = function(modelId) {
1202
+ return createLanguageModel(modelId);
1069
1203
  };
1204
+ provider.specificationVersion = "v4";
1205
+ provider.languageModel = createLanguageModel;
1206
+ provider.image = createImageModel;
1207
+ provider.imageModel = createImageModel;
1208
+ provider.embeddingModel = embeddingModel;
1209
+ provider.textEmbeddingModel = embeddingModel;
1210
+ provider.tools = responsesProvider.tools;
1211
+ return provider;
1070
1212
  }
1071
1213
  var quiverai = createQuiverAI();
1072
1214
  export {