> ## Documentation Index
> Fetch the complete documentation index at: https://docs.genesiscomputing.com/llms.txt
> Use this file to discover all available pages before exploring further.

# LiteLLM Admin Tools

> Reference for the Genesis tool that inspects a configured LiteLLM proxy.

## `litellm_admin_tools`

The connector's `action` selects a read operation for the saved connection. For
credential setup, least-privilege guidance, and the distinction from model
routing, see
[Connections](https://docs.genesiscomputing.com/docs/Setup/Connections.md#litellm-admin-connections).

### Actions

| Action | Purpose |
| - | - |
| `LIST_KEYS` | List virtual keys with aliases, owners, spend, limits, and hashes. |
| `GET_KEY_INFO` | Read one key's details and allowed routes. |
| `LIST_USERS` | List LiteLLM users, roles, spend, and budgets. |
| `LIST_TEAMS` | List teams, members, budgets, and spend. |
| `GET_SPEND_LOGS` | Read request-level spend records, filtered by key, user, team, model, and date. |
| `GET_DAILY_KEY_SPEND` | Read spend and usage totals per key, model, and day. |
| `LIST_MODELS` | List deployed proxy models. |
| `GET_CONFIG` | Read general settings and callback configuration where served. |
| `DETECT_SPEND_ANOMALIES` | Check the proxy's keys, users, daily spend, and request logs for spend anomalies; returns findings, notes for checks that could not run, and a ready-to-post `slack_message`. |
| `HELP`, `RTFM` | Return the action list and usage notes. |

### Parameters

| Parameter | Type | Default | Description |
| - | - | - | - |
| `action` | `string` (required) | — | Action from the table above. |
| `connection` | `string \| null` | `null` | Optional connection name such as `litellm_admin.prod`; otherwise uses the default connection. |
| `key` | `string \| null` | `null` | Alias filter for `LIST_KEYS`; hash or alias filter for spend actions; `GET_KEY_INFO` requires a key hash. |
| `litellm_user_id` | `string \| null` | `null` | LiteLLM user ID filter for `LIST_KEYS` and `GET_SPEND_LOGS`. |
| `team_id` | `string \| null` | `null` | Team filter for `LIST_KEYS` and `GET_SPEND_LOGS`. |
| `model` | `string \| null` | `null` | Model or model-group filter for spend actions. |
| `start_date` | `string \| null` | `null` | Inclusive first day of the spend window, `YYYY-MM-DD`. |
| `end_date` | `string \| null` | `null` | Inclusive last day of the spend window, `YYYY-MM-DD`; defaults to today in UTC. |
| `limit` | `integer` | `100` | Maximum rows to return, bounded to 1–1000. `LIST_KEYS` and `LIST_USERS` fetch larger results in proxy-sized pages of 100 rows. |
| `page` | `integer` | `1` | Page for `LIST_KEYS` and `LIST_USERS`, starting at 1. |
| `anomaly_settings` | `object \| null` | `null` | Optional `DETECT_SPEND_ANOMALIES` thresholds. `rotated_failures_medium_after_hours` defaults to `48`; `unknown_noise_jump_factor` to `3.0`, `unknown_noise_min_hashes` to `10`, `unknown_noise_min_failed` to `100`; `auto_provisioned_gone_medium_spend` to `$1.00` per day and `auto_provisioned_gone_medium_after_hours` to `48`; `time_budget_seconds` to `150` (allowed `30`–`300`). |
| `bot_id`, `thread_id`, `user_id` | implicit | Current context | Supplied by Genesis. |

The new `anomaly_settings` thresholds have these types and defaults:

| Setting | Type | Default | Purpose |
| - | - | -: | - |
| `unknown_noise_jump_factor` | number | `3.0` | Failed-only unknown-key counts or requests must exceed this multiple of the trailing daily median to trigger a noise-jump finding. |
| `unknown_noise_min_hashes` | integer | `10` | Minimum daily hash count for a noise-jump finding. |
| `unknown_noise_min_failed` | integer | `100` | Minimum daily failed-request count for a noise-jump finding. |
| `auto_provisioned_gone_medium_spend` | number | `1.0` | Daily spend above this USD threshold makes an unlisted auto-provisioned key finding **MEDIUM**. |
| `auto_provisioned_gone_medium_after_hours` | integer | `48` | Traffic continuing longer than this after the key last worked makes the finding **MEDIUM**. |

`GET_DAILY_KEY_SPEND` returns one row per date, key hash, and model, with spend,
successful and failed request counts, and token counts; one key can therefore have
several rows per day. Its response also includes `total_requests` and
`total_failed_requests` summed across the returned rows. It reads one day at a time
from LiteLLM's aggregated daily-activity route when available, and falls back to the
paged route when that route is unsupported or lacks per-model key detail.
Without dates, spend actions cover the last seven days, including today.
`GET_SPEND_LOGS` returns request rows without prompt or response text; older
proxies may return per-key totals instead. `GET_DAILY_KEY_SPEND` reads at most 20
pages per day on its paged fallback; when its result is `truncated: true`, narrow
the date range before using the partial totals. Credentials in model and
config results are redacted. For charts and recurring reports, use the
[`litellm_admin` dataset source](https://docs.genesiscomputing.com/docs/Setup/Datasets#litellm-admin-daily-spend-source)
instead of scheduling repeated tool calls.

`DETECT_SPEND_ANOMALIES` reads the last complete UTC day by default; set `end_date` to
choose another report end date. Its `anomaly_settings.time_budget_seconds` is a best-effort budget
(default `150`, allowed `30`–`300`): no read starts after the budget expires, and each
request timeout is cut to the remaining time. A read already in flight may finish later if
the proxy continues sending data. If the key list or daily spend cannot be read, the action
returns an error; failed optional reads are skipped and named in the report notes. A GET
that times out is retried once. The paged spend-log route is used when available, with a
legacy route fallback.

The `rotated_key` finding flags an unknown key hash whose alias now belongs to a listed
key. It is **MEDIUM** when the old key still succeeds or spends more than one hour after
the new key was created, or continues failing beyond
`anomaly_settings.rotated_failures_medium_after_hours` (default `48`); otherwise it is **LOW**. If the new
key's creation time is unavailable, successful requests or spend in the report window
prevent a LOW severity.

Unlisted hashes with spend or successful requests are checked with `GET /key/info`
(at most five lookups, highest spend first). A hash that exists but is absent from
the key list is reported as `key_missing_from_list`; failed lookups are noted and
do not confirm deletion. Traffic associated with a Genesis auto-provisioned source
is reported as `auto_provisioned_key_gone`: deletion-like evidence can be **LOW**,
while successful-only traffic, uncertain deletion timing, daily spend above
`auto_provisioned_gone_medium_spend`, traffic continuing past
`auto_provisioned_gone_medium_after_hours`, or a failed lookup is **MEDIUM**.
When the lookup is skipped, severity follows the available traffic evidence and
thresholds.

Unknown hashes with only failed requests and `$0` spend are grouped into one
`unknown_key_failed_only` finding rather than one finding per hash. It lists the
available routes, user agents and requester IPs; it is **LOW** when every log read
is model discovery and **MEDIUM** for other calls or a sufficiently large daily
jump above the trailing median. A spend spike against a baseline below `$0.01` is
described as new spend against an approximately-zero baseline, without a ratio.

For example, list keys and then inspect daily spend for one key:

```json theme={null}
{
  "action": "LIST_KEYS",
  "limit": 25
}
```

Use a returned `key_hash` as `key` with `GET_DAILY_KEY_SPEND` or
`GET_KEY_INFO`.
