@ai-sdk/groq 2.0.0-canary.9 → 2.0.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/dist/index.js CHANGED
@@ -32,7 +32,7 @@ var import_provider_utils4 = require("@ai-sdk/provider-utils");
32
32
  // src/groq-chat-language-model.ts
33
33
  var import_provider3 = require("@ai-sdk/provider");
34
34
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
35
- var import_zod3 = require("zod");
35
+ var import_v43 = require("zod/v4");
36
36
 
37
37
  // src/convert-to-groq-chat-messages.ts
38
38
  var import_provider = require("@ai-sdk/provider");
@@ -90,7 +90,7 @@ function convertToGroqChatMessages(prompt) {
90
90
  type: "function",
91
91
  function: {
92
92
  name: part.toolName,
93
- arguments: JSON.stringify(part.args)
93
+ arguments: JSON.stringify(part.input)
94
94
  }
95
95
  });
96
96
  break;
@@ -106,10 +106,23 @@ function convertToGroqChatMessages(prompt) {
106
106
  }
107
107
  case "tool": {
108
108
  for (const toolResponse of content) {
109
+ const output = toolResponse.output;
110
+ let contentValue;
111
+ switch (output.type) {
112
+ case "text":
113
+ case "error-text":
114
+ contentValue = output.value;
115
+ break;
116
+ case "content":
117
+ case "json":
118
+ case "error-json":
119
+ contentValue = JSON.stringify(output.value);
120
+ break;
121
+ }
109
122
  messages.push({
110
123
  role: "tool",
111
124
  tool_call_id: toolResponse.toolCallId,
112
- content: JSON.stringify(toolResponse.result)
125
+ content: contentValue
113
126
  });
114
127
  }
115
128
  break;
@@ -137,27 +150,33 @@ function getResponseMetadata({
137
150
  }
138
151
 
139
152
  // src/groq-chat-options.ts
140
- var import_zod = require("zod");
141
- var groqProviderOptions = import_zod.z.object({
142
- reasoningFormat: import_zod.z.enum(["parsed", "raw", "hidden"]).nullish(),
153
+ var import_v4 = require("zod/v4");
154
+ var groqProviderOptions = import_v4.z.object({
155
+ reasoningFormat: import_v4.z.enum(["parsed", "raw", "hidden"]).optional(),
143
156
  /**
144
157
  * Whether to enable parallel function calling during tool use. Default to true.
145
158
  */
146
- parallelToolCalls: import_zod.z.boolean().nullish(),
159
+ parallelToolCalls: import_v4.z.boolean().optional(),
147
160
  /**
148
161
  * A unique identifier representing your end-user, which can help OpenAI to
149
162
  * monitor and detect abuse. Learn more.
150
163
  */
151
- user: import_zod.z.string().nullish()
164
+ user: import_v4.z.string().optional(),
165
+ /**
166
+ * Whether to use structured outputs.
167
+ *
168
+ * @default true
169
+ */
170
+ structuredOutputs: import_v4.z.boolean().optional()
152
171
  });
153
172
 
154
173
  // src/groq-error.ts
155
- var import_zod2 = require("zod");
174
+ var import_v42 = require("zod/v4");
156
175
  var import_provider_utils = require("@ai-sdk/provider-utils");
157
- var groqErrorDataSchema = import_zod2.z.object({
158
- error: import_zod2.z.object({
159
- message: import_zod2.z.string(),
160
- type: import_zod2.z.string()
176
+ var groqErrorDataSchema = import_v42.z.object({
177
+ error: import_v42.z.object({
178
+ message: import_v42.z.string(),
179
+ type: import_v42.z.string()
161
180
  })
162
181
  });
163
182
  var groqFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
@@ -186,7 +205,7 @@ function prepareTools({
186
205
  function: {
187
206
  name: tool.name,
188
207
  description: tool.description,
189
- parameters: tool.parameters
208
+ parameters: tool.inputSchema
190
209
  }
191
210
  });
192
211
  }
@@ -239,21 +258,18 @@ function mapGroqFinishReason(finishReason) {
239
258
 
240
259
  // src/groq-chat-language-model.ts
241
260
  var GroqChatLanguageModel = class {
242
- constructor(modelId, settings, config) {
261
+ constructor(modelId, config) {
243
262
  this.specificationVersion = "v2";
244
- this.supportsStructuredOutputs = false;
245
- this.defaultObjectGenerationMode = "json";
263
+ this.supportedUrls = {
264
+ "image/*": [/^https?:\/\/.*$/]
265
+ };
246
266
  this.modelId = modelId;
247
- this.settings = settings;
248
267
  this.config = config;
249
268
  }
250
269
  get provider() {
251
270
  return this.config.provider;
252
271
  }
253
- get supportsImageUrls() {
254
- return !this.settings.downloadImages;
255
- }
256
- getArgs({
272
+ async getArgs({
257
273
  prompt,
258
274
  maxOutputTokens,
259
275
  temperature,
@@ -269,25 +285,27 @@ var GroqChatLanguageModel = class {
269
285
  toolChoice,
270
286
  providerOptions
271
287
  }) {
288
+ var _a, _b;
272
289
  const warnings = [];
290
+ const groqOptions = await (0, import_provider_utils2.parseProviderOptions)({
291
+ provider: "groq",
292
+ providerOptions,
293
+ schema: groqProviderOptions
294
+ });
295
+ const structuredOutputs = (_a = groqOptions == null ? void 0 : groqOptions.structuredOutputs) != null ? _a : true;
273
296
  if (topK != null) {
274
297
  warnings.push({
275
298
  type: "unsupported-setting",
276
299
  setting: "topK"
277
300
  });
278
301
  }
279
- if (responseFormat != null && responseFormat.type === "json" && responseFormat.schema != null) {
302
+ if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !structuredOutputs) {
280
303
  warnings.push({
281
304
  type: "unsupported-setting",
282
305
  setting: "responseFormat",
283
- details: "JSON response format schema is not supported"
306
+ details: "JSON response format schema is only supported with structuredOutputs"
284
307
  });
285
308
  }
286
- const groqOptions = (0, import_provider_utils2.parseProviderOptions)({
287
- provider: "groq",
288
- providerOptions,
289
- schema: groqProviderOptions
290
- });
291
309
  const {
292
310
  tools: groqTools,
293
311
  toolChoice: groqToolChoice,
@@ -309,10 +327,14 @@ var GroqChatLanguageModel = class {
309
327
  stop: stopSequences,
310
328
  seed,
311
329
  // response format:
312
- response_format: (
313
- // json object response format is not supported for streaming:
314
- stream === false && (responseFormat == null ? void 0 : responseFormat.type) === "json" ? { type: "json_object" } : void 0
315
- ),
330
+ response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? structuredOutputs && responseFormat.schema != null ? {
331
+ type: "json_schema",
332
+ json_schema: {
333
+ schema: responseFormat.schema,
334
+ name: (_b = responseFormat.name) != null ? _b : "response",
335
+ description: responseFormat.description
336
+ }
337
+ } : { type: "json_object" } : void 0,
316
338
  // provider options:
317
339
  reasoning_format: groqOptions == null ? void 0 : groqOptions.reasoningFormat,
318
340
  // messages:
@@ -325,8 +347,11 @@ var GroqChatLanguageModel = class {
325
347
  };
326
348
  }
327
349
  async doGenerate(options) {
328
- var _a, _b, _c, _d, _e;
329
- const { args, warnings } = this.getArgs({ ...options, stream: false });
350
+ var _a, _b, _c, _d, _e, _f, _g;
351
+ const { args, warnings } = await this.getArgs({
352
+ ...options,
353
+ stream: false
354
+ });
330
355
  const body = JSON.stringify(args);
331
356
  const {
332
357
  responseHeaders,
@@ -356,7 +381,6 @@ var GroqChatLanguageModel = class {
356
381
  if (reasoning != null && reasoning.length > 0) {
357
382
  content.push({
358
383
  type: "reasoning",
359
- reasoningType: "text",
360
384
  text: reasoning
361
385
  });
362
386
  }
@@ -364,10 +388,9 @@ var GroqChatLanguageModel = class {
364
388
  for (const toolCall of choice.message.tool_calls) {
365
389
  content.push({
366
390
  type: "tool-call",
367
- toolCallType: "function",
368
391
  toolCallId: (_a = toolCall.id) != null ? _a : (0, import_provider_utils2.generateId)(),
369
392
  toolName: toolCall.function.name,
370
- args: toolCall.function.arguments
393
+ input: toolCall.function.arguments
371
394
  });
372
395
  }
373
396
  }
@@ -376,7 +399,8 @@ var GroqChatLanguageModel = class {
376
399
  finishReason: mapGroqFinishReason(choice.finish_reason),
377
400
  usage: {
378
401
  inputTokens: (_c = (_b = response.usage) == null ? void 0 : _b.prompt_tokens) != null ? _c : void 0,
379
- outputTokens: (_e = (_d = response.usage) == null ? void 0 : _d.completion_tokens) != null ? _e : void 0
402
+ outputTokens: (_e = (_d = response.usage) == null ? void 0 : _d.completion_tokens) != null ? _e : void 0,
403
+ totalTokens: (_g = (_f = response.usage) == null ? void 0 : _f.total_tokens) != null ? _g : void 0
380
404
  },
381
405
  response: {
382
406
  ...getResponseMetadata(response),
@@ -388,7 +412,7 @@ var GroqChatLanguageModel = class {
388
412
  };
389
413
  }
390
414
  async doStream(options) {
391
- const { args, warnings } = this.getArgs({ ...options, stream: true });
415
+ const { args, warnings } = await this.getArgs({ ...options, stream: true });
392
416
  const body = JSON.stringify({ ...args, stream: true });
393
417
  const { responseHeaders, value: response } = await (0, import_provider_utils2.postJsonToApi)({
394
418
  url: this.config.url({
@@ -409,9 +433,12 @@ var GroqChatLanguageModel = class {
409
433
  let finishReason = "unknown";
410
434
  const usage = {
411
435
  inputTokens: void 0,
412
- outputTokens: void 0
436
+ outputTokens: void 0,
437
+ totalTokens: void 0
413
438
  };
414
439
  let isFirstChunk = true;
440
+ let isActiveText = false;
441
+ let isActiveReasoning = false;
415
442
  let providerMetadata;
416
443
  return {
417
444
  stream: response.pipeThrough(
@@ -420,7 +447,10 @@ var GroqChatLanguageModel = class {
420
447
  controller.enqueue({ type: "stream-start", warnings });
421
448
  },
422
449
  transform(chunk, controller) {
423
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
450
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
451
+ if (options.includeRawChunks) {
452
+ controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
453
+ }
424
454
  if (!chunk.success) {
425
455
  finishReason = "error";
426
456
  controller.enqueue({ type: "error", error: chunk.error });
@@ -442,6 +472,7 @@ var GroqChatLanguageModel = class {
442
472
  if (((_a = value.x_groq) == null ? void 0 : _a.usage) != null) {
443
473
  usage.inputTokens = (_b = value.x_groq.usage.prompt_tokens) != null ? _b : void 0;
444
474
  usage.outputTokens = (_c = value.x_groq.usage.completion_tokens) != null ? _c : void 0;
475
+ usage.totalTokens = (_d = value.x_groq.usage.total_tokens) != null ? _d : void 0;
445
476
  }
446
477
  const choice = value.choices[0];
447
478
  if ((choice == null ? void 0 : choice.finish_reason) != null) {
@@ -452,16 +483,28 @@ var GroqChatLanguageModel = class {
452
483
  }
453
484
  const delta = choice.delta;
454
485
  if (delta.reasoning != null && delta.reasoning.length > 0) {
486
+ if (!isActiveReasoning) {
487
+ controller.enqueue({
488
+ type: "reasoning-start",
489
+ id: "reasoning-0"
490
+ });
491
+ isActiveReasoning = true;
492
+ }
455
493
  controller.enqueue({
456
- type: "reasoning",
457
- reasoningType: "text",
458
- text: delta.reasoning
494
+ type: "reasoning-delta",
495
+ id: "reasoning-0",
496
+ delta: delta.reasoning
459
497
  });
460
498
  }
461
499
  if (delta.content != null && delta.content.length > 0) {
500
+ if (!isActiveText) {
501
+ controller.enqueue({ type: "text-start", id: "txt-0" });
502
+ isActiveText = true;
503
+ }
462
504
  controller.enqueue({
463
- type: "text",
464
- text: delta.content
505
+ type: "text-delta",
506
+ id: "txt-0",
507
+ delta: delta.content
465
508
  });
466
509
  }
467
510
  if (delta.tool_calls != null) {
@@ -480,39 +523,45 @@ var GroqChatLanguageModel = class {
480
523
  message: `Expected 'id' to be a string.`
481
524
  });
482
525
  }
483
- if (((_d = toolCallDelta.function) == null ? void 0 : _d.name) == null) {
526
+ if (((_e = toolCallDelta.function) == null ? void 0 : _e.name) == null) {
484
527
  throw new import_provider3.InvalidResponseDataError({
485
528
  data: toolCallDelta,
486
529
  message: `Expected 'function.name' to be a string.`
487
530
  });
488
531
  }
532
+ controller.enqueue({
533
+ type: "tool-input-start",
534
+ id: toolCallDelta.id,
535
+ toolName: toolCallDelta.function.name
536
+ });
489
537
  toolCalls[index] = {
490
538
  id: toolCallDelta.id,
491
539
  type: "function",
492
540
  function: {
493
541
  name: toolCallDelta.function.name,
494
- arguments: (_e = toolCallDelta.function.arguments) != null ? _e : ""
542
+ arguments: (_f = toolCallDelta.function.arguments) != null ? _f : ""
495
543
  },
496
544
  hasFinished: false
497
545
  };
498
546
  const toolCall2 = toolCalls[index];
499
- if (((_f = toolCall2.function) == null ? void 0 : _f.name) != null && ((_g = toolCall2.function) == null ? void 0 : _g.arguments) != null) {
547
+ if (((_g = toolCall2.function) == null ? void 0 : _g.name) != null && ((_h = toolCall2.function) == null ? void 0 : _h.arguments) != null) {
500
548
  if (toolCall2.function.arguments.length > 0) {
501
549
  controller.enqueue({
502
- type: "tool-call-delta",
503
- toolCallType: "function",
504
- toolCallId: toolCall2.id,
505
- toolName: toolCall2.function.name,
506
- argsTextDelta: toolCall2.function.arguments
550
+ type: "tool-input-delta",
551
+ id: toolCall2.id,
552
+ delta: toolCall2.function.arguments
507
553
  });
508
554
  }
509
555
  if ((0, import_provider_utils2.isParsableJson)(toolCall2.function.arguments)) {
556
+ controller.enqueue({
557
+ type: "tool-input-end",
558
+ id: toolCall2.id
559
+ });
510
560
  controller.enqueue({
511
561
  type: "tool-call",
512
- toolCallType: "function",
513
- toolCallId: (_h = toolCall2.id) != null ? _h : (0, import_provider_utils2.generateId)(),
562
+ toolCallId: (_i = toolCall2.id) != null ? _i : (0, import_provider_utils2.generateId)(),
514
563
  toolName: toolCall2.function.name,
515
- args: toolCall2.function.arguments
564
+ input: toolCall2.function.arguments
516
565
  });
517
566
  toolCall2.hasFinished = true;
518
567
  }
@@ -523,23 +572,24 @@ var GroqChatLanguageModel = class {
523
572
  if (toolCall.hasFinished) {
524
573
  continue;
525
574
  }
526
- if (((_i = toolCallDelta.function) == null ? void 0 : _i.arguments) != null) {
527
- toolCall.function.arguments += (_k = (_j = toolCallDelta.function) == null ? void 0 : _j.arguments) != null ? _k : "";
575
+ if (((_j = toolCallDelta.function) == null ? void 0 : _j.arguments) != null) {
576
+ toolCall.function.arguments += (_l = (_k = toolCallDelta.function) == null ? void 0 : _k.arguments) != null ? _l : "";
528
577
  }
529
578
  controller.enqueue({
530
- type: "tool-call-delta",
531
- toolCallType: "function",
532
- toolCallId: toolCall.id,
533
- toolName: toolCall.function.name,
534
- argsTextDelta: (_l = toolCallDelta.function.arguments) != null ? _l : ""
579
+ type: "tool-input-delta",
580
+ id: toolCall.id,
581
+ delta: (_m = toolCallDelta.function.arguments) != null ? _m : ""
535
582
  });
536
- if (((_m = toolCall.function) == null ? void 0 : _m.name) != null && ((_n = toolCall.function) == null ? void 0 : _n.arguments) != null && (0, import_provider_utils2.isParsableJson)(toolCall.function.arguments)) {
583
+ if (((_n = toolCall.function) == null ? void 0 : _n.name) != null && ((_o = toolCall.function) == null ? void 0 : _o.arguments) != null && (0, import_provider_utils2.isParsableJson)(toolCall.function.arguments)) {
584
+ controller.enqueue({
585
+ type: "tool-input-end",
586
+ id: toolCall.id
587
+ });
537
588
  controller.enqueue({
538
589
  type: "tool-call",
539
- toolCallType: "function",
540
- toolCallId: (_o = toolCall.id) != null ? _o : (0, import_provider_utils2.generateId)(),
590
+ toolCallId: (_p = toolCall.id) != null ? _p : (0, import_provider_utils2.generateId)(),
541
591
  toolName: toolCall.function.name,
542
- args: toolCall.function.arguments
592
+ input: toolCall.function.arguments
543
593
  });
544
594
  toolCall.hasFinished = true;
545
595
  }
@@ -547,6 +597,12 @@ var GroqChatLanguageModel = class {
547
597
  }
548
598
  },
549
599
  flush(controller) {
600
+ if (isActiveReasoning) {
601
+ controller.enqueue({ type: "reasoning-end", id: "reasoning-0" });
602
+ }
603
+ if (isActiveText) {
604
+ controller.enqueue({ type: "text-end", id: "txt-0" });
605
+ }
550
606
  controller.enqueue({
551
607
  type: "finish",
552
608
  finishReason,
@@ -561,65 +617,67 @@ var GroqChatLanguageModel = class {
561
617
  };
562
618
  }
563
619
  };
564
- var groqChatResponseSchema = import_zod3.z.object({
565
- id: import_zod3.z.string().nullish(),
566
- created: import_zod3.z.number().nullish(),
567
- model: import_zod3.z.string().nullish(),
568
- choices: import_zod3.z.array(
569
- import_zod3.z.object({
570
- message: import_zod3.z.object({
571
- content: import_zod3.z.string().nullish(),
572
- reasoning: import_zod3.z.string().nullish(),
573
- tool_calls: import_zod3.z.array(
574
- import_zod3.z.object({
575
- id: import_zod3.z.string().nullish(),
576
- type: import_zod3.z.literal("function"),
577
- function: import_zod3.z.object({
578
- name: import_zod3.z.string(),
579
- arguments: import_zod3.z.string()
620
+ var groqChatResponseSchema = import_v43.z.object({
621
+ id: import_v43.z.string().nullish(),
622
+ created: import_v43.z.number().nullish(),
623
+ model: import_v43.z.string().nullish(),
624
+ choices: import_v43.z.array(
625
+ import_v43.z.object({
626
+ message: import_v43.z.object({
627
+ content: import_v43.z.string().nullish(),
628
+ reasoning: import_v43.z.string().nullish(),
629
+ tool_calls: import_v43.z.array(
630
+ import_v43.z.object({
631
+ id: import_v43.z.string().nullish(),
632
+ type: import_v43.z.literal("function"),
633
+ function: import_v43.z.object({
634
+ name: import_v43.z.string(),
635
+ arguments: import_v43.z.string()
580
636
  })
581
637
  })
582
638
  ).nullish()
583
639
  }),
584
- index: import_zod3.z.number(),
585
- finish_reason: import_zod3.z.string().nullish()
640
+ index: import_v43.z.number(),
641
+ finish_reason: import_v43.z.string().nullish()
586
642
  })
587
643
  ),
588
- usage: import_zod3.z.object({
589
- prompt_tokens: import_zod3.z.number().nullish(),
590
- completion_tokens: import_zod3.z.number().nullish()
644
+ usage: import_v43.z.object({
645
+ prompt_tokens: import_v43.z.number().nullish(),
646
+ completion_tokens: import_v43.z.number().nullish(),
647
+ total_tokens: import_v43.z.number().nullish()
591
648
  }).nullish()
592
649
  });
593
- var groqChatChunkSchema = import_zod3.z.union([
594
- import_zod3.z.object({
595
- id: import_zod3.z.string().nullish(),
596
- created: import_zod3.z.number().nullish(),
597
- model: import_zod3.z.string().nullish(),
598
- choices: import_zod3.z.array(
599
- import_zod3.z.object({
600
- delta: import_zod3.z.object({
601
- content: import_zod3.z.string().nullish(),
602
- reasoning: import_zod3.z.string().nullish(),
603
- tool_calls: import_zod3.z.array(
604
- import_zod3.z.object({
605
- index: import_zod3.z.number(),
606
- id: import_zod3.z.string().nullish(),
607
- type: import_zod3.z.literal("function").optional(),
608
- function: import_zod3.z.object({
609
- name: import_zod3.z.string().nullish(),
610
- arguments: import_zod3.z.string().nullish()
650
+ var groqChatChunkSchema = import_v43.z.union([
651
+ import_v43.z.object({
652
+ id: import_v43.z.string().nullish(),
653
+ created: import_v43.z.number().nullish(),
654
+ model: import_v43.z.string().nullish(),
655
+ choices: import_v43.z.array(
656
+ import_v43.z.object({
657
+ delta: import_v43.z.object({
658
+ content: import_v43.z.string().nullish(),
659
+ reasoning: import_v43.z.string().nullish(),
660
+ tool_calls: import_v43.z.array(
661
+ import_v43.z.object({
662
+ index: import_v43.z.number(),
663
+ id: import_v43.z.string().nullish(),
664
+ type: import_v43.z.literal("function").optional(),
665
+ function: import_v43.z.object({
666
+ name: import_v43.z.string().nullish(),
667
+ arguments: import_v43.z.string().nullish()
611
668
  })
612
669
  })
613
670
  ).nullish()
614
671
  }).nullish(),
615
- finish_reason: import_zod3.z.string().nullable().optional(),
616
- index: import_zod3.z.number()
672
+ finish_reason: import_v43.z.string().nullable().optional(),
673
+ index: import_v43.z.number()
617
674
  })
618
675
  ),
619
- x_groq: import_zod3.z.object({
620
- usage: import_zod3.z.object({
621
- prompt_tokens: import_zod3.z.number().nullish(),
622
- completion_tokens: import_zod3.z.number().nullish()
676
+ x_groq: import_v43.z.object({
677
+ usage: import_v43.z.object({
678
+ prompt_tokens: import_v43.z.number().nullish(),
679
+ completion_tokens: import_v43.z.number().nullish(),
680
+ total_tokens: import_v43.z.number().nullish()
623
681
  }).nullish()
624
682
  }).nullish()
625
683
  }),
@@ -628,31 +686,31 @@ var groqChatChunkSchema = import_zod3.z.union([
628
686
 
629
687
  // src/groq-transcription-model.ts
630
688
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
631
- var import_zod4 = require("zod");
632
- var groqProviderOptionsSchema = import_zod4.z.object({
633
- language: import_zod4.z.string().nullish(),
634
- prompt: import_zod4.z.string().nullish(),
635
- responseFormat: import_zod4.z.string().nullish(),
636
- temperature: import_zod4.z.number().min(0).max(1).nullish(),
637
- timestampGranularities: import_zod4.z.array(import_zod4.z.string()).nullish()
689
+ var import_v44 = require("zod/v4");
690
+ var groqProviderOptionsSchema = import_v44.z.object({
691
+ language: import_v44.z.string().nullish(),
692
+ prompt: import_v44.z.string().nullish(),
693
+ responseFormat: import_v44.z.string().nullish(),
694
+ temperature: import_v44.z.number().min(0).max(1).nullish(),
695
+ timestampGranularities: import_v44.z.array(import_v44.z.string()).nullish()
638
696
  });
639
697
  var GroqTranscriptionModel = class {
640
698
  constructor(modelId, config) {
641
699
  this.modelId = modelId;
642
700
  this.config = config;
643
- this.specificationVersion = "v1";
701
+ this.specificationVersion = "v2";
644
702
  }
645
703
  get provider() {
646
704
  return this.config.provider;
647
705
  }
648
- getArgs({
706
+ async getArgs({
649
707
  audio,
650
708
  mediaType,
651
709
  providerOptions
652
710
  }) {
653
711
  var _a, _b, _c, _d, _e;
654
712
  const warnings = [];
655
- const groqOptions = (0, import_provider_utils3.parseProviderOptions)({
713
+ const groqOptions = await (0, import_provider_utils3.parseProviderOptions)({
656
714
  provider: "groq",
657
715
  providerOptions,
658
716
  schema: groqProviderOptionsSchema
@@ -684,7 +742,7 @@ var GroqTranscriptionModel = class {
684
742
  async doGenerate(options) {
685
743
  var _a, _b, _c, _d, _e;
686
744
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
687
- const { formData, warnings } = this.getArgs(options);
745
+ const { formData, warnings } = await this.getArgs(options);
688
746
  const {
689
747
  value: response,
690
748
  responseHeaders,
@@ -722,27 +780,27 @@ var GroqTranscriptionModel = class {
722
780
  };
723
781
  }
724
782
  };
725
- var groqTranscriptionResponseSchema = import_zod4.z.object({
726
- task: import_zod4.z.string(),
727
- language: import_zod4.z.string(),
728
- duration: import_zod4.z.number(),
729
- text: import_zod4.z.string(),
730
- segments: import_zod4.z.array(
731
- import_zod4.z.object({
732
- id: import_zod4.z.number(),
733
- seek: import_zod4.z.number(),
734
- start: import_zod4.z.number(),
735
- end: import_zod4.z.number(),
736
- text: import_zod4.z.string(),
737
- tokens: import_zod4.z.array(import_zod4.z.number()),
738
- temperature: import_zod4.z.number(),
739
- avg_logprob: import_zod4.z.number(),
740
- compression_ratio: import_zod4.z.number(),
741
- no_speech_prob: import_zod4.z.number()
783
+ var groqTranscriptionResponseSchema = import_v44.z.object({
784
+ task: import_v44.z.string(),
785
+ language: import_v44.z.string(),
786
+ duration: import_v44.z.number(),
787
+ text: import_v44.z.string(),
788
+ segments: import_v44.z.array(
789
+ import_v44.z.object({
790
+ id: import_v44.z.number(),
791
+ seek: import_v44.z.number(),
792
+ start: import_v44.z.number(),
793
+ end: import_v44.z.number(),
794
+ text: import_v44.z.string(),
795
+ tokens: import_v44.z.array(import_v44.z.number()),
796
+ temperature: import_v44.z.number(),
797
+ avg_logprob: import_v44.z.number(),
798
+ compression_ratio: import_v44.z.number(),
799
+ no_speech_prob: import_v44.z.number()
742
800
  })
743
801
  ),
744
- x_groq: import_zod4.z.object({
745
- id: import_zod4.z.string()
802
+ x_groq: import_v44.z.object({
803
+ id: import_v44.z.string()
746
804
  })
747
805
  });
748
806
 
@@ -758,19 +816,19 @@ function createGroq(options = {}) {
758
816
  })}`,
759
817
  ...options.headers
760
818
  });
761
- const createChatModel = (modelId, settings = {}) => new GroqChatLanguageModel(modelId, settings, {
819
+ const createChatModel = (modelId) => new GroqChatLanguageModel(modelId, {
762
820
  provider: "groq.chat",
763
821
  url: ({ path }) => `${baseURL}${path}`,
764
822
  headers: getHeaders,
765
823
  fetch: options.fetch
766
824
  });
767
- const createLanguageModel = (modelId, settings) => {
825
+ const createLanguageModel = (modelId) => {
768
826
  if (new.target) {
769
827
  throw new Error(
770
828
  "The Groq model function cannot be called with the new keyword."
771
829
  );
772
830
  }
773
- return createChatModel(modelId, settings);
831
+ return createChatModel(modelId);
774
832
  };
775
833
  const createTranscriptionModel = (modelId) => {
776
834
  return new GroqTranscriptionModel(modelId, {
@@ -780,8 +838,8 @@ function createGroq(options = {}) {
780
838
  fetch: options.fetch
781
839
  });
782
840
  };
783
- const provider = function(modelId, settings) {
784
- return createLanguageModel(modelId, settings);
841
+ const provider = function(modelId) {
842
+ return createLanguageModel(modelId);
785
843
  };
786
844
  provider.languageModel = createLanguageModel;
787
845
  provider.chat = createChatModel;