manage-api-keys
Skill180 starsChanged 8 months agoMITView on GitHub
Create, list, deactivate, and reactivate API keys for rate limiting
- Reads credentials
- Sends data out
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- cloudflare-cliSkill
- create-prSkill
- discord-community-feedbackSkill
- hosted-studio-debugSkill
- integration-testsSkill
- linear-issue-fixerSkill
- manage-tiersSkill
- sentry-issue-fixerSkill
- setupSkill
- studio-dbSkill
- unit-testsSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 2 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Before any operation, determine the target environment:
- Distinctive: line 23
Ask the user which operation to perform: Create, List, Deactivate, or Reactivate.
- Very specific: line 48
Ask the user for: tier_name (suggest listing tiers first with /manage-tiers) and optional description.
- Very specific: line 66
Ask the user for the key_prefix (8 characters, e.g., glk_ab12).
- Very specific: line 99
When the rate limit is exceeded, the response is HTTP 429 with a JSON-RPC error including window, limit, current, and retry_after_seconds.
- Very specific: line 119
Always use --data-binary @- with heredoc (<<'EOF') to avoid shell expansion issues with special characters in the admin key.
- Very specific: line 120
When rate limiting is disabled (RATE_LIMIT_ENABLED=false), keys can still be created and managed, but rate limits are not enforced and …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Manage API Keys
CRUD operations for API keys used in rate limiting on GenLayer Studio deployments.
Setup
Before any operation, determine the target environment:
- Ask the user which environment they are targeting:
- Local dev:
BASE_URL=http://localhost:4000/api, noadmin_keyneeded - Hosted (dev/stg/prd):
BASE_URL=https://<domain>/api, requiresadmin_key
- Local dev:
- For hosted deployments, ask the user for the
ADMIN_API_KEY(stored in k8s secrets asADMIN_API_KEY).
Operations
Ask the user which operation to perform: Create, List, Deactivate, or Reactivate.
List API Keys
Note: This endpoint may not exist yet. If admin_listApiKeys is not available, query the database directly using the studio-db skill, or inform the user it needs to be implemented.
# List all keys
curl -s -X POST "$BASE_URL" -H "Content-Type: application/json" --data-binary @- <<'EOF' | python3 -m json.tool
{"jsonrpc":"2.0","method":"admin_listApiKeys","params":{"admin_key":"<ADMIN_KEY>"},"id":1}
EOF
# Filter by tier
curl -s -X POST "$BASE_URL" -H "Content-Type: application/json" --data-binary @- <<'EOF' | python3 -m json.tool
{"jsonrpc":"2.0","method":"admin_listApiKeys","params":{"tier_name":"free","admin_key":"<ADMIN_KEY>"},"id":1}
EOF
# Filter by active status
curl -s -X POST "$BASE_URL" -H "Content-Type: application/json" --data-binary @- <<'EOF' | python3 -m json.tool
{"jsonrpc":"2.0","method":"admin_listApiKeys","params":{"is_active":false,"admin_key":"<ADMIN_KEY>"},"id":1}
EOFCreate API Key
Ask the user for: tier_name (suggest listing tiers first with /manage-tiers) and optional description.
curl -s -X POST "$BASE_URL" -H "Content-Type: application/json" --data-binary @- <<'EOF' | python3 -m json.tool
{"jsonrpc":"2.0","method":"admin_createApiKey","params":{"tier_name":"<TIER_NAME>","description":"<DESCRIPTION>","admin_key":"<ADMIN_KEY>"},"id":1}
EOFIMPORTANT: The full API key (e.g., glk_abcdef1234...) is only returned once at creation time. Remind the user to store it securely. Only the key_prefix (first 8 chars) is stored for identification.
Response includes:
api_key: Full key (store this!)key_prefix: First 8 characters (e.g.,glk_ab12)tier: Tier namedescription: Optional description
Deactivate API Key
Ask the user for the key_prefix (8 characters, e.g., glk_ab12). If they don't know it, list keys first.
curl -s -X POST "$BASE_URL" -H "Content-Type: application/json" --data-binary @- <<'EOF' | python3 -m json.tool
{"jsonrpc":"2.0","method":"admin_deactivateApiKey","params":{"key_prefix":"<KEY_PREFIX>","admin_key":"<ADMIN_KEY>"},"id":1}
EOFDeactivation takes effect immediately (Redis cache is invalidated).
Reactivate API Key
Note: This endpoint may not exist yet. If admin_reactivateApiKey is not available, inform the user it needs to be implemented.
curl -s -X POST "$BASE_URL" -H "Content-Type: application/json" --data-binary @- <<'EOF' | python3 -m json.tool
{"jsonrpc":"2.0","method":"admin_reactivateApiKey","params":{"key_prefix":"<KEY_PREFIX>","admin_key":"<ADMIN_KEY>"},"id":1}
EOFAPI Key Usage
Clients send the API key via the X-API-Key HTTP header:
curl -X POST "$BASE_URL" \
-H "Content-Type: application/json" \
-H "X-API-Key: glk_<full_key>" \
-d '{"jsonrpc":"2.0","method":"<method>","params":{...},"id":1}'- Requests without
X-API-Keyare subject to anonymous rate limits (default: 10/min, 100/hr, 1000/day). - Invalid or deactivated keys return
-32029 "Invalid API key". - When the rate limit is exceeded, the response is HTTP 429 with a JSON-RPC error including
window,limit,current, andretry_after_seconds.
Common Errors
| Error | Cause |
-32000 "Admin access required" | Missing or invalid admin_key on hosted deployment |
-32602 "Tier not found: X" | Specified tier_name doesn't exist |
-32001 "Active API key with prefix X not found" | Key doesn't exist or is already deactivated |
-32029 "Invalid API key" | Key is invalid or deactivated (when rate limiting is enabled) |
-32029 "Rate limit exceeded: N requests per minute" | Key has exceeded its tier's rate limit |
Key Format
- Full key:
glk_+ 64 hex characters (68 chars total) - Key prefix: first 8 characters (e.g.,
glk_ab12) - Storage: only the SHA-256 hash is stored in the database; the full key cannot be recovered
Important Notes
- Always use
--data-binary @-with heredoc (<<'EOF') to avoid shell expansion issues with special characters in the admin key. - When rate limiting is disabled (
RATE_LIMIT_ENABLED=false), keys can still be created and managed, but rate limits are not enforced and invalid keys are not rejected. - Cache invalidation happens automatically on deactivate/reactivate (5-minute TTL otherwise).
Reference
- Models:
backend/database_handler/models.py(ApiKey class) - Endpoints:
backend/protocol_rpc/endpoints.py(admin_create_api_key, admin_deactivate_api_key) - Rate limiter:
backend/protocol_rpc/rate_limiter.py - Middleware:
backend/protocol_rpc/rate_limit_middleware.py
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

