--- kind: function name: litellm-api-keys description: > Manages LiteLLM API keys for agent identity. Creates named keys so each agent is identifiable in LiteLLM logs/spend tracking. Keys are permanent (no expiry) and use the agent's bare name as alias (e.g., "tanko", not "tanko-jul2026"). Ensures agents never use the master key directly. Rotation is event-driven, not calendar-driven — rotate only on compromise, personnel change, or periodic security hygiene (quarterly/annually). Current key inventory and agent list: see gpu-fleet.prose.md § Agent Keys. Source of truth for LiteLLM config: /opt/inference-harness/litellm_config.yaml on CT 116. Last verified: 2026-07-09. --- ## Parameters - agent_name: string — The agent to manage keys for (e.g., "tanko", "mumuni") - action: "create" | "rotate" | "verify" | "list" — What to do (default: "create") - litellm_host: string — LiteLLM admin endpoint (default: "192.168.68.116:4000") - master_key: string — LiteLLM master key (default from environment) - agent_host: string — Agent's IP for SSH (default: resolved from infra) - agent_user: string — SSH user (default: "jerome") ## Returns - action: string — What was done - key_alias: string — The LiteLLM key alias created/rotated - key_prefix: string — First 10 chars of the new key (for identification) - previous_key_alias: string | null — Previous key alias if rotating - litellm_response: object — Raw response from LiteLLM /key/generate - agent_config_updated: boolean — Whether /etc/environment was updated - verification: { status: string, detail: string } — Final health check ## Execution 1. **Authenticate** — Verify master_key works against LiteLLM /key/list 2. **Check existing keys** — List all keys, find any with agent_name alias 3. **If action == "list"**: Return all keys with their aliases and spend 4. **If action == "create"**: - Generate new key with key_alias: "{agent_name}" (e.g., "tanko" — bare name, no date) - Set metadata: { "agent": "{agent_name}", "purpose": "agent-inference" } - Duration is null (permanent) — inherited from litellm default_key_generate_params - Set models: ["syslog-auto", "qwen3.6-27B-code", "gemma-4-12b", "ornith-1.0-35b"] - Note: qwen3.6-35B-A3B removed from fleet (was never deployed on any GPU) - Return the new key 5. **If action == "rotate"**: - Generate new key with same alias (LiteLLM replaces the old key) - SSH to agent_host, update /etc/environment LITELLM_API_KEY - Restart agent gateway (hermes gateway restart for Hermes agents) - Verify: curl test against /v1/models with new key - Rotation policy: on-demand only (compromise, departure, quarterly hygiene) 6. **If action == "verify"**: - SSH to agent, read /etc/environment - Test the key against LiteLLM /v1/models - Confirm key alias matches agent_name in LiteLLM key list