/groq-pack:groq-sdk-patternsfrom groq-pack
Applies production-ready Groq SDK patterns for TypeScript and Python: typed singletons, streaming, error handling with retry, and multi-tenant factories.
Ships in groq-pack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Production patterns for the groq-sdk package. The Groq SDK mirrors the OpenAI SDK interface (chat.completions.create), so patterns feel familiar but must account for Groq-specific behavior: extreme speed (500+ tok/s), aggressive rate limits on free tier, and unique response metadata like queue_time and completion_time.
The full, copy-paste-ready implementations live in references/ so this file stays a fast map of the workflow. Read the summary here, then drill into the language file you need.
groq-sdk (TypeScript) or groq (Python) installedGROQ_API_KEY set in the environmentBuild the integration in layers. Each step below is a one-line summary; the full typed implementation is in references/typescript-patterns.md (steps 1–5, 7) and references/python-patterns.md (step 6).
Groq client with maxRetries and timeout, so the whole app reuses one connection pool and config.queue_time, completion_time, total_time) and a computed tokensPerSec.AsyncGenerator<string> that yields delta.content tokens.Groq.APIError (429, 401, other) and Groq.APIConnectionError; rethrow the unknown.retry-after header on 429s, else jittered backoff.Groq(), AsyncGroq(), and streaming (see the Python reference).The essential skeleton — a shared singleton every other pattern builds on:
// src/groq/client.ts
import Groq from "groq-sdk";
let _client: Groq | null = null;
export function getGroq(): Groq {
if (!_client) {
_client = new Groq({
apiKey: process.env.GROQ_API_KEY,
maxRetries: 3,
timeout: 30_000,
});
}
return _client;
}
Groq differs from OpenAI in a few details (package name, base URL, extra usage timing fields, error class names). The full comparison and error-handling matrix are in references/sdk-differences.md.
Applying these patterns produces:
getGroq() client module and, for multi-tenant apps, a getClientForTenant() factory.complete() wrapper returning a typed CompletionResult — content, model, tokens (prompt/completion/total), and timing (queueMs, totalMs, tokensPerSec).safeComplete() variant returning { data, error } so callers never face an uncaught exception.| Pattern | Use Case | Benefit |
|---|---|---|
safeComplete wrapper | All API calls | Prevents uncaught exceptions |
withRetry | Rate-limited calls | Respects retry-after header |
| Typed error checking | instanceof Groq.APIError | Handles each status code specifically |
| Client singleton | App-wide usage | Single connection pool, consistent config |
err.headers["retry-after"] and wait that long before retrying; free tier hits this often.APIConnectionError: network issue reaching api.groq.com; retry or fail fast per context.Full typed handlers: references/typescript-patterns.md (Step 4 and Step 5).
Non-streaming completion with timing metadata (full code in references/typescript-patterns.md, Step 2):
const result = await complete(
[{ role: "user", content: "Summarize Groq's speed advantage." }],
"llama-3.3-70b-versatile"
);
console.log(result.content);
console.log(`${result.timing.tokensPerSec.toFixed(0)} tok/s`);
Streaming tokens to stdout (full code in the TS reference, Step 3):
for await (const token of streamCompletion([{ role: "user", content: "Hello" }])) {
process.stdout.write(token);
}
Python one-liner (full sync/async/streaming in references/python-patterns.md):
from groq import Groq
client = Groq()
print(client.chat.completions.create(
model="llama-3.3-70b-versatile",
messages=[{"role": "user", "content": "Hello"}],
).choices[0].message.content)
Apply these patterns in groq-core-workflow-a for real-world chat completions, then wire safeComplete and withRetry into every call site so rate limits and network errors are handled consistently across the codebase.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
24 skills in this plugin
/groq-ci-integrationConfigure Groq CI/CD integration with GitHub Actions, testing, and model validation.
Use when setting up automated testing, configuring CI pipelines,
or integrating Groq tests into your build process.
Trigger with phrases like "groq CI", "groq GitHub Actions",
"groq automated tests", "CI groq".
/groq-common-errorsDiagnose and fix Groq API errors with real error codes and solutions.
Use when encountering Groq errors, debugging failed requests,
or troubleshooting integration issues.
Trigger with phrases like "groq error", "fix groq",
"groq not working", "debug groq", "groq 429".
/groq-core-workflow-aExecute Groq's primary workflow: chat completions with tool use and JSON mode.
Use when implementing chat interfaces, function calling, structured output,
or building AI features with Groq's fast inference.
Trigger with phrases like "groq chat completion", "groq tool use",
"groq function calling", "groq JSON mode".
/groq-core-workflow-bUse when you need Groq's non-chat endpoints — transcribing or translating
audio with Whisper, understanding images with Llama 4 vision, generating
speech (TTS), or benchmarking models for speed vs quality.
Trigger with phrases like "groq whisper", "groq transcription",
"groq audio", "groq vision", "groq TTS", "groq speech".
/groq-cost-tuningOptimize Groq costs through model routing, token management, and usage monitoring.
Use when analyzing Groq billing, reducing API costs,
or implementing usage monitoring and budget alerts.
Trigger with phrases like "groq cost", "groq billing",
"reduce groq costs", "groq pricing", "groq expensive", "groq budget".
/groq-data-handlingUse when you need to keep PII out of Groq API calls, filter model responses,
audit-log conversations, or track token cost and usage for a Groq integration.
Implements prompt sanitization, PII redaction, response filtering, and usage
tracking. Trigger with phrases like "groq data", "groq PII", "groq GDPR",
"groq data retention", "groq privacy", "groq compliance".
npx claudepluginhub jeremylongshore/tons-of-skills-marketplace --plugin groq-packOther plugins' skills for the same job