@ai-sdk/groq 2.0.0-canary.9 → 2.0.1

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