AI SDK ProvidersGroq
Groq Provider
Groq is supported via OpenAI API compatibility - the OpenAI provider is used in the examples below.
The Groq provider contains language model support for the Groq API.
It creates language model objects that can be used with the generateText
, streamText
, and generateObject
.
Setup
The Groq provider is available via the @ai-sdk/openai
module as it is compatible with the OpenAI API.
You can install it with
pnpm install @ai-sdk/openai
Provider Instance
To use Groq, you can create a custom provider instance with the createOpenAI
function from @ai-sdk/openai
:
import { createOpenAI } from '@ai-sdk/openai';
const groq = createOpenAI({ baseURL: 'https://api.groq.com/openai/v1', apiKey: process.env.GROQ_API_KEY,});
Models
You can create Groq models using a provider instance.
The first argument is the model id, e.g. llama3-8b-8192
.
const model = groq('llama3-8b-8192');
Model Capabilities
Model | Image Input | Object Generation | Tool Usage | Tool Streaming |
---|---|---|---|---|
llama3-8b-8192 | ||||
llama3-70b-8192 | ||||
mixtral-8x7b-32768 | ||||
gemma-7b-it |