Commit graph

37495 commits

Author SHA1 Message Date
Ryan Crabbe
545db8c4e1
Merge remote-tracking branch 'origin/main' into litellm_chore-migrate-router-settings-page-off-of-tremor 2026-04-18 10:10:12 -07:00
Ryan Crabbe
746d10f1dd
Merge remote-tracking branch 'origin/main' into litellm_chore-migrate-guardrail-test-playground-off-tremor 2026-04-18 10:06:55 -07:00
yuneng-jiang
18a5fe546a
Merge pull request #25998 from BerriAI/litellm_/wonderful-bouman
[Feature] UI - Settings: Claude Code BYOK support
2026-04-18 09:29:41 -07:00
Yuneng Jiang
ecf65f5d61
Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_yj_apr17 2026-04-18 09:16:59 -07:00
Ryan Crabbe
48fb19b4fd
fix: align test assertion with additive merge semantics
test_virtual_key_max_budget_alert_check_per_key_overrides_global asserted
override semantics but the implementation does additive merge. Renamed test
and updated assertion to match: per-key and global thresholds are unioned,
not replaced.
2026-04-17 23:46:40 -07:00
Ryan Crabbe
e2e5b63b41
fix(ui): revert submit guard to allow intentional extra_headers clearing
The ?.length guard prevented intentional clears from persisting — send
the form value as-is since initialValues now populates it correctly.
2026-04-17 23:24:46 -07:00
Ryan Crabbe
c28877757c
fix(ui): extra_headers not persisting on MCP server edit
Set extra_headers explicitly in initialValues instead of relying on
a useEffect setFieldValue call that races with Antd form initialization.
Also avoid sending empty array on submit so the backend's exclude_none
doesn't overwrite stored values.
2026-04-17 22:48:39 -07:00
Ryan Crabbe
ec564f5e00
fix: resolve mypy errors in multi-threshold budget alerts
- Add early return guard in _handle_multi_threshold_max_budget_alert
  for None max_budget_alert_emails and max_budget
- Add explicit type annotation on alert_email_config in auth_checks
2026-04-17 21:51:41 -07:00
Yuneng Jiang
e004876950
Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_/wonderful-bouman
# Conflicts:
#	tests/test_litellm/proxy/ui_crud_endpoints/test_proxy_setting_endpoints.py
2026-04-17 21:32:09 -07:00
Yuneng Jiang
6fe79035d9
[Fix] UI - Settings: clarify Max-subscription vs BYOK toggle descriptions (independent of each other) 2026-04-17 21:21:43 -07:00
Yuneng Jiang
acb4f89254
[Fix] UI - Models: clarify Anthropic api_base label and tooltip to prevent recursive-loop misconfiguration 2026-04-17 21:18:35 -07:00
shivam
e8c33409ad
test: add coverage for get_project_model_rpm/tpm_limit and check_complete_credentials
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-17 19:38:13 -07:00
Shivam Rawat
37765e679f
Merge branch 'litellm_internal_staging' into litellm_pages_support_for_ocr 2026-04-17 19:29:45 -07:00
shivam
a449fc11a6
Merge branch 'litellm_internal_staging' into litellm_project_rate_limiting 2026-04-17 19:10:06 -07:00
shivam
fad884e9a7
Merge branch 'litellm_internal_staging' into litellm_persist_default_router_end_budget 2026-04-17 19:06:32 -07:00
Ryan Crabbe
c1503d3088
fix: escape user-controlled greeting in max budget alert email template
html.escape() the greeting (user_email/key_alias/token fallback) before
inserting into HTML email body to prevent HTML injection via key_alias.
2026-04-17 18:52:13 -07:00
yuneng-jiang
0b50a29baf
Merge pull request #25995 from BerriAI/litellm_fixBedrockTestMergeMarkers
[Fix] Remove unresolved merge conflict markers in bedrock test file
2026-04-17 18:37:50 -07:00
Yuneng Jiang
a282ac4170
[Fix] Remove unresolved merge conflict markers in bedrock test file
Fixes SyntaxError at pytest collection time caused by leftover
<<<<<<<, =======, >>>>>>> markers in test_bedrock_common_utils.py.
Keeps the assertion matching the model under test
(claude-haiku-4-5-20251001-v1:0).
2026-04-17 18:23:49 -07:00
shivam
6fd49f1da1
fix: enforce project-level model-specific rate limits in parallel_request_limiter_v3
Project-level model rpm/tpm limits stored in project_metadata were never
checked during rate limit enforcement — only model-level limits applied.

Adds _add_project_model_rate_limit_descriptor_from_metadata() to the v3
limiter (mirrors the existing team metadata path) and calls it in
async_pre_call_hook, creating a model_per_project descriptor keyed as
"{project_id}:{model}" with the project's configured limits.

Also extends get_model_rate_limit_from_metadata's Literal to accept
"project_metadata" and adds get_project_model_rpm/tpm_limit helpers.

Fixes: LIT-2317

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-17 18:17:24 -07:00
Ryan Crabbe
44eb2ea56e
fix: address Greptile review — empty recipients guard, type annotation, task pre-filter
- Guard empty recipients in _handle_multi_threshold_max_budget_alert:
  log warning and skip instead of falling through to old path error loop
- Widen max_budget_alert_emails type to Dict[str, Union[str, List[str]]]
  to match _parse_email_list runtime behavior (accepts comma-separated strings)
- Pre-filter asyncio.create_task with min threshold check to avoid
  unnecessary task allocation on every request when spend is below
  all configured thresholds
2026-04-17 17:54:16 -07:00
Krrish Dholakia
bb9955beca
[Fix] Budget reset job now resets implicitly-created end users with NULL budget_id
When litellm.max_end_user_budget_id is configured, implicitly-created end users
(via /chat/completions) have budget_id=NULL in the DB since the default budget
is only applied in-memory. The budget reset job filtered by budget_id, so these
users were never reset and eventually permanently blocked.

Fix: when the default budget is in the reset list, also query for and reset
end users with budget_id=NULL and spend > 0. This keeps the hot auth path
unchanged (no DB writes on every request).

Fixes #22019

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-17 17:49:33 -07:00
Ryan Crabbe
41a719a537
feat: add global fallback config, fix no-owner crash, improve email greeting
- Add `default_key_max_budget_alert_emails` litellm_settings config as
  global fallback for all virtual keys (per-key metadata takes priority)
- Fix crash when key has no user_id/user_email by passing recipient email
  to _get_email_params (same pattern as team soft budget path)
- Use owner email for greeting, falling back to key_alias or token
- Rename setting from default_max_budget_alert_emails to
  default_key_max_budget_alert_emails for clarity
2026-04-17 17:49:28 -07:00
Krrish Dholakia
89365628c9
[Fix] Persist default end-user budget_id to DB so budget reset job picks up implicitly created users
Previously, _apply_default_budget_to_end_user() only set the budget in-memory,
leaving budget_id NULL in the database. This caused the budget reset job to skip
these users since it filters by budget_id. Now the function also persists
budget_id via a Prisma update call (non-fatal on failure).

Fixes #22019

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-17 17:48:54 -07:00
Yuneng Jiang
11c3270cdc
Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_yj_apr17
# Conflicts:
#	litellm/__init__.py
2026-04-17 17:36:40 -07:00
Ryan Crabbe
ea509ec6b9
Run key budget alert check before max-budget enforcement
_virtual_key_max_budget_check raises BudgetExceededError when spend
crosses max_budget, which meant the 100% threshold in the multi-threshold
email config never got a chance to fire — the request that pushes spend
over 100% was rejected before the alert check ran. Reorder so the alert
check runs first; enforcement still raises right after.
2026-04-17 17:32:39 -07:00
yuneng-jiang
b9f5be8956
Merge pull request #25922 from BerriAI/litellm_a2a_agent_acl
[Fix] Agent endpoint and routing permission checks
2026-04-17 17:19:59 -07:00
Ryan Crabbe
779a9fab8e
feat: add configurable multi-threshold budget alerts for virtual keys
Users can set metadata.max_budget_alert_emails as a JSON map of threshold
percentages to email recipients on virtual keys. When configured, the email
handler loops over each threshold, checks per-threshold dedup cache, and
sends to the configured recipients (auto-including the key owner's email).

When no map is set, the existing single 80% threshold behavior is preserved
unchanged. Teams support is out of scope for this v0.
2026-04-17 17:12:35 -07:00
ishaan-berri
1c128a86b8
Merge pull request #25256 from BerriAI/litellm_ishaan_april6
Some checks are pending
Unit Tests: Proxy DB Operations / proxy-db (auth-checks, tests/proxy_unit_tests/test_auth_checks.py tests/proxy_unit_tests/test_user_api_key_auth.py, 20, 8) (push) Waiting to run
Unit Tests: Proxy DB Operations / proxy-db (key-generation, tests/proxy_unit_tests/test_key_generate_prisma.py, 30, 0) (push) Waiting to run
Unit Tests: Proxy DB Operations / proxy-db (remaining, tests/proxy_unit_tests --ignore=tests/proxy_unit_tests/test_key_generate_prisma.py --ignore=tests/proxy_unit_tests/test_auth_checks.py --ignore=tests/proxy_unit_tests/test_user_api_key_auth.py, 30, 8) (push) Waiting to run
Unit Tests: Security / security (push) Waiting to run
Litellm ishaan april6
2026-04-17 16:26:45 -07:00
Ishaan Jaffer
e6a20af646
fix(proxy-extras): skip post-deploy sanity check when no migrations pending
When prisma migrate deploy reports 'No pending migrations to apply' the DB
already matches schema — running _resolve_all_migrations (migrate diff +
prisma db execute) adds 25+ seconds unnecessarily, causing the proxy to
miss the 90-second startup timeout in test_litellm_proxy_server_config_no_general_settings.
2026-04-17 15:59:41 -07:00
Ishaan Jaffer
e073feec0a
fix(ui): rename claude-code-plugins to skills in page_metadata.ts
page_utils.test.ts enforces that every menuGroups entry has a matching
description and vice versa. The left nav uses 'skills' but page_metadata.ts
still had 'claude-code-plugins', causing two test failures.
2026-04-17 15:49:24 -07:00
Ishaan Jaffer
33175a8ee7
fix(proxy-extras): fall back to prisma db execute when migrate diff fails on pooler URL
When DIRECT_URL is not set and DATABASE_URL is a Neon pooler URL, prisma migrate diff
fails (pooler doesn't support extended query protocol for schema introspection). Previously
_resolve_all_migrations returned early without applying any migrations, leaving the
budget_limits column missing and causing test_auth_callback_new_user to fail.

Now falls back to running each migration SQL file via prisma db execute --file, which
works with pooler URLs and is safe to re-run due to IF NOT EXISTS guards.
2026-04-17 15:38:48 -07:00
Ishaan Jaffer
70456fb8bb
fix(ui): update add_plugin_form tests to match rewritten smart URL form 2026-04-17 15:17:21 -07:00
Ishaan Jaffer
33a2cee4af
fix(proxy-extras): use DIRECT_URL for prisma migrate diff, tempfile for diff dir 2026-04-17 15:17:15 -07:00
Yuneng Jiang
ee2cf0e6e8
fix: address three CI failures from recent security PR merges
- url_utils.py: narrow sockaddr[0] from str|int to str via a helper with a
  fail-closed isinstance check. Fixes the two mypy errors introduced by
  the SSRF hardening without masking unexpected stdlib behavior.

- key_management_endpoints.py: restore the documented team member_permissions
  path for /key/update. The cross-key admin check added to close the
  cross-org rewrite attack was over-broad: it rejected non-admin team
  members even when can_team_member_execute_key_management_endpoint had
  already validated their team membership and /key/update grant. Now skip
  the admin check when the key has a team_id and the change is non-budget
  (membership + permission already enforced above). Budget/spend changes
  still require team/org admin. The cross-org attack remains blocked:
  an outside org admin fails the earlier team membership check.

- test_logging_redaction_e2e_test.py: rename and rewrite two parametrized
  tests to assert that request-body turn_off_message_logging has no effect.
  Reflects the intentional removal of turn_off_message_logging from
  _supported_callback_params so the caller cannot override admin logging
  policy via the request body.

- test_key_management_endpoints.py: add two tests covering the restored
  team member permission path — one positive (non-budget update succeeds
  for a team member with /key/update grant), one negative (max_budget
  change still rejected without admin role).
2026-04-17 15:11:45 -07:00
Ishaan Jaffer
7c47bbd226
fix(migration): run schema sanity check after P3009/P3018 idempotent migration recovery 2026-04-17 15:01:10 -07:00
yuneng-jiang
6a9f8f7772
Merge pull request #25972 from BerriAI/litellm_yj_apr16
[Infra] Merge dev branch
2026-04-17 14:58:52 -07:00
Ishaan Jaffer
9281147a1a
fix(schema): add budget_limits Json? to LiteLLM_TeamTable and LiteLLM_VerificationToken 2026-04-17 14:47:18 -07:00
Ishaan Jaffer
b91a6f52b7
fix(schema): add budget_limits Json? to LiteLLM_TeamTable and LiteLLM_VerificationToken 2026-04-17 14:47:12 -07:00
Ishaan Jaffer
7239ed60e9
fix(schema): add budget_limits Json? to LiteLLM_TeamTable and LiteLLM_VerificationToken 2026-04-17 14:47:05 -07:00
Ishaan Jaffer
7b3480a94a
fix(team_delete): exclude budget_limits and default_team_member_models from deleted team record 2026-04-17 14:42:09 -07:00
Ishaan Jaffer
574633fcf1
fix(key_delete): exclude budget_limits from deleted verification token record 2026-04-17 14:21:39 -07:00
Ishaan Jaffer
6636329f69
fix(proxy): revert budget exceeded error code from 429 to 400 2026-04-17 14:02:04 -07:00
Ishaan Jaffer
b4df07a244
style(prometheus): apply Black formatting to types/integrations/prometheus.py 2026-04-17 13:49:27 -07:00
Ishaan Jaffer
2808cb908c
style(prometheus): apply Black formatting to prometheus.py 2026-04-17 13:49:24 -07:00
Ishaan Jaffer
7867497751
style(github_copilot): revert authenticator.py to origin/main formatting 2026-04-17 13:45:50 -07:00
Ishaan Jaffer
9de041f8ee
style(prometheus): sync types/integrations/prometheus.py formatting with origin/main 2026-04-17 13:45:22 -07:00
Ishaan Jaffer
2395a2db4d
style(prometheus): sync prometheus.py formatting with origin/main 2026-04-17 13:45:19 -07:00
Ishaan Jaffer
b7aa045de1
style(github_copilot): shorten __init__ docstring to avoid Black edge case 2026-04-17 13:33:14 -07:00
Yuneng Jiang
1e25a00e5d
[Docs] BYOK tutorial: document the UI-only configuration path 2026-04-17 13:32:17 -07:00
Yuneng Jiang
7eae18d158
[Feature] UI - Settings: toggle row for forward_llm_provider_auth_headers 2026-04-17 13:32:17 -07:00