@ai-sdk/groq 0.0.0-013d7476-20250808163325 → 0.0.0-fd764a60-20260114143805

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # AI SDK - Groq Provider
2
2
 
3
3
  The **[Groq provider](https://ai-sdk.dev/providers/ai-sdk-providers/groq)** for the [AI SDK](https://ai-sdk.dev/docs)
4
- contains language model support for the Groq chat and completion APIs and embedding model support for the Groq embeddings API.
4
+ contains language model support for the Groq chat and completion APIs, transcription support, and browser search tool.
5
5
 
6
6
  ## Setup
7
7
 
@@ -19,7 +19,95 @@ You can import the default provider instance `groq` from `@ai-sdk/groq`:
19
19
  import { groq } from '@ai-sdk/groq';
20
20
  ```
21
21
 
22
- ## Example
22
+ ## Browser Search Tool
23
+
24
+ The Groq provider includes a browser search tool that provides interactive web browsing capabilities. Unlike traditional web search, browser search navigates websites interactively, providing more detailed and comprehensive results.
25
+
26
+ ### Supported Models
27
+
28
+ Browser search is only available for these models:
29
+
30
+ - `openai/gpt-oss-20b`
31
+ - `openai/gpt-oss-120b`
32
+
33
+ ⚠️ **Important**: Using browser search with other models will generate a warning and the tool will be ignored.
34
+
35
+ ### Basic Usage
36
+
37
+ ```ts
38
+ import { groq } from '@ai-sdk/groq';
39
+ import { generateText } from 'ai';
40
+
41
+ const result = await generateText({
42
+ model: groq('openai/gpt-oss-120b'), // Must use supported model
43
+ prompt:
44
+ 'What are the latest developments in AI? Please search for recent news.',
45
+ tools: {
46
+ browser_search: groq.tools.browserSearch({}),
47
+ },
48
+ toolChoice: 'required', // Ensure the tool is used
49
+ });
50
+
51
+ console.log(result.text);
52
+ ```
53
+
54
+ ### Streaming Example
55
+
56
+ ```ts
57
+ import { groq } from '@ai-sdk/groq';
58
+ import { streamText } from 'ai';
59
+
60
+ const result = streamText({
61
+ model: groq('openai/gpt-oss-120b'),
62
+ prompt: 'Search for the latest tech news and summarize it.',
63
+ tools: {
64
+ browser_search: groq.tools.browserSearch({}),
65
+ },
66
+ toolChoice: 'required',
67
+ });
68
+
69
+ for await (const delta of result.fullStream) {
70
+ if (delta.type === 'text-delta') {
71
+ process.stdout.write(delta.text);
72
+ }
73
+ }
74
+ ```
75
+
76
+ ### Key Features
77
+
78
+ - **Interactive Browsing**: Navigates websites like a human user
79
+ - **Comprehensive Results**: More detailed than traditional search snippets
80
+ - **Server-side Execution**: Runs on Groq's infrastructure, no setup required
81
+ - **Powered by Exa**: Uses Exa search engine for optimal results
82
+ - **Currently Free**: Available at no additional charge during beta
83
+
84
+ ### Best Practices
85
+
86
+ - Use `toolChoice: 'required'` to ensure the browser search is activated
87
+ - Supported models only: `openai/gpt-oss-20b` and `openai/gpt-oss-120b`
88
+ - The tool works automatically - no configuration parameters needed
89
+ - Server-side execution means no additional API keys or setup required
90
+
91
+ ### Model Validation
92
+
93
+ The provider automatically validates model compatibility:
94
+
95
+ ```ts
96
+ // ✅ Supported - will work
97
+ const result = await generateText({
98
+ model: groq('openai/gpt-oss-120b'),
99
+ tools: { browser_search: groq.tools.browserSearch({}) },
100
+ });
101
+
102
+ // ❌ Unsupported - will show warning and ignore tool
103
+ const result = await generateText({
104
+ model: groq('gemma2-9b-it'),
105
+ tools: { browser_search: groq.tools.browserSearch({}) },
106
+ });
107
+ // Warning: "Browser search is only supported on models: openai/gpt-oss-20b, openai/gpt-oss-120b"
108
+ ```
109
+
110
+ ## Basic Text Generation
23
111
 
24
112
  ```ts
25
113
  import { groq } from '@ai-sdk/groq';
@@ -34,3 +122,5 @@ const { text } = await generateText({
34
122
  ## Documentation
35
123
 
36
124
  Please check out the **[Groq provider documentation](https://ai-sdk.dev/providers/ai-sdk-providers/groq)** for more information.
125
+
126
+ For browser search details, see the **[Groq Browser Search Documentation](https://console.groq.com/docs/browser-search)**.
package/dist/index.d.mts CHANGED
@@ -1,36 +1,61 @@
1
- import { ProviderV2, LanguageModelV2, TranscriptionModelV2 } from '@ai-sdk/provider';
1
+ import { ProviderV3, LanguageModelV3, TranscriptionModelV3 } from '@ai-sdk/provider';
2
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
2
3
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
4
  import { z } from 'zod/v4';
4
5
 
5
- type GroqChatModelId = 'gemma2-9b-it' | 'llama-3.1-8b-instant' | 'llama-3.3-70b-versatile' | 'meta-llama/llama-guard-4-12b' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'deepseek-r1-distill-llama-70b' | 'meta-llama/llama-4-maverick-17b-128e-instruct' | 'meta-llama/llama-4-scout-17b-16e-instruct' | 'meta-llama/llama-prompt-guard-2-22m' | 'meta-llama/llama-prompt-guard-2-86m' | 'mistral-saba-24b' | 'moonshotai/kimi-k2-instruct' | 'qwen/qwen3-32b' | 'llama-guard-3-8b' | 'llama3-70b-8192' | 'llama3-8b-8192' | 'mixtral-8x7b-32768' | 'qwen-qwq-32b' | 'qwen-2.5-32b' | 'deepseek-r1-distill-qwen-32b' | (string & {});
6
+ type GroqChatModelId = 'gemma2-9b-it' | 'llama-3.1-8b-instant' | 'llama-3.3-70b-versatile' | 'meta-llama/llama-guard-4-12b' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'deepseek-r1-distill-llama-70b' | 'meta-llama/llama-4-maverick-17b-128e-instruct' | 'meta-llama/llama-4-scout-17b-16e-instruct' | 'meta-llama/llama-prompt-guard-2-22m' | 'meta-llama/llama-prompt-guard-2-86m' | 'moonshotai/kimi-k2-instruct-0905' | 'qwen/qwen3-32b' | 'llama-guard-3-8b' | 'llama3-70b-8192' | 'llama3-8b-8192' | 'mixtral-8x7b-32768' | 'qwen-qwq-32b' | 'qwen-2.5-32b' | 'deepseek-r1-distill-qwen-32b' | (string & {});
6
7
  declare const groqProviderOptions: z.ZodObject<{
7
8
  reasoningFormat: z.ZodOptional<z.ZodEnum<{
8
9
  parsed: "parsed";
9
10
  raw: "raw";
10
11
  hidden: "hidden";
11
12
  }>>;
12
- reasoningEffort: z.ZodOptional<z.ZodString>;
13
+ reasoningEffort: z.ZodOptional<z.ZodEnum<{
14
+ none: "none";
15
+ default: "default";
16
+ low: "low";
17
+ medium: "medium";
18
+ high: "high";
19
+ }>>;
13
20
  parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
14
21
  user: z.ZodOptional<z.ZodString>;
15
22
  structuredOutputs: z.ZodOptional<z.ZodBoolean>;
23
+ strictJsonSchema: z.ZodOptional<z.ZodBoolean>;
24
+ serviceTier: z.ZodOptional<z.ZodEnum<{
25
+ on_demand: "on_demand";
26
+ flex: "flex";
27
+ auto: "auto";
28
+ }>>;
16
29
  }, z.core.$strip>;
17
30
  type GroqProviderOptions = z.infer<typeof groqProviderOptions>;
18
31
 
19
- type GroqTranscriptionModelId = 'whisper-large-v3-turbo' | 'distil-whisper-large-v3-en' | 'whisper-large-v3' | (string & {});
32
+ type GroqTranscriptionModelId = 'whisper-large-v3-turbo' | 'whisper-large-v3' | (string & {});
33
+
34
+ declare const groqTools: {
35
+ browserSearch: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}>;
36
+ };
20
37
 
21
- interface GroqProvider extends ProviderV2 {
38
+ interface GroqProvider extends ProviderV3 {
22
39
  /**
23
40
  Creates a model for text generation.
24
41
  */
25
- (modelId: GroqChatModelId): LanguageModelV2;
42
+ (modelId: GroqChatModelId): LanguageModelV3;
26
43
  /**
27
44
  Creates an Groq chat model for text generation.
28
45
  */
29
- languageModel(modelId: GroqChatModelId): LanguageModelV2;
46
+ languageModel(modelId: GroqChatModelId): LanguageModelV3;
30
47
  /**
31
48
  Creates a model for transcription.
32
49
  */
33
- transcription(modelId: GroqTranscriptionModelId): TranscriptionModelV2;
50
+ transcription(modelId: GroqTranscriptionModelId): TranscriptionModelV3;
51
+ /**
52
+ * Tools provided by Groq.
53
+ */
54
+ tools: typeof groqTools;
55
+ /**
56
+ * @deprecated Use `embeddingModel` instead.
57
+ */
58
+ textEmbeddingModel(modelId: string): never;
34
59
  }
35
60
  interface GroqProviderSettings {
36
61
  /**
@@ -60,4 +85,20 @@ Default Groq provider instance.
60
85
  */
61
86
  declare const groq: GroqProvider;
62
87
 
63
- export { type GroqProvider, type GroqProviderOptions, type GroqProviderSettings, createGroq, groq };
88
+ /**
89
+ * Browser search tool for Groq models.
90
+ *
91
+ * Provides interactive browser search capabilities that go beyond traditional web search
92
+ * by navigating websites interactively and providing more detailed results.
93
+ *
94
+ * Currently supported on:
95
+ * - openai/gpt-oss-20b
96
+ * - openai/gpt-oss-120b
97
+ *
98
+ * @see https://console.groq.com/docs/browser-search
99
+ */
100
+ declare const browserSearch: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}>;
101
+
102
+ declare const VERSION: string;
103
+
104
+ export { type GroqProvider, type GroqProviderOptions, type GroqProviderSettings, VERSION, browserSearch, createGroq, groq };
package/dist/index.d.ts CHANGED
@@ -1,36 +1,61 @@
1
- import { ProviderV2, LanguageModelV2, TranscriptionModelV2 } from '@ai-sdk/provider';
1
+ import { ProviderV3, LanguageModelV3, TranscriptionModelV3 } from '@ai-sdk/provider';
2
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
2
3
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
4
  import { z } from 'zod/v4';
4
5
 
5
- type GroqChatModelId = 'gemma2-9b-it' | 'llama-3.1-8b-instant' | 'llama-3.3-70b-versatile' | 'meta-llama/llama-guard-4-12b' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'deepseek-r1-distill-llama-70b' | 'meta-llama/llama-4-maverick-17b-128e-instruct' | 'meta-llama/llama-4-scout-17b-16e-instruct' | 'meta-llama/llama-prompt-guard-2-22m' | 'meta-llama/llama-prompt-guard-2-86m' | 'mistral-saba-24b' | 'moonshotai/kimi-k2-instruct' | 'qwen/qwen3-32b' | 'llama-guard-3-8b' | 'llama3-70b-8192' | 'llama3-8b-8192' | 'mixtral-8x7b-32768' | 'qwen-qwq-32b' | 'qwen-2.5-32b' | 'deepseek-r1-distill-qwen-32b' | (string & {});
6
+ type GroqChatModelId = 'gemma2-9b-it' | 'llama-3.1-8b-instant' | 'llama-3.3-70b-versatile' | 'meta-llama/llama-guard-4-12b' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'deepseek-r1-distill-llama-70b' | 'meta-llama/llama-4-maverick-17b-128e-instruct' | 'meta-llama/llama-4-scout-17b-16e-instruct' | 'meta-llama/llama-prompt-guard-2-22m' | 'meta-llama/llama-prompt-guard-2-86m' | 'moonshotai/kimi-k2-instruct-0905' | 'qwen/qwen3-32b' | 'llama-guard-3-8b' | 'llama3-70b-8192' | 'llama3-8b-8192' | 'mixtral-8x7b-32768' | 'qwen-qwq-32b' | 'qwen-2.5-32b' | 'deepseek-r1-distill-qwen-32b' | (string & {});
6
7
  declare const groqProviderOptions: z.ZodObject<{
7
8
  reasoningFormat: z.ZodOptional<z.ZodEnum<{
8
9
  parsed: "parsed";
9
10
  raw: "raw";
10
11
  hidden: "hidden";
11
12
  }>>;
12
- reasoningEffort: z.ZodOptional<z.ZodString>;
13
+ reasoningEffort: z.ZodOptional<z.ZodEnum<{
14
+ none: "none";
15
+ default: "default";
16
+ low: "low";
17
+ medium: "medium";
18
+ high: "high";
19
+ }>>;
13
20
  parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
14
21
  user: z.ZodOptional<z.ZodString>;
15
22
  structuredOutputs: z.ZodOptional<z.ZodBoolean>;
23
+ strictJsonSchema: z.ZodOptional<z.ZodBoolean>;
24
+ serviceTier: z.ZodOptional<z.ZodEnum<{
25
+ on_demand: "on_demand";
26
+ flex: "flex";
27
+ auto: "auto";
28
+ }>>;
16
29
  }, z.core.$strip>;
17
30
  type GroqProviderOptions = z.infer<typeof groqProviderOptions>;
18
31
 
19
- type GroqTranscriptionModelId = 'whisper-large-v3-turbo' | 'distil-whisper-large-v3-en' | 'whisper-large-v3' | (string & {});
32
+ type GroqTranscriptionModelId = 'whisper-large-v3-turbo' | 'whisper-large-v3' | (string & {});
33
+
34
+ declare const groqTools: {
35
+ browserSearch: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}>;
36
+ };
20
37
 
21
- interface GroqProvider extends ProviderV2 {
38
+ interface GroqProvider extends ProviderV3 {
22
39
  /**
23
40
  Creates a model for text generation.
24
41
  */
25
- (modelId: GroqChatModelId): LanguageModelV2;
42
+ (modelId: GroqChatModelId): LanguageModelV3;
26
43
  /**
27
44
  Creates an Groq chat model for text generation.
28
45
  */
29
- languageModel(modelId: GroqChatModelId): LanguageModelV2;
46
+ languageModel(modelId: GroqChatModelId): LanguageModelV3;
30
47
  /**
31
48
  Creates a model for transcription.
32
49
  */
33
- transcription(modelId: GroqTranscriptionModelId): TranscriptionModelV2;
50
+ transcription(modelId: GroqTranscriptionModelId): TranscriptionModelV3;
51
+ /**
52
+ * Tools provided by Groq.
53
+ */
54
+ tools: typeof groqTools;
55
+ /**
56
+ * @deprecated Use `embeddingModel` instead.
57
+ */
58
+ textEmbeddingModel(modelId: string): never;
34
59
  }
35
60
  interface GroqProviderSettings {
36
61
  /**
@@ -60,4 +85,20 @@ Default Groq provider instance.
60
85
  */
61
86
  declare const groq: GroqProvider;
62
87
 
63
- export { type GroqProvider, type GroqProviderOptions, type GroqProviderSettings, createGroq, groq };
88
+ /**
89
+ * Browser search tool for Groq models.
90
+ *
91
+ * Provides interactive browser search capabilities that go beyond traditional web search
92
+ * by navigating websites interactively and providing more detailed results.
93
+ *
94
+ * Currently supported on:
95
+ * - openai/gpt-oss-20b
96
+ * - openai/gpt-oss-120b
97
+ *
98
+ * @see https://console.groq.com/docs/browser-search
99
+ */
100
+ declare const browserSearch: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}>;
101
+
102
+ declare const VERSION: string;
103
+
104
+ export { type GroqProvider, type GroqProviderOptions, type GroqProviderSettings, VERSION, browserSearch, createGroq, groq };