@ai-sdk/groq 4.0.0-beta.4 → 4.0.0-beta.54

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.
@@ -1,44 +1,51 @@
1
- import {
2
- InvalidResponseDataError,
3
- LanguageModelV3,
4
- LanguageModelV3CallOptions,
5
- LanguageModelV3Content,
6
- LanguageModelV3FinishReason,
7
- LanguageModelV3GenerateResult,
8
- LanguageModelV3StreamPart,
9
- LanguageModelV3StreamResult,
10
- SharedV3ProviderMetadata,
11
- SharedV3Warning,
1
+ import type {
2
+ LanguageModelV4,
3
+ LanguageModelV4CallOptions,
4
+ LanguageModelV4Content,
5
+ LanguageModelV4FinishReason,
6
+ LanguageModelV4GenerateResult,
7
+ LanguageModelV4StreamPart,
8
+ LanguageModelV4StreamResult,
9
+ SharedV4ProviderMetadata,
10
+ SharedV4Warning,
12
11
  } from '@ai-sdk/provider';
13
12
  import {
14
- FetchFunction,
15
- ParseResult,
13
+ StreamingToolCallTracker,
16
14
  combineHeaders,
17
15
  createEventSourceResponseHandler,
18
16
  createJsonResponseHandler,
19
17
  generateId,
20
- isParsableJson,
18
+ isCustomReasoning,
19
+ mapReasoningToProviderEffort,
21
20
  parseProviderOptions,
22
21
  postJsonToApi,
22
+ serializeModelOptions,
23
+ WORKFLOW_SERIALIZE,
24
+ WORKFLOW_DESERIALIZE,
25
+ type FetchFunction,
26
+ type ParseResult,
23
27
  } from '@ai-sdk/provider-utils';
24
28
  import { z } from 'zod/v4';
25
29
  import { convertGroqUsage } from './convert-groq-usage';
26
30
  import { convertToGroqChatMessages } from './convert-to-groq-chat-messages';
27
31
  import { getResponseMetadata } from './get-response-metadata';
28
- import { GroqChatModelId, groqLanguageModelOptions } from './groq-chat-options';
32
+ import {
33
+ groqLanguageModelChatOptions,
34
+ type GroqChatModelId,
35
+ } from './groq-chat-language-model-options';
29
36
  import { groqErrorDataSchema, groqFailedResponseHandler } from './groq-error';
30
37
  import { prepareTools } from './groq-prepare-tools';
31
38
  import { mapGroqFinishReason } from './map-groq-finish-reason';
32
39
 
33
40
  type GroqChatConfig = {
34
41
  provider: string;
35
- headers: () => Record<string, string | undefined>;
42
+ headers?: () => Record<string, string | undefined>;
36
43
  url: (options: { modelId: string; path: string }) => string;
37
44
  fetch?: FetchFunction;
38
45
  };
39
46
 
40
- export class GroqChatLanguageModel implements LanguageModelV3 {
41
- readonly specificationVersion = 'v3';
47
+ export class GroqChatLanguageModel implements LanguageModelV4 {
48
+ readonly specificationVersion = 'v4';
42
49
 
43
50
  readonly modelId: GroqChatModelId;
44
51
 
@@ -48,6 +55,20 @@ export class GroqChatLanguageModel implements LanguageModelV3 {
48
55
 
49
56
  private readonly config: GroqChatConfig;
50
57
 
58
+ static [WORKFLOW_SERIALIZE](model: GroqChatLanguageModel) {
59
+ return serializeModelOptions({
60
+ modelId: model.modelId,
61
+ config: model.config,
62
+ });
63
+ }
64
+
65
+ static [WORKFLOW_DESERIALIZE](options: {
66
+ modelId: GroqChatModelId;
67
+ config: GroqChatConfig;
68
+ }) {
69
+ return new GroqChatLanguageModel(options.modelId, options.config);
70
+ }
71
+
51
72
  constructor(modelId: GroqChatModelId, config: GroqChatConfig) {
52
73
  this.modelId = modelId;
53
74
  this.config = config;
@@ -68,19 +89,17 @@ export class GroqChatLanguageModel implements LanguageModelV3 {
68
89
  stopSequences,
69
90
  responseFormat,
70
91
  seed,
71
- stream,
92
+ reasoning,
72
93
  tools,
73
94
  toolChoice,
74
95
  providerOptions,
75
- }: LanguageModelV3CallOptions & {
76
- stream: boolean;
77
- }) {
78
- const warnings: SharedV3Warning[] = [];
96
+ }: LanguageModelV4CallOptions) {
97
+ const warnings: SharedV4Warning[] = [];
79
98
 
80
99
  const groqOptions = await parseProviderOptions({
81
100
  provider: 'groq',
82
101
  providerOptions,
83
- schema: groqLanguageModelOptions,
102
+ schema: groqLanguageModelChatOptions,
84
103
  });
85
104
 
86
105
  const structuredOutputs = groqOptions?.structuredOutputs ?? true;
@@ -145,7 +164,21 @@ export class GroqChatLanguageModel implements LanguageModelV3 {
145
164
 
146
165
  // provider options:
147
166
  reasoning_format: groqOptions?.reasoningFormat,
148
- reasoning_effort: groqOptions?.reasoningEffort,
167
+ reasoning_effort:
168
+ groqOptions?.reasoningEffort ??
169
+ (isCustomReasoning(reasoning) && reasoning !== 'none'
170
+ ? mapReasoningToProviderEffort({
171
+ reasoning,
172
+ effortMap: {
173
+ minimal: 'low',
174
+ low: 'low',
175
+ medium: 'medium',
176
+ high: 'high',
177
+ xhigh: 'high',
178
+ },
179
+ warnings,
180
+ })
181
+ : undefined),
149
182
  service_tier: groqOptions?.serviceTier,
150
183
 
151
184
  // messages:
@@ -160,12 +193,9 @@ export class GroqChatLanguageModel implements LanguageModelV3 {
160
193
  }
161
194
 
162
195
  async doGenerate(
163
- options: LanguageModelV3CallOptions,
164
- ): Promise<LanguageModelV3GenerateResult> {
165
- const { args, warnings } = await this.getArgs({
166
- ...options,
167
- stream: false,
168
- });
196
+ options: LanguageModelV4CallOptions,
197
+ ): Promise<LanguageModelV4GenerateResult> {
198
+ const { args, warnings } = await this.getArgs(options);
169
199
 
170
200
  const body = JSON.stringify(args);
171
201
 
@@ -178,7 +208,7 @@ export class GroqChatLanguageModel implements LanguageModelV3 {
178
208
  path: '/chat/completions',
179
209
  modelId: this.modelId,
180
210
  }),
181
- headers: combineHeaders(this.config.headers(), options.headers),
211
+ headers: combineHeaders(this.config.headers?.(), options.headers),
182
212
  body: args,
183
213
  failedResponseHandler: groqFailedResponseHandler,
184
214
  successfulResponseHandler: createJsonResponseHandler(
@@ -189,7 +219,7 @@ export class GroqChatLanguageModel implements LanguageModelV3 {
189
219
  });
190
220
 
191
221
  const choice = response.choices[0];
192
- const content: Array<LanguageModelV3Content> = [];
222
+ const content: Array<LanguageModelV4Content> = [];
193
223
 
194
224
  // text content:
195
225
  const text = choice.message.content;
@@ -236,22 +266,19 @@ export class GroqChatLanguageModel implements LanguageModelV3 {
236
266
  }
237
267
 
238
268
  async doStream(
239
- options: LanguageModelV3CallOptions,
240
- ): Promise<LanguageModelV3StreamResult> {
241
- const { args, warnings } = await this.getArgs({ ...options, stream: true });
269
+ options: LanguageModelV4CallOptions,
270
+ ): Promise<LanguageModelV4StreamResult> {
271
+ const { args, warnings } = await this.getArgs(options);
242
272
 
243
- const body = JSON.stringify({ ...args, stream: true });
273
+ const body = { ...args, stream: true };
244
274
 
245
275
  const { responseHeaders, value: response } = await postJsonToApi({
246
276
  url: this.config.url({
247
277
  path: '/chat/completions',
248
278
  modelId: this.modelId,
249
279
  }),
250
- headers: combineHeaders(this.config.headers(), options.headers),
251
- body: {
252
- ...args,
253
- stream: true,
254
- },
280
+ headers: combineHeaders(this.config.headers?.(), options.headers),
281
+ body,
255
282
  failedResponseHandler: groqFailedResponseHandler,
256
283
  successfulResponseHandler:
257
284
  createEventSourceResponseHandler(groqChatChunkSchema),
@@ -259,17 +286,9 @@ export class GroqChatLanguageModel implements LanguageModelV3 {
259
286
  fetch: this.config.fetch,
260
287
  });
261
288
 
262
- const toolCalls: Array<{
263
- id: string;
264
- type: 'function';
265
- function: {
266
- name: string;
267
- arguments: string;
268
- };
269
- hasFinished: boolean;
270
- }> = [];
271
-
272
- let finishReason: LanguageModelV3FinishReason = {
289
+ let toolCallTracker: StreamingToolCallTracker;
290
+
291
+ let finishReason: LanguageModelV4FinishReason = {
273
292
  unified: 'other',
274
293
  raw: undefined,
275
294
  };
@@ -295,14 +314,18 @@ export class GroqChatLanguageModel implements LanguageModelV3 {
295
314
  let isActiveText = false;
296
315
  let isActiveReasoning = false;
297
316
 
298
- let providerMetadata: SharedV3ProviderMetadata | undefined;
317
+ let providerMetadata: SharedV4ProviderMetadata | undefined;
299
318
  return {
300
319
  stream: response.pipeThrough(
301
320
  new TransformStream<
302
321
  ParseResult<z.infer<typeof groqChatChunkSchema>>,
303
- LanguageModelV3StreamPart
322
+ LanguageModelV4StreamPart
304
323
  >({
305
324
  start(controller) {
325
+ toolCallTracker = new StreamingToolCallTracker(controller, {
326
+ generateId,
327
+ typeValidation: 'required',
328
+ });
306
329
  controller.enqueue({ type: 'stream-start', warnings });
307
330
  },
308
331
 
@@ -411,120 +434,7 @@ export class GroqChatLanguageModel implements LanguageModelV3 {
411
434
  }
412
435
 
413
436
  for (const toolCallDelta of delta.tool_calls) {
414
- const index = toolCallDelta.index;
415
-
416
- if (toolCalls[index] == null) {
417
- if (toolCallDelta.type !== 'function') {
418
- throw new InvalidResponseDataError({
419
- data: toolCallDelta,
420
- message: `Expected 'function' type.`,
421
- });
422
- }
423
-
424
- if (toolCallDelta.id == null) {
425
- throw new InvalidResponseDataError({
426
- data: toolCallDelta,
427
- message: `Expected 'id' to be a string.`,
428
- });
429
- }
430
-
431
- if (toolCallDelta.function?.name == null) {
432
- throw new InvalidResponseDataError({
433
- data: toolCallDelta,
434
- message: `Expected 'function.name' to be a string.`,
435
- });
436
- }
437
-
438
- controller.enqueue({
439
- type: 'tool-input-start',
440
- id: toolCallDelta.id,
441
- toolName: toolCallDelta.function.name,
442
- });
443
-
444
- toolCalls[index] = {
445
- id: toolCallDelta.id,
446
- type: 'function',
447
- function: {
448
- name: toolCallDelta.function.name,
449
- arguments: toolCallDelta.function.arguments ?? '',
450
- },
451
- hasFinished: false,
452
- };
453
-
454
- const toolCall = toolCalls[index];
455
-
456
- if (
457
- toolCall.function?.name != null &&
458
- toolCall.function?.arguments != null
459
- ) {
460
- // send delta if the argument text has already started:
461
- if (toolCall.function.arguments.length > 0) {
462
- controller.enqueue({
463
- type: 'tool-input-delta',
464
- id: toolCall.id,
465
- delta: toolCall.function.arguments,
466
- });
467
- }
468
-
469
- // check if tool call is complete
470
- // (some providers send the full tool call in one chunk):
471
- if (isParsableJson(toolCall.function.arguments)) {
472
- controller.enqueue({
473
- type: 'tool-input-end',
474
- id: toolCall.id,
475
- });
476
-
477
- controller.enqueue({
478
- type: 'tool-call',
479
- toolCallId: toolCall.id ?? generateId(),
480
- toolName: toolCall.function.name,
481
- input: toolCall.function.arguments,
482
- });
483
- toolCall.hasFinished = true;
484
- }
485
- }
486
-
487
- continue;
488
- }
489
-
490
- // existing tool call, merge if not finished
491
- const toolCall = toolCalls[index];
492
-
493
- if (toolCall.hasFinished) {
494
- continue;
495
- }
496
-
497
- if (toolCallDelta.function?.arguments != null) {
498
- toolCall.function!.arguments +=
499
- toolCallDelta.function?.arguments ?? '';
500
- }
501
-
502
- // send delta
503
- controller.enqueue({
504
- type: 'tool-input-delta',
505
- id: toolCall.id,
506
- delta: toolCallDelta.function.arguments ?? '',
507
- });
508
-
509
- // check if tool call is complete
510
- if (
511
- toolCall.function?.name != null &&
512
- toolCall.function?.arguments != null &&
513
- isParsableJson(toolCall.function.arguments)
514
- ) {
515
- controller.enqueue({
516
- type: 'tool-input-end',
517
- id: toolCall.id,
518
- });
519
-
520
- controller.enqueue({
521
- type: 'tool-call',
522
- toolCallId: toolCall.id ?? generateId(),
523
- toolName: toolCall.function.name,
524
- input: toolCall.function.arguments,
525
- });
526
- toolCall.hasFinished = true;
527
- }
437
+ toolCallTracker.processDelta(toolCallDelta);
528
438
  }
529
439
  }
530
440
  },
@@ -538,6 +448,8 @@ export class GroqChatLanguageModel implements LanguageModelV3 {
538
448
  controller.enqueue({ type: 'text-end', id: 'txt-0' });
539
449
  }
540
450
 
451
+ toolCallTracker.flush();
452
+
541
453
  controller.enqueue({
542
454
  type: 'finish',
543
455
  finishReason,
@@ -547,7 +459,7 @@ export class GroqChatLanguageModel implements LanguageModelV3 {
547
459
  },
548
460
  }),
549
461
  ),
550
- request: { body },
462
+ request: { body: JSON.stringify(body) },
551
463
  response: { headers: responseHeaders },
552
464
  };
553
465
  }
@@ -1,9 +1,9 @@
1
- import { FetchFunction } from '@ai-sdk/provider-utils';
1
+ import type { FetchFunction } from '@ai-sdk/provider-utils';
2
2
 
3
3
  export type GroqConfig = {
4
4
  provider: string;
5
5
  url: (options: { modelId: string; path: string }) => string;
6
- headers: () => Record<string, string | undefined>;
6
+ headers?: () => Record<string, string | undefined>;
7
7
  fetch?: FetchFunction;
8
8
  generateId?: () => string;
9
9
  };
@@ -1,21 +1,21 @@
1
1
  import {
2
- LanguageModelV3CallOptions,
3
- SharedV3Warning,
4
2
  UnsupportedFunctionalityError,
3
+ type LanguageModelV4CallOptions,
4
+ type SharedV4Warning,
5
5
  } from '@ai-sdk/provider';
6
6
  import {
7
7
  getSupportedModelsString,
8
8
  isBrowserSearchSupportedModel,
9
9
  } from './groq-browser-search-models';
10
- import { GroqChatModelId } from './groq-chat-options';
10
+ import type { GroqChatModelId } from './groq-chat-language-model-options';
11
11
 
12
12
  export function prepareTools({
13
13
  tools,
14
14
  toolChoice,
15
15
  modelId,
16
16
  }: {
17
- tools: LanguageModelV3CallOptions['tools'];
18
- toolChoice?: LanguageModelV3CallOptions['toolChoice'];
17
+ tools: LanguageModelV4CallOptions['tools'];
18
+ toolChoice?: LanguageModelV4CallOptions['toolChoice'];
19
19
  modelId: GroqChatModelId;
20
20
  }): {
21
21
  tools:
@@ -40,12 +40,12 @@ export function prepareTools({
40
40
  | 'none'
41
41
  | 'required'
42
42
  | undefined;
43
- toolWarnings: SharedV3Warning[];
43
+ toolWarnings: SharedV4Warning[];
44
44
  } {
45
45
  // when the tools array is empty, change it to undefined to prevent errors:
46
46
  tools = tools?.length ? tools : undefined;
47
47
 
48
- const toolWarnings: SharedV3Warning[] = [];
48
+ const toolWarnings: SharedV4Warning[] = [];
49
49
 
50
50
  if (tools == null) {
51
51
  return { tools: undefined, toolChoice: undefined, toolWarnings };
@@ -1,37 +1,37 @@
1
1
  import {
2
- LanguageModelV3,
3
2
  NoSuchModelError,
4
- ProviderV3,
5
- TranscriptionModelV3,
3
+ type LanguageModelV4,
4
+ type ProviderV4,
5
+ type TranscriptionModelV4,
6
6
  } from '@ai-sdk/provider';
7
7
  import {
8
- FetchFunction,
9
8
  loadApiKey,
10
9
  withoutTrailingSlash,
11
10
  withUserAgentSuffix,
11
+ type FetchFunction,
12
12
  } from '@ai-sdk/provider-utils';
13
13
  import { GroqChatLanguageModel } from './groq-chat-language-model';
14
- import { GroqChatModelId } from './groq-chat-options';
15
- import { GroqTranscriptionModelId } from './groq-transcription-options';
14
+ import type { GroqChatModelId } from './groq-chat-language-model-options';
15
+ import type { GroqTranscriptionModelId } from './groq-transcription-model-options';
16
16
  import { GroqTranscriptionModel } from './groq-transcription-model';
17
17
 
18
18
  import { groqTools } from './groq-tools';
19
19
  import { VERSION } from './version';
20
- export interface GroqProvider extends ProviderV3 {
20
+ export interface GroqProvider extends ProviderV4 {
21
21
  /**
22
22
  * Creates a model for text generation.
23
23
  */
24
- (modelId: GroqChatModelId): LanguageModelV3;
24
+ (modelId: GroqChatModelId): LanguageModelV4;
25
25
 
26
26
  /**
27
27
  * Creates an Groq chat model for text generation.
28
28
  */
29
- languageModel(modelId: GroqChatModelId): LanguageModelV3;
29
+ languageModel(modelId: GroqChatModelId): LanguageModelV4;
30
30
 
31
31
  /**
32
32
  * Creates a model for transcription.
33
33
  */
34
- transcription(modelId: GroqTranscriptionModelId): TranscriptionModelV3;
34
+ transcription(modelId: GroqTranscriptionModelId): TranscriptionModelV4;
35
35
 
36
36
  /**
37
37
  * Tools provided by Groq.
@@ -118,7 +118,7 @@ export function createGroq(options: GroqProviderSettings = {}): GroqProvider {
118
118
  return createLanguageModel(modelId);
119
119
  };
120
120
 
121
- provider.specificationVersion = 'v3' as const;
121
+ provider.specificationVersion = 'v4' as const;
122
122
  provider.languageModel = createLanguageModel;
123
123
  provider.chat = createChatModel;
124
124
 
@@ -1,4 +1,8 @@
1
- import { InferSchema, lazySchema, zodSchema } from '@ai-sdk/provider-utils';
1
+ import {
2
+ lazySchema,
3
+ zodSchema,
4
+ type InferSchema,
5
+ } from '@ai-sdk/provider-utils';
2
6
  import { z } from 'zod/v4';
3
7
 
4
8
  export type GroqTranscriptionModelId =
@@ -1,4 +1,4 @@
1
- import { TranscriptionModelV3, SharedV3Warning } from '@ai-sdk/provider';
1
+ import type { TranscriptionModelV4, SharedV4Warning } from '@ai-sdk/provider';
2
2
  import {
3
3
  combineHeaders,
4
4
  convertBase64ToUint8Array,
@@ -6,15 +6,18 @@ import {
6
6
  mediaTypeToExtension,
7
7
  parseProviderOptions,
8
8
  postFormDataToApi,
9
+ serializeModelOptions,
10
+ WORKFLOW_SERIALIZE,
11
+ WORKFLOW_DESERIALIZE,
9
12
  } from '@ai-sdk/provider-utils';
10
13
  import { z } from 'zod/v4';
11
- import { GroqConfig } from './groq-config';
14
+ import type { GroqConfig } from './groq-config';
12
15
  import { groqFailedResponseHandler } from './groq-error';
13
16
  import {
14
- GroqTranscriptionModelId,
15
17
  groqTranscriptionModelOptions,
16
- } from './groq-transcription-options';
17
- import { GroqTranscriptionAPITypes } from './groq-api-types';
18
+ type GroqTranscriptionModelId,
19
+ } from './groq-transcription-model-options';
20
+ import type { GroqTranscriptionAPITypes } from './groq-api-types';
18
21
 
19
22
  interface GroqTranscriptionModelConfig extends GroqConfig {
20
23
  _internal?: {
@@ -22,13 +25,27 @@ interface GroqTranscriptionModelConfig extends GroqConfig {
22
25
  };
23
26
  }
24
27
 
25
- export class GroqTranscriptionModel implements TranscriptionModelV3 {
26
- readonly specificationVersion = 'v3';
28
+ export class GroqTranscriptionModel implements TranscriptionModelV4 {
29
+ readonly specificationVersion = 'v4';
27
30
 
28
31
  get provider(): string {
29
32
  return this.config.provider;
30
33
  }
31
34
 
35
+ static [WORKFLOW_SERIALIZE](model: GroqTranscriptionModel) {
36
+ return serializeModelOptions({
37
+ modelId: model.modelId,
38
+ config: model.config,
39
+ });
40
+ }
41
+
42
+ static [WORKFLOW_DESERIALIZE](options: {
43
+ modelId: GroqTranscriptionModelId;
44
+ config: GroqTranscriptionModelConfig;
45
+ }) {
46
+ return new GroqTranscriptionModel(options.modelId, options.config);
47
+ }
48
+
32
49
  constructor(
33
50
  readonly modelId: GroqTranscriptionModelId,
34
51
  private readonly config: GroqTranscriptionModelConfig,
@@ -38,8 +55,8 @@ export class GroqTranscriptionModel implements TranscriptionModelV3 {
38
55
  audio,
39
56
  mediaType,
40
57
  providerOptions,
41
- }: Parameters<TranscriptionModelV3['doGenerate']>[0]) {
42
- const warnings: SharedV3Warning[] = [];
58
+ }: Parameters<TranscriptionModelV4['doGenerate']>[0]) {
59
+ const warnings: SharedV4Warning[] = [];
43
60
 
44
61
  // Parse provider options
45
62
  const groqOptions = await parseProviderOptions({
@@ -101,8 +118,8 @@ export class GroqTranscriptionModel implements TranscriptionModelV3 {
101
118
  }
102
119
 
103
120
  async doGenerate(
104
- options: Parameters<TranscriptionModelV3['doGenerate']>[0],
105
- ): Promise<Awaited<ReturnType<TranscriptionModelV3['doGenerate']>>> {
121
+ options: Parameters<TranscriptionModelV4['doGenerate']>[0],
122
+ ): Promise<Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>> {
106
123
  const currentDate = this.config._internal?.currentDate?.() ?? new Date();
107
124
  const { formData, warnings } = await this.getArgs(options);
108
125
 
@@ -115,7 +132,7 @@ export class GroqTranscriptionModel implements TranscriptionModelV3 {
115
132
  path: '/audio/transcriptions',
116
133
  modelId: this.modelId,
117
134
  }),
118
- headers: combineHeaders(this.config.headers(), options.headers),
135
+ headers: combineHeaders(this.config.headers?.(), options.headers),
119
136
  formData,
120
137
  failedResponseHandler: groqFailedResponseHandler,
121
138
  successfulResponseHandler: createJsonResponseHandler(
package/src/index.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  export { createGroq, groq } from './groq-provider';
2
2
  export type { GroqProvider, GroqProviderSettings } from './groq-provider';
3
3
  export type {
4
- GroqLanguageModelOptions,
5
- /** @deprecated Use `GroqLanguageModelOptions` instead. */
6
- GroqLanguageModelOptions as GroqProviderOptions,
7
- } from './groq-chat-options';
8
- export type { GroqTranscriptionModelOptions } from './groq-transcription-options';
4
+ GroqLanguageModelChatOptions,
5
+ /** @deprecated Use `GroqLanguageModelChatOptions` instead. */
6
+ GroqLanguageModelChatOptions as GroqLanguageModelOptions,
7
+ /** @deprecated Use `GroqLanguageModelChatOptions` instead. */
8
+ GroqLanguageModelChatOptions as GroqProviderOptions,
9
+ } from './groq-chat-language-model-options';
10
+ export type { GroqTranscriptionModelOptions } from './groq-transcription-model-options';
9
11
  export { browserSearch } from './tool/browser-search';
10
12
  export { VERSION } from './version';
@@ -1,8 +1,8 @@
1
- import { LanguageModelV3FinishReason } from '@ai-sdk/provider';
1
+ import type { LanguageModelV4FinishReason } from '@ai-sdk/provider';
2
2
 
3
3
  export function mapGroqFinishReason(
4
4
  finishReason: string | null | undefined,
5
- ): LanguageModelV3FinishReason['unified'] {
5
+ ): LanguageModelV4FinishReason['unified'] {
6
6
  switch (finishReason) {
7
7
  case 'stop':
8
8
  return 'stop';
@@ -1,4 +1,8 @@
1
- import { createProviderToolFactory } from '@ai-sdk/provider-utils';
1
+ import {
2
+ createProviderExecutedToolFactory,
3
+ lazySchema,
4
+ zodSchema,
5
+ } from '@ai-sdk/provider-utils';
2
6
  import { z } from 'zod/v4';
3
7
 
4
8
  /**
@@ -13,16 +17,20 @@ import { z } from 'zod/v4';
13
17
  *
14
18
  * @see https://console.groq.com/docs/browser-search
15
19
  */
16
- export const browserSearch = createProviderToolFactory<
20
+ export const browserSearch = createProviderExecutedToolFactory<
17
21
  {
18
22
  // Browser search doesn't take input parameters - it's controlled by the prompt
19
23
  // The tool is activated automatically when included in the tools array
20
24
  },
25
+ {
26
+ // Browser search doesn't have any output parameters
27
+ },
21
28
  {
22
29
  // No configuration options needed - the tool works automatically
23
30
  // when included in the tools array for supported models
24
31
  }
25
32
  >({
26
33
  id: 'groq.browser_search',
27
- inputSchema: z.object({}),
34
+ inputSchema: lazySchema(() => zodSchema(z.object({}))),
35
+ outputSchema: lazySchema(() => zodSchema(z.object({}))),
28
36
  });