Commit Graph
2104 Commits
Author SHA1 Message Date
ConstantineandGitHub 3ebec39b74 fix(proxy): use async anthropic client to prevent event loop blocking (#18435)
Fixes #16716.
Previously, synchronous Anthropic client was used for token counting, which blocked the event loop.
This change switches to AsyncAnthropic and caches the client instance.
2026-01-08 23:26:46 +05:30
yuneng-jiangandGitHub e285e2b91d Merge pull request #18675 from BerriAI/litellm_key_team_routing_config
[Feature] Allow Add and Update for router_settings on Keys and Teams
2026-01-07 16:24:04 -08:00
Danial KhanandGitHub f126f75995 feat: pass server_tool_use and tool_search_tool_result blocks to anthropic (#18770)
* feat: Allow message types of server_tool_use and tool_search_tool_result to reach anthropic

* test: anthropic server tool use pass through testing
2026-01-08 00:47:28 +05:30
yuneng-jiang 140ce5fce2 Merge remote-tracking branch 'origin' into litellm_key_team_routing_config 2026-01-07 11:08:01 -08:00
yuneng-jiang 943445dd0f Adding test 2026-01-07 11:00:07 -08:00
yuneng-jiang 9a49bb293f Merge remote-tracking branch 'origin' into litellm_key_team_routing_config 2026-01-07 10:55:38 -08:00
yuneng-jiang 7da8d5fcd5 Merge remote-tracking branch 'origin' into litellm_endpoint_usage_breakdown 2026-01-07 10:25:43 -08:00
Ishaan Jaffer 6122ff9fce TestEncryptResponseId 2026-01-07 21:03:22 +05:30
Ishaan Jaffer b855ad5541 test_encode_decode_helpers_roundtrip_in_cache_context 2026-01-07 18:23:17 +05:30
Ishaan Jaffer dd67235d4d TestLevoIntegration 2026-01-07 18:17:22 +05:30
Ishaan Jaffer 3530218930 fix aupload_container_file 2026-01-07 14:19:36 +05:30
Yuta Saito 1d16a8526e feat: allow configuring project name for OpenTelemetry service name 2026-01-07 14:20:10 +09:00
yuneng-jiang 2a6f2a3fb8 add team member budget duration in team/update 2026-01-06 17:43:17 -08:00
yuneng-jiang ccfffc5de9 Add endpoint to aggregate activity tables 2026-01-06 15:54:03 -08:00
Alexsander HamirandGitHub bb4c01ffa0 Add LITELLM_DISABLE_LAZY_LOADING env var to fix VCR cassette creation issue (#18725) 2026-01-06 14:49:11 -08:00
Otavio BritoandGitHub 18ca6b2add Handle not supported region for vertex ai count tokens - v1/messages/count_tokens (#18665)
* Handle not supported region for vertex ai count tokens

* add unit test
2026-01-07 00:05:00 +05:30
Lize CaiandGitHub fe9b05e23e Add header for SAP AI Core Tracking (#18714)
Signed-off-by: Lize Cai <lize.cai@sap.com>
2026-01-06 23:59:02 +05:30
Kris XiaandGitHub 5e00a49e7f fix(streaming): normalize status code extraction to prevent 4xx errors from triggering mid-stream fallback (#18698)
在流式处理错误时,添加状态码标准化逻辑,确保 4xx 客户端错误直接抛出而不是被包装成 MidStreamFallbackError。

- 新增 _normalize_status_code 函数用于从异常对象提取状态码
- 优先从异常的 status_code 属性获取,其次从 response.status_code 获取
- 当映射异常或原始异常的状态码在 400-499 范围内时,直接抛出映射异常
- 添加单元测试验证 Vertex AI 400 错误正确抛出为 BadRequestError
- 确保流式处理中的客户端错误能够正确传播,而不会触发回退机制
2026-01-06 23:41:23 +05:30
Sameer KankuteandGitHub 353769d2ac Merge pull request #18688 from BerriAI/litellm_fix_reasoning_summary_default
[Fix] Put automatic reasoning summary inclusion behind feat flag
2026-01-06 17:56:40 +05:30
Sameer KankuteandGitHub 2baec27657 Revert "feat(model_cost): add display_name, model_vendor, and model_version metadata to model entries" 2026-01-06 15:29:42 +05:30
Sameer Kankute 865c7a2215 fix: test_update_ui_settings_allowlisted_value 2026-01-06 13:58:37 +05:30
Sameer Kankute 9d59d3eef6 fix: test_secret_manager_failure_does_not_block_email 2026-01-06 13:58:15 +05:30
Sameer Kankute 9f65f82c56 Fix: ImportError: qualifire package is required for QualifireGuardrail. Install it with: pip install qualifire 2026-01-06 13:52:26 +05:30
Sameer Kankute bb00a53786 Put reasoning summary behind feat flag 2026-01-06 11:36:20 +05:30
Sameer KankuteandGitHub 694e44551f Merge pull request #17330 from nmgarza5/add-model-metadata
feat(model_cost): add display_name, model_vendor, and model_version metadata to model entries
2026-01-06 10:56:49 +05:30
Sameer KankuteandGitHub 3c0248edb9 Merge pull request #18663 from BerriAI/litellm_staging_01_05_2026
Staging 01/05/2026
2026-01-06 10:46:04 +05:30
YutaSaitoandGitHub a774e7899c Merge pull request #18281 from Eric84626/main
Fix: fixed some MCP gateway oauth2 auth issues and ClosedResourceError
2026-01-06 13:22:46 +09:00
YutaSaitoandGitHub 31470032ad Merge pull request #18681 from BerriAI/litellm_feat_mcp-server-visibility-configurable
[feat] mcp server visibility configurable
2026-01-06 12:53:07 +09:00
YutaSaitoandGitHub ccdcb20048 Merge pull request #18279 from mangabits/fix-otel-provider
Use already configured opentelemetry providers
2026-01-06 12:49:48 +09:00
Yuta Saito 694bcb6186 feat: add user_mcp_management_mode for view_all visibility 2026-01-06 11:22:28 +09:00
yuneng-jiang 1b7b42628d Add/update for router_settings in keys / teams 2026-01-05 16:19:42 -08:00
Eric84626andGitHub f59e9cef55 Merge branch 'main' into main 2026-01-06 06:57:25 +08:00
Yuta Saito a8092ab4c4 fix: ensure_async_clients_test error 2026-01-06 07:13:13 +09:00
yuneng-jiangandGitHub 7937c8674b Merge pull request #18666 from BerriAI/litellm_keys_create_hour_fix
[Fix] Use timedelta to Calculate Key Expiry on Generate
2026-01-05 12:57:53 -08:00
yuneng-jiang c7345e4bfd Use timedelta to calculate key expiry 2026-01-05 12:24:34 -08:00
Urain Ahmad ShahandGitHub bf33e639ef Fix User Invite & Key Generation Email Notification Logic (#18524)
* Fix email notification

* Update email notification tests

* moved test file
2026-01-06 01:35:52 +05:30
drorIvryandGitHub b6a64ff99a feature/ add qualifire guardrails (#18594)
* init guardrails

* init guardrails

* some fixes

* some fixes

* ruff

* some fixes

* some fixes

* some fixes

* some fixes

* some fixes

* some fixes

* docs
2026-01-06 01:34:43 +05:30
Cesar GarciaandGitHub 0e601d0bfe Fix: Map Gemini cached_tokens to Langfuse cache_read_input_tokens (#18614)
* Fix: Map Gemini cached_tokens to Langfuse cache_read_input_tokens

Fixes #18520

## Problem
Langfuse integration was not capturing cached tokens from Gemini models.
Gemini returns cached tokens in `usage.prompt_tokens_details.cached_tokens`,
but Langfuse only read from top-level `usage.cache_read_input_tokens`
(which only Anthropic populates).

## Solution
Updated langfuse.py to check both locations:
1. First check top-level cache_read_input_tokens (for Anthropic)
2. Then check prompt_tokens_details.cached_tokens (for Gemini, OpenAI, others)

This ensures all providers' cached tokens are properly reported to Langfuse.

## Changes
- Modified litellm/integrations/langfuse/langfuse.py (lines 742-761)
- Added 3 unit tests in tests/test_litellm/integrations/langfuse/test_gemini_cached_tokens.py
- All existing Langfuse tests still pass (11/11)

## Testing
- test_cached_tokens_extraction: Verifies Gemini cached_tokens extraction
- test_cached_tokens_not_present: Backward compatibility (no cached_tokens)
- test_cached_tokens_is_zero: Edge case when cached_tokens = 0

* Refactor: Extract cache token logic into helper function

Address review feedback from @officer47p

- Created _extract_cache_read_input_tokens() helper function
- Reduces code bloat in _log_langfuse_v2 method
- Improves testability and reusability
- All tests still passing (11/11)
2026-01-06 01:34:09 +05:30
Alexsander HamirandGitHub 85a357c7e5 fix: extend case normalization to ALL guardrail types (not just tool_permission) (#18664)
This extends the previous fix to handle capitalized fields across ALL guardrail types,
including Presidio, Azure, Lakera, Bedrock, etc.

Discovery:
- Database investigation revealed the issue affects multiple guardrail types
- Found 4 affected guardrails in staging: 3 Presidio + 1 Azure
- All had default_action: 'Deny' causing the same validation failures
- The initial fix only covered ToolPermissionGuardrailConfigModel

Root Cause (Deeper):
- LitellmParams inherits from 13+ different guardrail config models
- Models use ConfigDict(extra="allow") allowing any field to be set
- Users can set default_action/on_disallowed_action on ANY guardrail type
- Only ToolPermissionGuardrailConfigModel was validating these fields

Solution:
- Added field validators to LitellmParams class (parent of all guardrails)
- Validators run for ALL guardrail types: Presidio, Azure, Bedrock, Lakera, etc.
- Added comprehensive tests covering multiple guardrail types

Changes:
- litellm/types/guardrails.py:
  * Added @field_validator for default_action in LitellmParams
  * Added @field_validator for on_disallowed_action in LitellmParams
  * Added normalization in LitellmParams.__init__ as backup
  * Imported field_validator from pydantic

- tests/test_litellm/types/test_guardrails_case_normalization.py:
  * New test file with 7 tests covering multiple guardrail types
  * Tests verify Presidio, Azure, Tool Permission, Lakera, Bedrock
  * All tests passing

Impact:
- Previous fix: Only tool_permission guardrails protected
- This fix: ALL guardrail types now protected (13+ types)
- Handles both new writes and existing database records
- Tested against actual database with Presidio/Azure guardrails

Testing:
- 7 new cross-guardrail tests (all passing)
- 27 existing tool_permission tests (all passing)
- Verified fix works for real database records
2026-01-05 11:59:00 -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
Nik 13db8e10dc feat: add display_name, model_vendor, and model_version metadata 2026-01-05 11:01:36 -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
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 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 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
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
Yuta Saito bdc35b4cd2 tests: mock LiteLLM_UserTable for CloudZero export 2026-01-05 17:23:04 +09:00