Add Groq provider support to AI SDK applications with language models, transcription, and browser search capabilities. Includes setup, configuration, and usage examples for text generation and interactive web browsing.
Integrate Groq provider into AI SDK applications for language model support, transcription, and browser search capabilities.
This skill helps you set up and use the Groq provider for the AI SDK, which provides:
1. Install the Groq provider package:
```bash
npm i @ai-sdk/groq
```
2. Optionally add the AI SDK skill for coding agents:
```bash
npx skills add vercel/ai
```
3. Import the Groq provider in your code:
```ts
import { groq } from '@ai-sdk/groq';
import { generateText } from 'ai';
```
Use Groq models for standard text generation:
```ts
import { groq } from '@ai-sdk/groq';
import { generateText } from 'ai';
const { text } = await generateText({
model: groq('gemma2-9b-it'),
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});
console.log(text);
```
The browser search tool provides interactive web browsing capabilities (more comprehensive than traditional search).
Browser search **only** works with:
Using other models will generate a warning and the tool will be ignored.
```ts
import { groq } from '@ai-sdk/groq';
import { generateText } from 'ai';
const result = await generateText({
model: groq('openai/gpt-oss-120b'), // Must use supported model
prompt: 'What are the latest developments in AI? Please search for recent news.',
tools: {
browser_search: groq.tools.browserSearch({}),
},
toolChoice: 'required', // Ensures the tool is used
});
console.log(result.text);
```
```ts
import { groq } from '@ai-sdk/groq';
import { streamText } from 'ai';
const result = streamText({
model: groq('openai/gpt-oss-120b'),
prompt: 'Search for the latest tech news and summarize it.',
tools: {
browser_search: groq.tools.browserSearch({}),
},
toolChoice: 'required',
});
for await (const delta of result.fullStream) {
if (delta.type === 'text-delta') {
process.stdout.write(delta.text);
}
}
```
When adding Groq provider support to a project:
1. **Install the package**: Add `@ai-sdk/groq` to dependencies
2. **Import the provider**: Use `import { groq } from '@ai-sdk/groq'`
3. **Choose appropriate model**:
- For standard text generation: `gemma2-9b-it` or other available models
- For browser search: `openai/gpt-oss-20b` or `openai/gpt-oss-120b` only
4. **Configure tools** (if using browser search):
- Add `browser_search: groq.tools.browserSearch({})` to tools object
- Set `toolChoice: 'required'` to ensure tool activation
5. **Handle responses**: Process text output or stream results
The provider automatically validates browser search compatibility:
```ts
// ✅ Supported - will work
const result = await generateText({
model: groq('openai/gpt-oss-120b'),
tools: { browser_search: groq.tools.browserSearch({}) },
});
// ❌ Unsupported - will show warning and ignore tool
const result = await generateText({
model: groq('gemma2-9b-it'),
tools: { browser_search: groq.tools.browserSearch({}) },
});
// Warning: "Browser search is only supported on models: openai/gpt-oss-20b, openai/gpt-oss-120b"
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/groq-ai-sdk-integration/raw