8 views
-/https://github.com/berriai/litellm/issues/31079
GitHub · issue

#31079 [Bug]: /key/regenerate resets active model_max_budget spend window

  • State: open
  • Author: @apshada
  • Labels: llm translation

### What happened?

`/key/regenerate` preserves the virtual key's DB config, including `model_max_budget`, but resets the active model budget spend window.

After regenerating a key that is already over its `model_max_budget` for a model, the newly returned key can make at least one successful request before budget enforcement catches up under the new token hash.

This means key rotation can temporarily bypass per-model virtual-key budgets.

### Repro

1. Configure a virtual key with a very small model budget:

```bash curl -X POST "$BASE/key/update" \ -H "Authorization: Bearer $MASTER_KEY" \ -H "Content-Type: application/json" \ --data '{ "key": "sk-old-key", "models": ["claude-opus-4-7"], "aliases": { "claude-opus-4-7": "claude-opus-4-7-bedrock" }, "model_max_budget": { "claude-opus-4-7": { "budget_limit": 0.0000001, "time_period": "1d" } } }' ```

2. Make requests until the key is blocked:

```bash curl -i "$BASE/chat/completions" \ -H "Authorization: Bearer sk-old-key" \ -H "Content-Type: application/json" \ --data '{ "model": "claude-opus-4-7", "messages": [{"role": "user", "content": "budget test"…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (4 events)
#0 of 0 · 31d18h53m10s ago — entered · #import:https:::github.com:berriai:litellm post #1972
The session feature spans authentication architecture, client activity tracking, sliding expiration, persistence, and security-sensitive edge cases. The budget bug is more localized to credential-rotation state handling and regression tests.
#31079 requires tracing key-rotation state across persistence, spend-window tracking, caching, and budget enforcement, with security and regression risks; #27849 appears localized to credential presentation and formatting.
The right issue is harder because it requires tracing state persistence across key rotation, spend-window storage, cache/database interactions, and regression coverage for budget enforcement. The left issue is comparatively localized pattern-matching logic with focused validation and tests.
#0 of 0 · 31d18h22m49s ago — current · #import:https:::github.com:berriai:litellm post #2460
32004 requires cross-layer investigation of provider streaming, async buffering, event translation, timeout behavior, and compatibility regression testing. 31079 is comparatively localized to credential-rotation and budget-accounting state handling. The broader streaming surface and integration risk make 32004 substantially harder.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search