---
name: groq-enterprise-rbac
description: |-
  Use when you run Groq inference for multiple teams and need per-team model
  allow-lists, spending caps, rate limits, and key rotation — because Groq API
  keys have no built-in scopes, so access control must live in your gateway.
  Configure Groq organization management, API key scoping, spending controls,
  and team access patterns. Trigger with phrases like "groq organization",
  "groq RBAC", "groq enterprise", "groq team access", "groq spending limits",
  "groq multi-team".
allowed-tools: Read, Write, Edit
version: 1.11.0
license: MIT
author: Jeremy Longshore <jeremy@intentsolutions.io>
tags:
  - saas
  - groq
  - rbac
compatibility: Designed for Claude Code
title: groq-enterprise-rbac
canonical_url: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/groq-enterprise-rbac
last_updated: 2026-10-07T06:06:28.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/examples.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-enterprise-rbac/references/examples.md), [references/implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-enterprise-rbac/references/implementation.md).
>
> If the user asked to install this Skill, run `npx skilld install jeremylongshore/tons-of-skills-marketplace/groq-enterprise-rbac`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/groq-enterprise-rbac`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/jeremylongshore/tons-of-skills-marketplace/groq-enterprise-rbac) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/groq-enterprise-rbac`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/groq-enterprise-rbac --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/groq-enterprise-rbac --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Groq Enterprise Access Management

## Overview

Manage team access to Groq's inference API through API key strategy, model-level routing controls, spending limits, and usage monitoring. Groq uses flat API keys (`gsk_` prefix) with no built-in scoping -- access control is implemented at the application layer, in a gateway that sits between your teams and Groq.

## Groq Access Model

- **API keys** are per-organization, not per-user
- **No built-in scopes** -- every key has full API access
- **Rate limits** are per-organization, shared across all keys
- **Spending limits** are configurable in the Groq Console
- **Projects** allow creating isolated API keys with separate limits

## Prerequisites

- A Groq organization with Console access (console.groq.com) and billing configured.
- Permission to create Groq **Projects** — one per team/service, each yielding its own `gsk_` key.
- A secret manager (AWS Secrets Manager, GCP Secret Manager, Vault, etc.) to store per-team keys.
- A gateway/service layer (Node/TypeScript in these examples) that every team's traffic passes through — Groq enforces nothing per-team, so your gateway is the control point.
- `groq-sdk` and `p-queue` installed if you use the reference gateway.

## Instructions

Access control is enforced in your own gateway. The full, copy-paste implementation for every
step lives in [references/implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-enterprise-rbac/references/implementation.md); the high-level flow:

1. **API key strategy** — one Groq Project (and key) per team/environment, named `{team}-{environment}-{purpose}`. Register keys in a lookup:

   ```typescript
   // Key naming convention: {team}-{environment}-{purpose}
   const KEY_REGISTRY = {
     "chatbot-prod":    "gsk_...",  // Project: chatbot-production
     "chatbot-staging": "gsk_...",  // Project: chatbot-staging
     "analytics-prod":  "gsk_...",  // Project: analytics-production
   } as const;
   ```

2. **Model access control** — define a per-team config (`allowedModels`, `maxTokensPerRequest`, `monthlyBudgetUsd`, `rateLimitRPM`) and a `validateRequest(team, model, maxTokens)` guard that throws before any unauthorized model or oversized request reaches Groq.
3. **API gateway** — `groqGateway(team, messages, model, maxTokens)` validates permissions, checks the monthly budget, rate-limits per team via `p-queue`, calls Groq with the team's key, and records usage.
4. **Spending controls** — set an org-level cap + alerts in the Groq Console (50/80/95%, auto-pause), and track application-level per-team spend with `recordTeamUsage`, which logs threshold alerts.
5. **Key rotation** — zero-downtime rotation: create a new key in the same Project, deploy alongside the old key, update the secret manager, restart, monitor 24h, then delete the old key.

See [references/implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-enterprise-rbac/references/implementation.md) for the complete code for each step.

## Output

Applying this skill produces a working per-team access layer in front of Groq:

- A **key registry** mapping each team/environment to its own Groq Project key.
- A **`TEAM_CONFIGS` policy object** — the source of truth for which models, token ceilings, budgets, and rate limits each team gets.
- A **gateway function** that rejects unauthorized model/token/budget requests before they reach Groq and rate-limits per team.
- **Per-team spend tracking** with 80%/95% threshold alerts, plus a weekly cost/token report table.
- A documented **key-rotation runbook** for zero-downtime credential changes.

## Error Handling

| Issue | Cause | Solution |
|-------|-------|----------|
| `429 rate_limit_exceeded` | Org-level RPM/TPM hit | Teams share org limits; reduce aggregate volume |
| `401 invalid_api_key` | Key deleted or rotated | Update secret manager, restart services |
| Budget exhausted | Monthly cap reached | Increase cap or wait for billing cycle reset |
| Wrong model used | No server-side enforcement | Validate model against team config before calling Groq |

## Examples

Two worked examples — a weekly per-team usage dashboard and a request that gets blocked by
the model allow-list — are in [references/examples.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-enterprise-rbac/references/examples.md).

The gateway rejects an out-of-scope model before it ever bills Groq:

```typescript
// analytics is scoped to llama-3.1-8b-instant only
await groqGateway("analytics", messages, "llama-3.3-70b-versatile", 512);
// throws: "Team analytics not authorized for model llama-3.3-70b-versatile"
```

## Resources

- [Groq Projects](https://console.groq.com/docs/projects)
- [Groq Spend Limits](https://console.groq.com/docs/spend-limits)
- [Groq Rate Limits](https://console.groq.com/docs/rate-limits)
- [Groq API Keys](https://console.groq.com/keys)
- [Full implementation walkthrough](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-enterprise-rbac/references/implementation.md)
- [Worked examples](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-enterprise-rbac/references/examples.md)
- For migration strategies, see the `groq-migration-deep-dive` skill.
