litellm/tests/test_litellm/proxy
ishaan-berri 0afffe4366
feat: multiple concurrent budget windows per API key and team (#24883) (#25109)
* feat: multiple concurrent budget windows per API key and team (#24883)

* feat(proxy): add BudgetLimitEntry type and wire budget_limits into key/team models

* feat(schema): add budget_limits Json column to VerificationToken and TeamTable

* feat(migrations): add migration for budget_limits column on keys and teams

* feat(keys): initialize budget_limits windows with reset_at on key create/update

* feat(teams): initialize budget_limits windows with reset_at on team create/update

* feat(auth): add _virtual_key_multi_budget_check and _team_multi_budget_check

* feat(auth): call multi-budget checks from common_checks for keys and teams

* feat(proxy): increment per-window Redis spend counters after each request

* feat(budget): reset individual budget windows on schedule via reset_budget_job

* feat(ui): add hourly option to BudgetDurationDropdown

* feat(ui): add budget_limits field to KeyResponse type

* feat(ui): add Budget Windows editor to key edit view

* feat(ui): add Budget Windows editor to create key form

* fix(proxy): strip budget_limits=None before Prisma upsert to fix login 500

Prisma rejects nullable JSON fields (Json? without @default) when passed as
Python None — it needs the field omitted entirely so the DB stores NULL via
the column's nullable constraint. This was breaking /v2/login because the UI
session key creation path hit the upsert with budget_limits=None.

* ui(key-edit): use antd InputNumber+Button for budget windows, add reset hints

* ui(create-key): use antd InputNumber+Button for budget windows, add reset hints

* docs(users): add multiple budget windows section with API + dashboard walkthrough

* fix: BudgetExceededError returns HTTP 429 instead of 400

- Add status_code=429 to BudgetExceededError class
- auth_exception_handler hardcoded code=400 → code=429

* fix: no-op else branch in multi-budget auth checks causes KeyError

- BudgetLimitEntry objects must be coerced via model_dump() not left as-is
- Move _virtual_key_multi_budget_check into common_checks (was asymmetric
  with _team_multi_budget_check which already lived there)

* fix: len() on JSON string returns char count not window count

Guard with isinstance check + json.loads() before iterating per-window
Redis counters in increment_spend_counters

* fix: silent except:pass hides Redis reset failures in reset_budget_windows

Log Redis counter reset failures as warnings so they are observable

* test: add unit tests for multi-budget window enforcement

5 tests covering: no budget_limits passes, under budget passes,
over hourly window raises 429, over monthly window raises 429,
BudgetLimitEntry objects coerced without KeyError

* fix: key per-window counters stable across reorders (duration key, not index)

* fix: team+key per-window spend increments use duration key, not index

* fix: budget window reset uses duration key; log failures instead of swallowing

* refactor: extract BudgetWindowsEditor to shared component

* refactor: key_edit_view imports BudgetWindowsEditor from shared component

* refactor: create_key_button imports BudgetWindowsEditor from shared component

---------

Co-authored-by: Ishaan Jaffer <ishaanjaffer0324@gmail.com>

* fix(reset_budget_job): extract _reset_expired_window helper to fix PLR0915 too many statements

* feat(skills): Skills Registry & Hub — register skills, browse in AI Hub, public skill hub (#25118)

* feat(skills): add domain and namespace fields to plugin types

* feat(skills): store and return domain/namespace inside manifest_json

* feat(skills): add /public/skill_hub endpoint for unauthenticated access

* feat(skills): whitelist /public/skill_hub from auth requirements

* feat(skills): add domain, namespace to Plugin and RegisterPluginRequest types

* feat(skills): smart URL parser — paste github URL, auto-detect source type and name

* feat(skills): replace enable toggle with Public badge, make rows clickable

* feat(skills): add skill detail view with Overview and How to Use tabs

* feat(skills): add MakeSkillPublicForm modal for publishing skills to the hub

* feat(skills): rename panel to Skills, wire in skill detail view on row click

* feat(skills): add skill hub table columns — name, description, domain, source, status

* feat(skills): add SkillHubDashboard with stats row, domain dropdown filter, and table

* feat(skills): add Skill Hub tab to AI Hub with Select Skills to Make Public button

* feat(skills): move Skills to top-level nav item directly under MCP Servers

* feat(skills): add skillHubPublicCall and NEXT_PUBLIC_BASE_URL support

* feat(skills): add Skill Hub tab to public AI Hub page

* feat(skills): add skills page routing in main app router

* feat(skills): add /skills page route

* chore: update package-lock after npm install

* docs(skills): add Skills Gateway doc page with mermaid architecture diagram

* docs(skills): add Skills Gateway to sidebar under Agent & MCP Gateway

* docs(skills): add loom walkthrough video to Skills Gateway doc

* chore: fixes

---------

Co-authored-by: Ishaan Jaffer <ishaanjaffer0324@gmail.com>
Co-authored-by: Yuneng Jiang <yuneng@berri.ai>
2026-04-06 14:02:04 -07:00
..
_experimental/mcp_server cherry-pick: tag query fix + MCP metadata support (#25145) 2026-04-04 16:44:02 -07:00
agent_endpoints [Fix] Test isolation for agent health checks and documentation test path resolution 2026-03-28 11:00:22 -07:00
anthropic_endpoints Litellm ishaan march 20 (#24303) 2026-03-21 12:40:11 -07:00
auth feat: multiple concurrent budget windows per API key and team (#24883) (#25109) 2026-04-06 14:02:04 -07:00
client add a new feature fix to expose the team alias when authenticating th… (#17725) 2025-12-10 10:10:28 -08:00
common_utils Litellm ishaan april4 2 (#25150) 2026-04-04 23:09:42 +00:00
db cherry-pick: tag query fix + MCP metadata support (#25145) 2026-04-04 16:44:02 -07:00
discovery_endpoints feat: add control plane for multi-proxy worker management 2026-03-19 22:50:19 -07:00
experimental/mcp_server
google_endpoints fix: Metadata / Trace ID Missing in S3 Streaming Callbacks 2026-02-25 14:16:42 +05:30
guardrails Merge remote-tracking branch 'origin/main' into litellm_feat-add-guardrail 2026-04-04 16:17:38 -07:00
health_endpoints Prisma DB Failure Detection and Self-Healing (#21059) 2026-03-05 13:44:49 -08:00
hooks Litellm ishaan april1 try2 (#25110) 2026-04-03 14:57:44 -07:00
image_endpoints fixing core proxy tests 2026-02-12 17:54:32 -08:00
management_endpoints test: add unit tests for _get_team_deployments filtering logic 2026-04-04 14:34:39 -07:00
management_helpers Merge branch 'main' into litellm_audit_log_s3_export 2026-03-20 16:39:54 -07:00
middleware [Fix] Fix test failures and Docker build from pinned dependency upgrade 2026-04-01 09:43:33 -07:00
openai_files_endpoint test: test 2026-03-28 19:17:38 -07:00
pass_through_endpoints fix: stabilize 5 CI test failures 2026-03-13 01:03:35 +00:00
policy_engine Litellm ishaan april4 2 (#25150) 2026-04-04 23:09:42 +00:00
prompts Litellm ishaan april1 try2 (#25110) 2026-04-03 14:57:44 -07:00
public_endpoints feat(ui): expose Azure Entra ID credential fields in provider form 2026-04-04 11:19:45 -07:00
rag_endpoints tests and route permissions (#21508) 2026-02-18 16:58:38 -08:00
realtime_endpoints fix(tests): fix flaky realtime WebRTC endpoint tests 2026-03-12 23:14:51 -07:00
response_api_endpoints Fix x-litellm-key-spend update 2025-12-12 11:44:51 +05:30
spend_tracking fix(test): add user_api_key_project_alias to spend logs expected keys 2026-03-23 18:12:50 -07:00
test_configs
ui_crud_endpoints Update tests/test_litellm/proxy/ui_crud_endpoints/test_proxy_setting_endpoints.py 2026-03-14 15:42:17 -07:00
vector_store_endpoints test_delete_vector_store_checks_access 2026-01-31 12:05:09 -08:00
__init__.py test fix 2025-10-17 10:46:42 -07:00
conftest.py Add health endpoint tests to CI with database and Redis support (#17877) 2025-12-12 07:35:50 -08:00
test_aiohttp_cleanup_closed.py fix(aiohttp): only set enable_cleanup_closed when required (#21897) 2026-02-23 21:06:29 -08:00
test_aiohttp_session_recovery.py fix: use AsyncMock for concurrent test consistency 2026-03-18 00:54:23 +00:00
test_api_key_masking_in_errors.py fix: mask API keys in error responses for invalid/malformed keys (#20289) 2026-02-12 19:58:05 +05:30
test_audio_speech_prometheus_hooks.py fix req changes 2026-02-28 21:32:57 +05:30
test_batch_expiry.py fix(proxy): improve team expiry enforcement validation 2026-03-03 17:29:39 -08:00
test_batch_metadata_none_fix.py
test_caching_routes.py
test_chat_completion_metadata.py fix: propagate JWT auth metadata to OTEL spans (#19627) 2026-01-23 21:21:23 -08:00
test_common_request_processing.py fix(guardrails): return HTTP 400 instead of 500 for Model Armor streaming blocks (#24693) 2026-04-02 21:28:52 -07:00
test_custom_proxy.py fix(ui/): fix routing for custom server root path (#15701) 2025-10-23 13:59:29 -07:00
test_empty_model_list.py [Release Fix] (#22411) 2026-02-28 09:46:35 -08:00
test_enforce_user_param.py Enforce support of enforce_user_param to openai post endpoints 2025-12-03 12:19:21 +05:30
test_fallback_management_endpoints.py Add fallback endpoints support 2026-01-16 10:51:33 +05:30
test_fastapi_offline_routes.py
test_health_check_functions.py Litellm ishaan april4 2 (#25150) 2026-04-04 23:09:42 +00:00
test_health_check_max_tokens.py add docs and formatting 2026-02-28 14:08:09 +05:30
test_litellm_pre_call_utils.py feat(proxy): add project-level guardrails support (#25087) 2026-04-03 20:20:44 -07:00
test_max_budget_env_var.py Fix PR review issues: gpt-4-0314 prompt caching, case-insensitive data URL check, test I/O mocking 2026-03-21 11:30:29 -07:00
test_model_dump_with_preserved_fields.py Fix_mapped tests part 2 2026-02-26 12:43:39 +05:30
test_model_id_header_propagation.py (fix) propagate x-litellm-model-id in responses (#16986) 2025-11-24 20:40:43 -08:00
test_model_info_default_limits.py refactor: consolidate duplicate helpers and eliminate success-handler double lookup 2026-03-19 07:26:43 -04:00
test_model_level_guardrails.py test: use __file__-relative sys.path for stable test imports 2026-03-16 21:07:07 +01:00
test_openapi_schema_validation.py Reapply "feat: add model_cost aliases expansion support" 2026-03-12 13:36:57 -03:00
test_prometheus_cleanup.py [Infra] Merging RC Branch with Main (#23786) 2026-03-16 15:32:20 -07:00
test_proxy_cli.py feat(proxy): use AZURE_DEFAULT_API_VERSION for proxy --api_version default 2026-03-19 15:57:03 +05:30
test_proxy_server.py [Fix] Include access group models in UI model listing 2026-03-28 12:32:12 -07:00
test_proxy_types.py fix: Add PROXY_ADMIN role to system user for key rotation (#21896) 2026-02-27 19:11:29 -08:00
test_proxy_utils.py [Feat[ extends OAuth2 M2M authentication support to info routes (/key/info, /team/info, /user/info, /model/info) (#22713) 2026-03-06 17:29:25 -08:00
test_pyroscope.py Fix CI/CD pyroscope test failure (#21219) 2026-02-14 12:07:20 -08:00
test_response_model_sanitization.py fix: return winning model name instead of comma-separated list for fastest_response 2026-03-27 22:34:26 -07:00
test_route_a2a_models.py Fix test_route_a2a_model_bypasses_router 2026-02-05 09:47:05 +05:30
test_route_llm_request.py Override router settings 2026-01-31 16:04:52 -08:00
test_shared_health_check.py Litellm ishaan april4 2 (#25150) 2026-04-04 23:09:42 +00:00
test_spend_log_cleanup.py Fix spend log cleanup: lock tracking, integer retention, skip log level 2026-03-03 10:12:08 -08:00
test_swagger_chat_completions.py [Release Fix] (#22411) 2026-02-28 09:46:35 -08:00
test_team_member_update.py
test_tools_allowlist_enforcement.py Bug Fix: auto-inject prompt caching support for Gemini models (#21881) 2026-03-03 20:25:35 -08:00
test_update_llm_router_resilience.py fix(proxy): isolate get_config failures from model loading in sync loop 2026-02-26 17:49:44 -03:00