Apply Groq security best practices for API key management and data protection. Use when securing API keys, implementing least privilege access, or auditing Groq security configuration. Trigger with phrases like "groq security", "groq secrets", "secure groq", "groq API key security".
70
87%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Low
Low-risk findings worth noting
Security practices for Groq API keys and data flowing through Groq's inference API. Groq uses a single API key type (gsk_ prefix) with full access -- there are no scoped tokens -- so key management and rotation are critical.
This skill walks through six hardening steps end to end. The essentials live here; deep code and full command sequences are extracted into references/ for progressive disclosure:
gsk_ and grant full API accessWork through the six steps in order. Each summary below is enough to act on; drill into the linked reference for the full code.
Keep the key out of source. Use a .env.local (git-ignored) for development
and a platform secret manager (Vercel / AWS / GCP / GitHub Actions) for
production. Use Write to create the .env.local and .gitignore entries:
echo "GROQ_API_KEY=gsk_dev_key_here" > .env.local
echo -e ".env\n.env.local\n.env.*.local" >> .gitignoreFull per-platform commands: references/examples.md Example 1.
Both keys work simultaneously, so rotation is zero-downtime: create a
date-named key, deploy it, verify with a 200 from /v1/models, monitor 24h,
then delete the old key. Full sequence: references/examples.md Example 2.
Install a pre-commit hook that blocks any staged gsk_ key. Use Read to
confirm .gitignore excludes the .env files, then use Grep to sweep the
existing tree and history for keys already committed:
grep -rnE "gsk_[a-zA-Z0-9]{20,}" . --exclude-dir=.gitHook + history-scan commands: references/examples.md Examples 3-4.
Never expose the key to client code. Proxy inference through your backend so the key stays server-side, and validate/limit user input before calling Groq. Full Next.js route handler: references/implementation.md § Server-Side Key Usage Pattern.
Sanitize user input to strip override phrases (ignore previous instructions,
you are now, system:) and pair it with a hardened system prompt that
refuses role changes. Full code: references/implementation.md § Prompt Injection Defense.
Log every completion with token counts, latency, and status so abuse and cost
spikes trace back to a user. Full auditedCompletion implementation:
references/implementation.md § Audit Logging.
Applying this skill produces a hardened Groq integration:
.env.local (dev) and secret-manager entry (prod) — no key in source.git/hooks/pre-commit hook that exits non-zero on any staged gsk_ keyGroqAuditEntry) on every completion401 Unauthorized from /v1/models — the rotated key is wrong or not yet propagated to the secret manager. Re-check the Authorization: Bearer value before deleting the old key.chmod +x .git/hooks/pre-commit); hooks are not copied by git clone, so re-install per checkout.Grep finds a key already in history — rotate the key immediately (Step 2); scrubbing history alone is not enough because the key was exposed.GROQ_API_KEY reference — any bundler that inlines the key (e.g. a NEXT_PUBLIC_ prefix) leaks it; move the call server-side (Step 4).429 spike can indicate abuse.Lean summaries are in Instructions; full copy-ready code lives in the references:
.env files in .gitignoreFor production deployment, work through the groq-prod-checklist skill, which
covers deployment gates, monitoring, and spend controls beyond this security
baseline.
0540a62
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.