Commit Graph
29595 Commits
Author SHA1 Message Date
yuneng-jiang c7345e4bfd Use timedelta to calculate key expiry 2026-01-05 12:24:34 -08:00
b5aa7d1838 feat: Add api_key to GenericGuardrailAPI and set x-api-key header (#18647)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-01-06 01:05:51 +05:30
Alexsander HamirandGitHub 0b0a9abd90 fix: normalize case for tool permission guardrail fields to prevent validation errors (#18662)
This fixes a critical issue where capitalized values in tool_permission guardrail
configurations (e.g., "Deny" instead of "deny") caused Pydantic validation errors
during proxy startup, leading to repeated initialization failures and latency issues.

Problem:
- Users could save guardrails with capitalized values through UI/API
- Data was written to database without validation (e.g., default_action: "Deny")
- On proxy startup, loading from DB triggered strict Pydantic validation
- ValidationError caused guardrail initialization to fail in a retry loop
- This resulted in startup delays and repeated error logging

Root Cause:
- Write path had no case normalization
- Read path enforced strict lowercase Literal validation
- Asymmetry between write and read caused latent data corruption

Solution:
Added field validators to normalize case before Pydantic validation:

1. ToolPermissionRule.decision ("allow"/"deny")
   - Normalizes decision field in rules array

2. ToolPermissionGuardrailConfigModel.default_action ("allow"/"deny")
   - Normalizes default fallback action

3. ToolPermissionGuardrailConfigModel.on_disallowed_action ("block"/"rewrite")
   - Normalizes disallowed tool behavior

4. ToolPermissionGuardrail.__init__ normalization
   - Defensive normalization for direct instantiation
   - Ensures normalization regardless of code path

Impact:
- Prevents validation errors during guardrail initialization
- Eliminates startup retry loops and latency issues
- Handles existing database records with capitalized values
- Accepts case-insensitive input from all sources (UI, API, direct calls)
- Fully backward compatible with existing lowercase configurations

Testing:
- Added 3 comprehensive tests for case-insensitive handling
- All 27 existing tests still pass
- Tests verify normalization across all affected fields

Files Changed:
- litellm/types/proxy/guardrails/guardrail_hooks/tool_permission.py
  Added @field_validator decorators for case normalization
- litellm/proxy/guardrails/guardrail_hooks/tool_permission.py
  Added runtime normalization in __init__ method
- tests/test_litellm/proxy/guardrails/guardrail_hooks/test_tool_permission.py
  Added case-insensitive validation tests
2026-01-05 11:24:19 -08:00
Alexsander HamirandGitHub 3b847e0d9d refactor: migrate utils.py lazy imports to registry pattern (#18657)
* refactor: migrate utils.py lazy imports to registry pattern

- Refactored utils.py __getattr__ to use cached registry pattern (similar to __init__.py)
- Added UTILS_MODULE_NAMES tuple and _UTILS_MODULE_IMPORT_MAP to _lazy_imports_registry.py
- Added _get_utils_globals() helper function to _lazy_imports.py
- Added _lazy_import_utils_module() handler function for utils module lazy imports
- Updated _get_lazy_import_registry() to include utils module lazy imports
- Removed redundant _get_utils_globals() from utils.py (now in _lazy_imports.py)
- Added comprehensive tests for utils module lazy imports in test_lazy_imports.py

This refactoring:
- Reduces code duplication (from 670+ lines to ~10 lines in __getattr__)
- Improves maintainability (new lazy imports just need registry entry)
- Maintains consistency with __init__.py lazy import pattern
- All existing functionality preserved and tested

* Fix NameError: get_coroutine_checker not defined in check_coroutine function

* Fix lazy loading for get_coroutine_checker in function_setup and check_coroutine

- Add lazy loading for get_coroutine_checker at start of function_setup to ensure all calls use lazy-loaded version
- Fix check_coroutine function to use lazy loading pattern via getattr
- All direct calls to get_coroutine_checker() now properly use lazy import mechanism
2026-01-05 09:55:48 -08:00
Alexsander HamirandGitHub 4d3eb013b4 feat: lazy load DatadogLLMObsInitParams to reduce import time (#18658)
- Added DatadogLLMObsInitParams to TYPES_NAMES in _lazy_imports_registry.py
- Added import map entry for DatadogLLMObsInitParams in _TYPES_IMPORT_MAP
- Moved DatadogLLMObsInitParams import from module level to TYPE_CHECKING block in __init__.py
- Follows existing lazy import patterns for type classes
- Automatically tested by existing test_types_lazy_imports() function
2026-01-05 09:33:35 -08:00
orgersh92andGitHub d8d10f5e25 lasso-guardrail-api docs (#18652) 2026-01-05 20:58:26 +05:30
Ishaan Jaffer f752ec3eaf fix 2026-01-05 20:25:39 +05:30
Ishaan JaffandGitHub 2b3b16c86c [Feat] Litellm UI allow selecting many models for cost estimator (#18653)
* LiteLLM Cost Estimate

* fix - multi model selector

* v2 of report

* fixes

* export fix
2026-01-05 20:19:59 +05:30
Ishaan JaffandGitHub bf1c5bef59 [UI] Add view for estimating costs across requests (#18645)
* add estimate_cost endpoint

* TestCostEstimateEndpoint

* fix estimate_cost

* add /cost/estimate to spend tracking routes

* fix code QA checks

* fixes endpoint

* v0 cost estimator

* v0 cost estimator

* formatNumberWithCommas

* fix admin view

* docs

* docs fix + export PDF/CSV

* fixes for export
2026-01-05 19:19:58 +05:30
Sameer KankuteandGitHub d0a26dd4bc Merge pull request #18644 from BerriAI/litellm_fix_mapped_tests_05012026
Fix mapped tests 05012026
2026-01-05 17:53:17 +05:30
Sameer Kankute d3107ac61a revert litellm/litellm/llms/gemini/interactions/transformation.py 2026-01-05 17:37:01 +05:30
Sameer KankuteandGitHub 3c60b930e2 Merge pull request #18635 from BerriAI/litellm_completions_api_summary_param
(feat) Add mapping for reasoning effort to summary param of responses API
2026-01-05 17:36:21 +05:30
Sameer KankuteandGitHub 30096ffe5c Merge pull request #18637 from BerriAI/litellm_gemini_api_base_auth_fix
fix: auth header for custom api base in generate Content request
2026-01-05 17:35:47 +05:30
Sameer KankuteandGitHub 23fa88f64e Merge pull request #18638 from BerriAI/litellm_fix_custom_llm_providers_ui_testing
fix: Add custom llm provider to get_llm_provider when sent via UI
2026-01-05 17:34:50 +05:30
Sameer Kankute 2d7f0a1351 fix: test_create_simple_string_input 2026-01-05 17:15:12 +05:30
Sameer Kankute c0f74c994a Fix: test_transform_request_image_extraction 2026-01-05 17:02:54 +05:30
Sameer Kankute 935824e4f9 Fix : test_sap_chat[False] 2026-01-05 16:56:22 +05:30
Ishaan JaffandGitHub 7f4dba2a01 [Feat] Add Cost Estimator for AI Gateway (#18643)
* add estimate_cost endpoint

* TestCostEstimateEndpoint

* fix estimate_cost

* add /cost/estimate to spend tracking routes

* fix code QA checks

* fixes endpoint
2026-01-05 16:51:23 +05:30
Sameer Kankute 840617de73 fix: tests.test_litellm.interactions.test_gemini_interactions.TestGeminiInteractions 2026-01-05 16:41:24 +05:30
Matt GreathouseandGitHub b24156079f Add gemini-3-flash on openrouter (#18247) 2026-01-05 16:37:23 +05:30
Sameer Kankute d590c820c2 Fix: TypeError: Object of type function is not JSON serializable 2026-01-05 16:32:21 +05:30
Sameer KankuteGitHubCopilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
28c7659d3d Potential fix for code scanning alert no. 3954: Clear-text logging of sensitive information
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-01-05 16:06:10 +05:30
YutaSaitoandGitHub 165d5f3af1 Merge pull request #18640 from BerriAI/litellm_fix_cloudzero_integration_test
tests: mock LiteLLM_UserTable for CloudZero export
2026-01-05 17:41:22 +09:00
YutaSaitoandGitHub d5e4a43be3 Merge pull request #18639 from BerriAI/litellm_feat_mcp_global_mode
[feat] mcp global mode
2026-01-05 17:34:06 +09:00
Yuta Saito bdc35b4cd2 tests: mock LiteLLM_UserTable for CloudZero export 2026-01-05 17:23:04 +09:00
Yuta Saito ef2f76e5a5 fix: npm build error 2026-01-05 17:06:02 +09:00
Yuta Saito 7213f4a690 chore: lint 2026-01-05 16:57:39 +09:00
Yuta Saito fee9553c51 feat: add allow_all_keys doc 2026-01-05 16:56:19 +09:00
Yuta Saito 38a20b8036 feat: feat: allow_all_keys to mcp server on the UI 2026-01-05 16:28:51 +09:00
Sameer Kankute 6337ea876b fix: Add custom llm provider to get_llm_provider when sent via UI 2026-01-05 12:57:30 +05:30
Sameer Kankute 0730a74dda fix: auth header for custom api base in generate Content request 2026-01-05 12:25:13 +05:30
Yuta Saito f1d77ae14d feat: allow_all_keys to mcp server 2026-01-05 15:49:09 +09:00
Sameer Kankute 02a41a5c13 fix the comment 2026-01-05 11:40:40 +05:30
Sameer Kankute 0f8e4364d6 Replace summary param as detailed 2026-01-05 11:24:35 +05:30
Sameer Kankute 42d4aab3e7 Add mapping for reasoning effort to summary of responses API 2026-01-05 11:21:34 +05:30
YutaSaitoandGitHub b6664669d2 Merge pull request #18480 from hamzaq453/fix/openapi-parameter-names-security
Fix: Remove exec() usage and handle invalid OpenAPI parameter names
2026-01-05 14:34:57 +09:00
YutaSaitoandGitHub c405135c2b Merge pull request #18584 from BerriAI/feat/add_user_email_to_cloudzero
feat: add user email to cloudzero
2026-01-05 14:22:46 +09:00
hamzaq453 9ca7b1ad9b Resolve merge conflicts: integrate path validation with **kwargs approach
- Keep **kwargs approach (no exec()) for security
- Integrate path traversal validation from main branch
- Add URL encoding for path parameters
- Merge both test suites (edge cases + security tests)
- All 14 tests passing
2026-01-05 10:20:26 +05:00
YutaSaitoandGitHub ff6fd0c7f4 Merge pull request #18634 from BerriAI/litellm_refactor_bedrock_guardrail
refactor: remove redundant Bedrock guardrail block handling
2026-01-05 14:12:21 +09:00
Yuta Saito b37076bf2a refactor: remove redundant Bedrock guardrail block handling 2026-01-05 13:55:38 +09:00
YutaSaitoandGitHub fcabc059ca Merge pull request #18630 from BerriAI/litellm_fix_mcp_guardrail
fix: MCP handling in unified guardrail
2026-01-05 12:25:14 +09:00
amangupta-20andGitHub 399579f8ea feat: Add Levo AI integration (#18529) 2026-01-05 08:49:21 +05:30
Yuta Saito 0509fc79da fix: move code from litellm/llms to the mcp_server dir 2026-01-05 12:05:16 +09:00
Yuta Saito c8c73e6fa5 fix: MCP handling in unified guardrail 2026-01-05 10:41:24 +09:00
yuneng-jiangandGitHub 359b8df8b2 Merge pull request #18619 from BerriAI/litellm_ui_keys_loading_2
[Feature] UI - Virtual Keys Table Loading State Between Pages
2026-01-03 19:30:32 -08:00
yuneng-jiang 1112974112 Virtual Keys Table Loading State 2026-01-03 19:22:38 -08:00
yuneng-jiangandGitHub 280085edaa Merge pull request #18618 from BerriAI/litellm_ui_unit_test_coverage
[Infra] UI - Unit Tests: Adding Tests to Increase Coverage
2026-01-03 17:55:53 -08:00
yuneng-jiang 816124a40b Fixign build 2026-01-03 17:39:59 -08:00
yuneng-jiang 1184db079e fixing tests 2026-01-03 17:30:52 -08:00
yuneng-jiang 60c39255d5 Adding unit testing coverage 2026-01-03 17:25:46 -08:00