Back to AI Framework Overview | All Providers
MemberJunction AI provider for Groq's ultra-fast inference platform. Extends the OpenAI provider to work with Groq's OpenAI-compatible API, providing access to LLM inference powered by Groq's custom Language Processing Units (LPUs).
graph TD
A["GroqLLM
(Provider)"] -->|extends| B["OpenAILLM
(@memberjunction/ai-openai)"]
B -->|extends| C["BaseLLM
(@memberjunction/ai)"]
A -->|overrides base URL| D["Groq API
(api.groq.com/openai/v1)"]
D -->|runs on| E["Groq LPU
Inference Engine"]
C -->|registered via| F["@RegisterClass"]
style A fill:#7c5295,stroke:#563a6b,color:#fff
style B fill:#2d6a9f,stroke:#1a4971,color:#fff
style C fill:#2d6a9f,stroke:#1a4971,color:#fff
style D fill:#2d8659,stroke:#1a5c3a,color:#fff
style E fill:#b8762f,stroke:#8a5722,color:#fff
style F fill:#b8762f,stroke:#8a5722,color:#fff
npm install @memberjunction/ai-groq
import { GroqLLM } from "@memberjunction/ai-groq";
const llm = new GroqLLM("your-groq-api-key");
const result = await llm.ChatCompletion({
model: "llama-3.3-70b-versatile",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Explain neural networks." },
],
temperature: 0.7,
maxOutputTokens: 1000,
});
if (result.success) {
console.log(result.data.choices[0].message.content);
}
const result = await llm.ChatCompletion({
model: "llama-3.3-70b-versatile",
messages: [{ role: "user", content: "Write a haiku about speed." }],
streaming: true,
streamingCallbacks: {
OnContent: (content) => process.stdout.write(content),
OnComplete: () => console.log("\nDone!"),
},
});
GroqLLM is a thin subclass of OpenAILLM that redirects API calls to Groq's endpoint at https://api.groq.com/openai/v1. Since Groq implements an OpenAI-compatible API, all chat, streaming, and parameter handling logic is inherited from the OpenAI provider.
All parameters supported by the OpenAI provider are available, including temperature, maxOutputTokens, topP, frequencyPenalty, presencePenalty, seed, stopSequences, and responseFormat.
Additionally, assistantPrefill is supported — Groq natively supports prefilling the assistant's response to guide output format. See the Prefill & Stop Sequences Guide for details.
Registered as GroqLLM via @RegisterClass(BaseLLM, 'GroqLLM').
@memberjunction/ai - Core AI abstractions@memberjunction/ai-openai - OpenAI provider (parent class)@memberjunction/global - Class registration