$npx -y skills add BerriAI/litellm-skills --skill add-keyGenerate a new API key on a live LiteLLM proxy. Asks for alias, scope (user/team), budget, models, and expiry, then calls POST /key/generate. Use when the user wants to create, generate, or provision an API key on a LiteLLM proxy instance.
| 1 | # Add Key |
| 2 | |
| 3 | Generate a new API key on a live LiteLLM proxy. |
| 4 | |
| 5 | ## Setup |
| 6 | |
| 7 | Ask for these if not already known: |
| 8 | ``` |
| 9 | LITELLM_BASE_URL — e.g. https://my-proxy.example.com |
| 10 | LITELLM_API_KEY — proxy admin key |
| 11 | ``` |
| 12 | |
| 13 | API reference: https://litellm.vercel.app/docs/proxy/virtual_keys |
| 14 | |
| 15 | ## Ask the user |
| 16 | |
| 17 | 1. **Key alias** (optional but recommended, e.g. `my-app-prod`) |
| 18 | 2. **Scope** — assign to a `team_id` or `user_id`? (optional) |
| 19 | 3. **Allowed models** (optional, e.g. `gpt-4o, claude-3-5-sonnet`) |
| 20 | 4. **Max budget** (optional, e.g. `5.00`) |
| 21 | 5. **Expiry** (optional, e.g. `7d`, `30d`, `90d`) — omit for no expiry |
| 22 | |
| 23 | ## Run |
| 24 | |
| 25 | ```bash |
| 26 | BASE="$LITELLM_BASE_URL" |
| 27 | KEY="$LITELLM_API_KEY" |
| 28 | |
| 29 | curl -s -X POST "$BASE/key/generate" \ |
| 30 | -H "Authorization: Bearer $KEY" \ |
| 31 | -H "Content-Type: application/json" \ |
| 32 | -d '{ |
| 33 | "key_alias": "<alias>", |
| 34 | "team_id": "<team_id_or_omit>", |
| 35 | "user_id": "<user_id_or_omit>", |
| 36 | "models": [<models_or_empty>], |
| 37 | "max_budget": <budget_or_null>, |
| 38 | "duration": "<duration_or_omit>" |
| 39 | }' |
| 40 | ``` |
| 41 | |
| 42 | ## Verify |
| 43 | |
| 44 | Confirm the key was created: |
| 45 | ```bash |
| 46 | curl -s "$BASE/key/info" \ |
| 47 | -H "Authorization: Bearer <new_key>" | python3 -c " |
| 48 | import sys, json |
| 49 | d = json.load(sys.stdin) |
| 50 | info = d.get('info', {}) |
| 51 | print(f'Alias: {info.get(\"key_alias\")}') |
| 52 | print(f'Expires: {info.get(\"expires\")}') |
| 53 | print(f'Budget: {info.get(\"max_budget\")}') |
| 54 | print(f'Models: {info.get(\"models\")}') |
| 55 | " |
| 56 | ``` |
| 57 | |
| 58 | ## Output |
| 59 | |
| 60 | Show the user: |
| 61 | - `key` — the actual key value (only shown once, tell them to save it) |
| 62 | - `key_alias`, `expires`, `max_budget`, `models` |
| 63 | |
| 64 | On error: |
| 65 | - **401** — check that `LITELLM_API_KEY` is a valid admin key |
| 66 | - **400** — check required fields; verify `team_id`/`user_id` exists |
| 67 | - Other errors — show `detail` and the likely fix |