Synthèse automatique
Fournit des exemples et bonnes pratiques pour intégrer l’API Groq, orientée inférence LLM à faible latence, avec chat, streaming, JSON structuré et appels d’outils en TypeScript.
Points forts
- Montre un client TypeScript compatible OpenAI pour les appels classiques et le streaming destiné aux interfaces temps réel.
- Couvre le mode JSON et le function calling avec des exemples directement réutilisables.
- Met l’accent sur des cas où la latence compte : chatbots, complétion de code et réponses en flux.
Limites
- Se concentre sur TypeScript et le SDK groq-sdk ; peu d’indications pour Python ou d’autres langages.
- Ne détaille pas la gestion des erreurs, des quotas, des retries ou des coûts.
- L’exemple de tool calling est tronqué dans le document fourni, donc certains extraits ne sont pas complets.
À utiliser lorsqu’on veut ajouter rapidement une intégration Groq à une application TypeScript nécessitant des réponses LLM rapides ou en streaming.
À éviter si le besoin porte sur un autre fournisseur LLM, Python, ou une architecture d’inférence auto-hébergée non couverte par le skill.
Analyse de sécurité
SûrThe skill is purely documentation and TypeScript code examples for integrating the Groq API (chat completions, streaming, JSON mode, tool calling, Whisper transcription). It reads the API key from process.env.GROQ_API_KEY and makes ordinary SDK calls; there is no shell execution, filesystem destruction, network exfiltration, obfuscated payload, or safety-disabling instruction. Execution risk is minimal.
Aucun point d'attention détecté
Comment cette analyse est faiteExemples
Using the Groq skill, write a TypeScript function that streams a Groq chat completion to a React component with llama-3.3-70b-versatile and calls onChunk for each token.Create a Groq TypeScript helper using JSON mode to extract people, organizations, locations, and dates from text, with temperature 0.Show how to call Groq's chat completions API with two tools, get_weather and search_web, and handle the returned tool calls.name: groq description: Expert guidance for Groq, the LLM inference platform that provides the fastest token generation speeds available, powered by custom LPU (Language Processing Unit) hardware. Helps developers integrate Groq's API for real-time AI applications where latency matters — chatbots, code completion, and streaming responses. license: Apache-2.0 compatibility: No special requirements metadata: author: terminal-skills version: 1.0.0 category: data-ai tags:
- llm
- inference
- api
- fast-inference
- chat
Groq — Ultra-Fast LLM Inference
Overview
Groq, the LLM inference platform that provides the fastest token generation speeds available, powered by custom LPU (Language Processing Unit) hardware. Helps developers integrate Groq's API for real-time AI applications where latency matters — chatbots, code completion, and streaming responses.
Instructions
Basic Chat Completion
// src/llm/groq-client.ts — Groq API (OpenAI-compatible)
import Groq from "groq-sdk";
const groq = new Groq({
apiKey: process.env.GROQ_API_KEY!,
});
// Basic completion — fastest LLM inference available
async function chat(prompt: string): Promise<string> {
const completion = await groq.chat.completions.create({
model: "llama-3.3-70b-versatile", // Fast and capable
messages: [
{
role: "system",
content: "You are a helpful assistant. Be concise and direct.",
},
{ role: "user", content: prompt },
],
temperature: 0.7,
max_tokens: 1024,
});
return completion.choices[0].message.content ?? "";
}
// Streaming for real-time UI
async function streamChat(
prompt: string,
onChunk: (text: string) => void
): Promise<string> {
const stream = await groq.chat.completions.create({
model: "llama-3.3-70b-versatile",
messages: [{ role: "user", content: prompt }],
stream: true,
});
let fullResponse = "";
for await (const chunk of stream) {
const text = chunk.choices[0]?.delta?.content ?? "";
fullResponse += text;
onChunk(text);
}
return fullResponse;
}
Structured Output (JSON Mode)
// src/llm/structured.ts — Get structured JSON responses from Groq
async function extractEntities(text: string) {
const completion = await groq.chat.completions.create({
model: "llama-3.3-70b-versatile",
messages: [
{
role: "system",
content: `Extract entities from the text. Return JSON with this structure:
{ "people": [string], "organizations": [string], "locations": [string], "dates": [string] }`,
},
{ role: "user", content: text },
],
response_format: { type: "json_object" },
temperature: 0, // Deterministic for extraction
});
return JSON.parse(completion.choices[0].message.content!);
}
// Tool use / Function calling
async function chatWithTools(prompt: string, tools: any[]) {
const completion = await groq.chat.completions.create({
model: "llama-3.3-70b-versatile",
messages: [{ role: "user", content: prompt }],
tools: [
{
type: "function",
function: {
name: "get_weather",
description: "Get the current weather for a city",
parameters: {
type: "object",
properties: {
city: { type: "string", description: "City name" },
unit: { type: "string", enum: ["celsius", "fahrenheit"] },
},
required: ["city"],
},
},
},
{
type: "function",
function: {
name: "search_web",
description: "Search the web for information",
parameters: {
type: "object",
properties: {
query: { type: "string", description: "Search query" },
},
required: ["query"],
},
},
},
],
tool_choice: "auto",
});
const toolCalls = completion.choices[0].message.tool_calls;
if (toolCalls) {
for (const call of toolCalls) {
console.log(`Tool: ${call.function.name}, Args: ${call.function.arguments}`);
}
}
return completion;
}
Audio Transcription (Whisper)
// src/audio/transcribe.ts — Fast audio transcription via Groq
import fs from "fs";
async function transcribeAudio(filePath: string) {
const transcription = await groq.audio.transcriptions.create({
file: fs.createReadStream(filePath),
model: "whisper-large-v3-turbo", // Fastest Whisper model
language: "en", // Optional: specify language
response_format: "verbose_json", // Includes timestamps
temperature: 0,
});
return {
text: transcription.text,
segments: transcription.segments?.map((s: any) => ({
start: s.start,
end: s.end,
text: s.text,
})),
duration: transcription.duration,
};
}
// Translate audio to English
async function translateAudio(filePath: string) {
const translation = await groq.audio.translations.create({
file: fs.createReadStream(filePath),
model: "whisper-large-v3-turbo",
response_format: "text",
});
return translation;
}
Model Selection
// Available Groq models (as of early 2026)
const MODELS = {
// Llama 3.3 — best balance of speed and quality
"llama-3.3-70b-versatile": {
contextWindow: 128_000,
bestFor: "general-purpose, reasoning, coding",
speed: "~350 tok/s",
},
// Llama 3.1 — larger context, slightly slower
"llama-3.1-8b-instant": {
contextWindow: 128_000,
bestFor: "simple tasks, classification, extraction",
speed: "~750 tok/s",
},
// Mixtral — great for multilingual
"mixtral-8x7b-32768": {
contextWindow: 32_768,
bestFor: "multilingual, creative writing",
speed: "~500 tok/s",
},
// Gemma 2 — compact and efficient
"gemma2-9b-it": {
contextWindow: 8_192,
bestFor: "lightweight tasks, edge deployment comparison",
speed: "~600 tok/s",
},
};
// Choose model based on task
function selectModel(task: "chat" | "extract" | "code" | "fast"): string {
switch (task) {
case "chat": return "llama-3.3-70b-versatile";
case "extract": return "llama-3.1-8b-instant"; // Fast, good enough for extraction
case "code": return "llama-3.3-70b-versatile";
case "fast": return "llama-3.1-8b-instant"; // Lowest latency
}
}
Python Integration
# src/groq_client.py — Groq with Python (OpenAI-compatible)
from groq import Groq
client = Groq(api_key=os.environ["GROQ_API_KEY"])
# Basic completion
response = client.chat.completions.create(
model="llama-3.3-70b-versatile",
messages=[{"role": "user", "content": "Explain quantum computing in 3 sentences"}],
temperature=0.7,
max_tokens=200,
)
print(response.choices[0].message.content)
# With OpenAI SDK (drop-in replacement)
from openai import OpenAI
client = OpenAI(
api_key=os.environ["GROQ_API_KEY"],
base_url="https://api.groq.com/openai/v1",
)
# Same API, Groq's speed
Installation
# TypeScript/JavaScript
npm install groq-sdk
# Python
pip install groq
# Or use with any OpenAI-compatible SDK
# Just set base_url to https://api.groq.com/openai/v1
Examples
Example 1: Integrating Groq into an existing application
User request:
Add Groq to my Next.js app for the AI chat feature. I want streaming responses.
The agent installs the SDK, creates an API route that initializes the Groq client, configures streaming, selects an appropriate model, and wires up the frontend to consume the stream. It handles error cases and sets up proper environment variable management for the API key.
Example 2: Optimizing structured output performance
User request:
My Groq calls are slow and expensive. Help me optimize the setup.
The agent reviews the current implementation, identifies issues (wrong model selection, missing caching, inefficient prompting, no batching), and applies optimizations specific to Groq's capabilities — adjusting model parameters, adding response caching, and implementing retry logic with exponential backoff.
Guidelines
- Use Groq for latency-sensitive tasks — Chatbots, autocomplete, real-time analysis; Groq's speed is 5-10x faster than cloud GPU providers
- llama-3.1-8b for simple tasks — Don't use the 70B model for classification or extraction; 8B is faster and cheaper
- JSON mode for structured output — Use
response_format: { type: "json_object" }for reliable structured responses - Stream everything user-facing — With Groq's speed, streaming feels instant; still use it for perceived responsiveness
- Whisper for audio — Groq's Whisper is the fastest transcription API available; process audio files in seconds
- Rate limits vary by model — Check your rate limits in the Groq dashboard; 8B models have higher request limits
- OpenAI SDK compatibility — Switch from OpenAI to Groq by changing the base URL; no code changes needed
- Fallback to other providers — Groq can have capacity constraints during peak; have a fallback to OpenAI or Anthropic
Du fichier au premier essai
Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.
Consulter la source et ses fichiers annexesCe téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.
1. Télécharger le fichier
Télécharger SKILL.mdDepuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/groq-ultra-fast-llm-inference-mrzxuq9k/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.
Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.
mkdir -p '.skill-downloads/groq-ultra-fast-llm-inference-mrzxuq9k' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/groq-ultra-fast-llm-inference-mrzxuq9k/download' --output '.skill-downloads/groq-ultra-fast-llm-inference-mrzxuq9k/SKILL.md.part' && mv '.skill-downloads/groq-ultra-fast-llm-inference-mrzxuq9k/SKILL.md.part' '.skill-downloads/groq-ultra-fast-llm-inference-mrzxuq9k/SKILL.md'2. Vérifier les prérequis
Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.
Environnement déclaré par l’auteur : No special requirements
Extrait original : Installation
# TypeScript/JavaScript
npm install groq-sdk
# Python
pip install groq
# Or use with any OpenAI-compatible SDK
# Just set base_url to https://api.groq.com/openai/v1
Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.
3. Charger la skill
Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.
Claude Code
test -f '.skill-downloads/groq-ultra-fast-llm-inference-mrzxuq9k/SKILL.md' && test -s '.skill-downloads/groq-ultra-fast-llm-inference-mrzxuq9k/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/groq' && cp -R '.skill-downloads/groq-ultra-fast-llm-inference-mrzxuq9k' '.claude/skills/groq'Cursor
test -f '.skill-downloads/groq-ultra-fast-llm-inference-mrzxuq9k/SKILL.md' && test -s '.skill-downloads/groq-ultra-fast-llm-inference-mrzxuq9k/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/groq' && cp -R '.skill-downloads/groq-ultra-fast-llm-inference-mrzxuq9k' '.cursor/skills/groq'Codex
test -f '.skill-downloads/groq-ultra-fast-llm-inference-mrzxuq9k/SKILL.md' && test -s '.skill-downloads/groq-ultra-fast-llm-inference-mrzxuq9k/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/groq' && cp -R '.skill-downloads/groq-ultra-fast-llm-inference-mrzxuq9k' '.agents/skills/groq'OpenSkills
OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.
Installation officielle d’OpenSkillsopenskills install './.skill-downloads/groq-ultra-fast-llm-inference-mrzxuq9k'openskills read 'groq-ultra-fast-llm-inference-mrzxuq9k'La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.
Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.
openskills syncMode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.
4. Faire un premier essai
Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :
Lis .skill-downloads/groq-ultra-fast-llm-inference-mrzxuq9k/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.
Créer des cartes interactives avec kepler.gl
Data & IA
Création de cartes interactives et export HTML autonome avec le package Python keplergl, à partir de données géospatiales (DataFrame, GeoJSON, CSV).
Optimisation de paramètres par agent
Data & IA
Guide d'optimisation de systèmes configurables avec objectif mesurable, via des essais bornés et une recommandation fondée sur des preuves.
Relance des visiteurs ICP
Data & IA
Identifiez les utilisateurs inscrits correspondant au profil client idéal mais qui n'ont pas activé, et rédigez des messages de relance personnalisés pour les réengager.