GR

groq-performance-tuning

Implements caching, batching, and model selection to maximize Groq inference throughput.

Install

mkdir -p .claude/skills/groq-performance-tuning && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/3393" && unzip -o skill.zip -d .claude/skills/groq-performance-tuning && rm skill.zip

Installs to .claude/skills/groq-performance-tuning

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Optimize Groq API performance with model selection, caching, streaming,
71 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Select optimal Groq models for speed and quality tiers
  • Minimize token count in prompts and set max_tokens
  • Implement streaming for perceived performance
  • Cache deterministic responses for repeat requests
  • Parallelize requests using a rate-limit-aware queue
  • Benchmark models against real prompts

How it works

The skill applies six tuning levers: model selection, token count minimization, streaming, caching, parallelization with a queue, and benchmarking, to optimize client-side Groq API interactions.

Inputs & outputs

You give it
Groq API requests with various models and parameters
You get back
Optimized Groq API responses with reduced latency and increased throughput

When to use groq-performance-tuning

  • Improve Groq API latency
  • Implement request caching
  • Optimize request throughput
  • Select optimal model for performance

About this skill

Groq Performance Tuning

Overview

Maximize Groq's LPU inference speed advantage. Groq already delivers extreme throughput (280-560 tok/s) and low latency (<200ms TTFT), but client-side optimization -- model selection, prompt size, streaming, caching, and parallelism -- determines whether your application fully exploits that speed.

This skill walks through six tuning levers at a high level; the complete, copy-pasteable code for each lives in references/implementation.md, and end-to-end worked scenarios live in references/examples.md.

Prerequisites

  • Groq API key — set GROQ_API_KEY in the environment. The groq-sdk client (new Groq()) reads it automatically; never hardcode the key.
  • Node.js 18+ with the groq-sdk package installed (npm install groq-sdk).
  • Optional packages for the caching and parallelism steps: lru-cache and p-queue (npm install lru-cache p-queue).
  • A baseline latency measurement of your current integration so you can confirm the tuning actually helps.

Groq Speed Benchmarks

ModelTTFTThroughputContext
llama-3.1-8b-instant~50ms~560 tok/s128K
llama-3.3-70b-versatile~150ms~280 tok/s128K
llama-3.3-70b-specdec~100ms~400 tok/s128K
meta-llama/llama-4-scout-17b-16e-instruct~80ms~460 tok/s128K

TTFT = Time to First Token. Actual values depend on prompt size and server load.

Instructions

Apply these six levers in order. Each is a small, independent change — start with the ones that match your bottleneck (model choice and caching give the biggest wins on most workloads). The full code for every step is in references/implementation.md.

  1. Choose the right model for speed. Map each call site to a speed tier: llama-3.1-8b-instant for latency-critical paths, llama-3.3-70b-versatile for quality-sensitive paths, llama-3.3-70b-specdec for 70b quality at higher throughput. Set temperature: 0 so responses are deterministic (and cacheable).
  2. Minimize token count. Trim verbose system prompts to their essence and set max_tokens to the expected output size, not a safe-looking ceiling. Fewer tokens means faster responses and less TPM-quota pressure.
  3. Stream for perceived performance. For any output the user watches arrive, stream chunks and surface live TTFT / tokens-per-second metrics. Streaming hides TTFT even when total wall-clock is unchanged.
  4. Cache deterministic responses. Hash {messages, model} and serve repeat temperature: 0 requests from an LRU cache with a short TTL — turning a repeated call into a ~0ms hit.
  5. Parallelize under a rate-limit-aware queue. Fan out bulk work with p-queue, capping concurrency and per-minute volume so you saturate throughput without tripping 429s.
  6. Benchmark before you commit. Measure the candidate models against your real prompt shape and pick the fastest that clears your quality bar.

The essential skeleton — a tiered client every other step builds on:

import Groq from "groq-sdk";

const groq = new Groq();  // reads GROQ_API_KEY from the environment

const SPEED_MAP = {
  instant: "llama-3.1-8b-instant",      // <100ms TTFT — latency-critical
  balanced: "llama-3.3-70b-versatile",  // <200ms TTFT — quality-sensitive
  fast70b: "llama-3.3-70b-specdec",     // 70b quality, faster throughput
} as const;

async function tieredCompletion(prompt: string, tier: keyof typeof SPEED_MAP = "instant") {
  return groq.chat.completions.create({
    model: SPEED_MAP[tier],
    messages: [{ role: "user", content: prompt }],
    temperature: 0,   // deterministic = cacheable
    max_tokens: 256,  // request only what you need
  });
}

See references/implementation.md for the streaming, caching, parallel-queue, and benchmarking functions in full.

Output

Applying these levers to a Groq integration produces:

  • A tiered model map (SPEED_MAP) so each call site uses the fastest model that meets its quality bar.
  • A streaming helper that returns { content, ttftMs, totalMs, tokPerSec } for live latency instrumentation.
  • A deterministic prompt cache (LRU + SHA-256 key) that collapses repeated requests to ~0ms.
  • A rate-limit-aware parallel executor that maximizes throughput without hitting 429s.
  • A benchmark report printing average latency and tokens/sec per model, e.g.:
llama-3.1-8b-instant     |  61ms avg | 548 tok/s avg
llama-3.3-70b-versatile  | 148ms avg | 279 tok/s avg
llama-3.3-70b-specdec    | 103ms avg | 401 tok/s avg

Performance Decision Matrix

ScenarioModelmax_tokensstreamcache
Classification8b-instant5NoYes
Chat response70b-versatile1024YesNo
Data extraction8b-instant200NoYes
Code generation70b-versatile2048YesNo
Bulk processing8b-instant256NoYes

Examples

Common scenarios mapped to the levers above. Full code for each is in references/examples.md.

  • Latency-critical classification8b-instant + one-word prompt + max_tokens: 5 + cache. First call ~50ms TTFT; identical repeats return from cache at ~0ms.
  • Interactive chat70b-versatile streamed with streamWithMetrics, printing tokens as they arrive plus a [TTFT | tok/s] footer.
  • Bulk processing (500 records)parallelCompletions wraps each call in a rate-limit-aware p-queue and reuses the cache for duplicate rows.
  • Empirical model choice — run benchmarkModels against your real prompt, then hardcode the fastest tier that clears your quality bar.
// Latency-critical classification, cached
const label = await cachedCompletion(
  [
    { role: "system", content: "Classify as positive/negative/neutral. One word only." },
    { role: "user", content: "This product exceeded every expectation." },
  ],
  "llama-3.1-8b-instant"
);
// => "positive"

See references/examples.md for the streaming, bulk, and benchmarking walkthroughs.

Error Handling

IssueCauseSolution
High TTFTUsing 70b for simple tasksSwitch to llama-3.1-8b-instant
Rate limit (429)Over RPM or TPMUse queue with interval limiting
Stream disconnectNetwork timeoutImplement reconnection with partial content
Token overflowmax_tokens too highSet to expected output size
Cache miss rate highUnique promptsNormalize prompts, use template patterns

Resources

Prerequisites

Groq API key set as GROQ_API_KEY environment variableNode.js 18+ with groq-sdk package installedOptional: lru-cache and p-queue packages

Limitations

  • High TTFT can be caused by using 70b models for simple tasks
  • Rate limits (429) can occur from over-RPM or TPM
  • Cache miss rates can be high with unique prompts

How it compares

This skill provides specific client-side strategies to maximize Groq's LPU inference speed, focusing on perceived performance and efficient resource use, unlike generic API integration.

Compared to similar skills

groq-performance-tuning side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
groq-performance-tuning (this skill)126dNo flagsIntermediate
langchain-architecture82moReviewIntermediate
agentdb-performance-optimization69moReviewAdvanced
voice-ai-development56moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

You might also like

langchain-architecture

wshobson

Design LLM applications using the LangChain framework with agents, memory, and tool integration patterns. Use when building LangChain applications, implementing AI agents, or creating complex LLM workflows.

899

agentdb-performance-optimization

ruvnet

Optimize AgentDB performance with quantization (4-32x memory reduction), HNSW indexing (150x faster search), caching, and batch operations. Use when optimizing memory usage, improving search speed, or scaling to millions of vectors.

656

voice-ai-development

davila7

Expert in building voice AI applications - from real-time voice agents to voice-enabled apps. Covers OpenAI Realtime API, Vapi for voice agents, Deepgram for transcription, ElevenLabs for synthesis, LiveKit for real-time infrastructure, and WebRTC fundamentals. Knows how to build low-latency, production-ready voice experiences. Use when: voice ai, voice agent, speech to text, text to speech, realtime voice.

553

ai-model-nodejs

TencentCloudBase

Use this skill when developing Node.js backend services or CloudBase cloud functions (Express/Koa/NestJS, serverless, backend APIs) that need AI capabilities. Features text generation (generateText), streaming (streamText), AND image generation (generateImage) via @cloudbase/node-sdk ≥3.16.0. Built-in models include Hunyuan (hunyuan-2.0-instruct-20251111 recommended), DeepSeek (deepseek-v3.2 recommended), and hunyuan-image for images. This is the ONLY SDK that supports image generation. NOT for browser/Web apps (use ai-model-web) or WeChat Mini Program (use ai-model-wechat).

59

openrouter-streaming-setup

jeremylongshore

Implement streaming responses with OpenRouter. Use when building real-time chat interfaces or reducing time-to-first-token. Trigger with phrases like 'openrouter streaming', 'openrouter sse', 'stream response', 'real-time openrouter'.

111

ideogram-rate-limits

jeremylongshore

Implement Ideogram rate limiting, backoff, and idempotency patterns. Use when handling rate limit errors, implementing retry logic, or optimizing API request throughput for Ideogram. Trigger with phrases like "ideogram rate limit", "ideogram throttling", "ideogram 429", "ideogram retry", "ideogram backoff".

28

Search skills

Search the agent skills registry