@ai-sdk/groq 0.0.0-013d7476-20250808163325

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/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Vercel, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # AI SDK - Groq Provider
2
+
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.
5
+
6
+ ## Setup
7
+
8
+ The Groq provider is available in the `@ai-sdk/groq` module. You can install it with
9
+
10
+ ```bash
11
+ npm i @ai-sdk/groq
12
+ ```
13
+
14
+ ## Provider Instance
15
+
16
+ You can import the default provider instance `groq` from `@ai-sdk/groq`:
17
+
18
+ ```ts
19
+ import { groq } from '@ai-sdk/groq';
20
+ ```
21
+
22
+ ## Example
23
+
24
+ ```ts
25
+ import { groq } from '@ai-sdk/groq';
26
+ import { generateText } from 'ai';
27
+
28
+ const { text } = await generateText({
29
+ model: groq('gemma2-9b-it'),
30
+ prompt: 'Write a vegetarian lasagna recipe for 4 people.',
31
+ });
32
+ ```
33
+
34
+ ## Documentation
35
+
36
+ Please check out the **[Groq provider documentation](https://ai-sdk.dev/providers/ai-sdk-providers/groq)** for more information.
@@ -0,0 +1,63 @@
1
+ import { ProviderV2, LanguageModelV2, TranscriptionModelV2 } from '@ai-sdk/provider';
2
+ import { FetchFunction } from '@ai-sdk/provider-utils';
3
+ import { z } from 'zod/v4';
4
+
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
+ declare const groqProviderOptions: z.ZodObject<{
7
+ reasoningFormat: z.ZodOptional<z.ZodEnum<{
8
+ parsed: "parsed";
9
+ raw: "raw";
10
+ hidden: "hidden";
11
+ }>>;
12
+ reasoningEffort: z.ZodOptional<z.ZodString>;
13
+ parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
14
+ user: z.ZodOptional<z.ZodString>;
15
+ structuredOutputs: z.ZodOptional<z.ZodBoolean>;
16
+ }, z.core.$strip>;
17
+ type GroqProviderOptions = z.infer<typeof groqProviderOptions>;
18
+
19
+ type GroqTranscriptionModelId = 'whisper-large-v3-turbo' | 'distil-whisper-large-v3-en' | 'whisper-large-v3' | (string & {});
20
+
21
+ interface GroqProvider extends ProviderV2 {
22
+ /**
23
+ Creates a model for text generation.
24
+ */
25
+ (modelId: GroqChatModelId): LanguageModelV2;
26
+ /**
27
+ Creates an Groq chat model for text generation.
28
+ */
29
+ languageModel(modelId: GroqChatModelId): LanguageModelV2;
30
+ /**
31
+ Creates a model for transcription.
32
+ */
33
+ transcription(modelId: GroqTranscriptionModelId): TranscriptionModelV2;
34
+ }
35
+ interface GroqProviderSettings {
36
+ /**
37
+ Base URL for the Groq API calls.
38
+ */
39
+ baseURL?: string;
40
+ /**
41
+ API key for authenticating requests.
42
+ */
43
+ apiKey?: string;
44
+ /**
45
+ Custom headers to include in the requests.
46
+ */
47
+ headers?: Record<string, string>;
48
+ /**
49
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
50
+ or to provide a custom fetch implementation for e.g. testing.
51
+ */
52
+ fetch?: FetchFunction;
53
+ }
54
+ /**
55
+ Create an Groq provider instance.
56
+ */
57
+ declare function createGroq(options?: GroqProviderSettings): GroqProvider;
58
+ /**
59
+ Default Groq provider instance.
60
+ */
61
+ declare const groq: GroqProvider;
62
+
63
+ export { type GroqProvider, type GroqProviderOptions, type GroqProviderSettings, createGroq, groq };
@@ -0,0 +1,63 @@
1
+ import { ProviderV2, LanguageModelV2, TranscriptionModelV2 } from '@ai-sdk/provider';
2
+ import { FetchFunction } from '@ai-sdk/provider-utils';
3
+ import { z } from 'zod/v4';
4
+
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
+ declare const groqProviderOptions: z.ZodObject<{
7
+ reasoningFormat: z.ZodOptional<z.ZodEnum<{
8
+ parsed: "parsed";
9
+ raw: "raw";
10
+ hidden: "hidden";
11
+ }>>;
12
+ reasoningEffort: z.ZodOptional<z.ZodString>;
13
+ parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
14
+ user: z.ZodOptional<z.ZodString>;
15
+ structuredOutputs: z.ZodOptional<z.ZodBoolean>;
16
+ }, z.core.$strip>;
17
+ type GroqProviderOptions = z.infer<typeof groqProviderOptions>;
18
+
19
+ type GroqTranscriptionModelId = 'whisper-large-v3-turbo' | 'distil-whisper-large-v3-en' | 'whisper-large-v3' | (string & {});
20
+
21
+ interface GroqProvider extends ProviderV2 {
22
+ /**
23
+ Creates a model for text generation.
24
+ */
25
+ (modelId: GroqChatModelId): LanguageModelV2;
26
+ /**
27
+ Creates an Groq chat model for text generation.
28
+ */
29
+ languageModel(modelId: GroqChatModelId): LanguageModelV2;
30
+ /**
31
+ Creates a model for transcription.
32
+ */
33
+ transcription(modelId: GroqTranscriptionModelId): TranscriptionModelV2;
34
+ }
35
+ interface GroqProviderSettings {
36
+ /**
37
+ Base URL for the Groq API calls.
38
+ */
39
+ baseURL?: string;
40
+ /**
41
+ API key for authenticating requests.
42
+ */
43
+ apiKey?: string;
44
+ /**
45
+ Custom headers to include in the requests.
46
+ */
47
+ headers?: Record<string, string>;
48
+ /**
49
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
50
+ or to provide a custom fetch implementation for e.g. testing.
51
+ */
52
+ fetch?: FetchFunction;
53
+ }
54
+ /**
55
+ Create an Groq provider instance.
56
+ */
57
+ declare function createGroq(options?: GroqProviderSettings): GroqProvider;
58
+ /**
59
+ Default Groq provider instance.
60
+ */
61
+ declare const groq: GroqProvider;
62
+
63
+ export { type GroqProvider, type GroqProviderOptions, type GroqProviderSettings, createGroq, groq };