Commit Graph
1466 Commits
Author SHA1 Message Date
Igal BoxermanandGitHub e6e1e8fca4 feat(pillar): add automatic LiteLLM context headers (#17076)
- Automatically pass LiteLLM virtual key context as X-LiteLLM-* headers
- Includes key_alias, user_id, team_id, org_id, and user_email
- No configuration required - always enabled for application/user tracking
- Excludes sensitive data (metadata, API tokens) for security
- Add comprehensive tests (30 tests, all passing)
- Update documentation with header details
2025-11-25 19:35:39 -08:00
Sameer KankuteandGitHub cd65a84abd Merge pull request #16844 from Chesars/fix/response-format-to-text-format-bridge-conversion
fix: Support response_format parameter in completion -> responses bridge
2025-11-26 08:51:09 +05:30
Kerem TurgutluandGitHub 8637d74e17 include server_tool_use in streaming usage (#16826)
* include server_tool_use in streaming usage

* add test
2025-11-25 14:50:17 -08:00
Sameer KankuteandGitHub 67622fb040 Add day 0 support for anthropic new feat (#17091)
* Added tool search support for anthropic

* Add programtic tool calling support

* Add tool use input examples support

* Add anthropic effort param support

* Add anthropic effort param support

* Add blog for new features

* fix mypy and lint errors

* fix mypy and lint errors

* fix mypy and lint errors

* fix mypy and lint errors

* Add better handling

* Add better handling
2025-11-25 11:28:47 -08:00
Sameer KankuteandGitHub 3249f6dd2d Merge pull request #17070 from BerriAI/litellm_add_vertex_ai_image_support
Add vertex ai image gen support for both gemini and imagen models
2025-11-26 00:04:03 +05:30
Sameer KankuteandGitHub 83a9dcd2d2 Merge pull request #16886 from BerriAI/litellm_anthopic_azure_support
Added support for azure anthopic models via chat completion
2025-11-26 00:03:52 +05:30
Sameer KankuteandGitHub 2e50db81a5 Merge pull request #17071 from BerriAI/litellm_azure_gpt_5_reasoning
Fix `reasoning_effort="none"` not working on Azure for GPT-5.1
2025-11-25 23:59:25 +05:30
00e17c81a1 Add enforce user param functionality (#17088)
* feat: Add reject_metadata_tags to proxy config

Co-authored-by: krrishdholakia <krrishdholakia@gmail.com>

* Refactor: Rename reject_metadata_tags to reject_clientside_metadata_tags

Co-authored-by: krrishdholakia <krrishdholakia@gmail.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-11-25 09:36:24 -08:00
Sameer KankuteandGitHub e0396e5fa7 Merge pull request #17082 from BerriAI/main
merge main
2025-11-25 18:49:52 +05:30
Sameer Kankute e2f2ccd913 Add tests related messages api 2025-11-25 18:45:51 +05:30
Sameer Kankute c149ade6a8 Add tests related to reasoning param none 2025-11-25 13:57:15 +05:30
Sameer Kankute a50083a87b Remove none support from reasoning param 2025-11-25 13:56:30 +05:30
Sameer Kankute 883cfaeeaf Add tests 2025-11-25 13:32:13 +05:30
wcyatandGitHub 6dcb5425a5 fix(vertex): fix CreateCachedContentRequest enum error (#16965)
* feat: add _fix_enum_types function to remove enums from non-string fields in schema

* test: add test for _fix_enum_types function to validate enum removal from non-string fields
2025-11-24 21:24:29 -08:00
Saar wintrovandGitHub cfd35d3b14 Metadata: fix 401 when audio/transcriptions (#17023)
* Metadata: fix 401 when audio/transcriptions

* check if str, CR fixes
2025-11-24 20:56:27 -08:00
Cesar GarciaandGitHub 650b18974f fix(gemini): skip thinking config for image models (#17027)
* fix(gemini): exclude image models from automatic thinking_level parameter (#17013)

- gemini-3-pro-image-preview does not support thinking_level parameter
- Added check to skip adding thinkingConfig for models containing "image"
- Fixes BadRequestError: "Thinking level is not supported for this model"
- Only affects automatic default behavior, user can still pass reasoning_effort explicitly

Fixes #17013

* test: add tests for gemini-3 image models thinking_level exclusion

* update docs
2025-11-24 20:54:12 -08:00
yuneng-jiangandGitHub d2b3ef0667 Add aws_bedrock_runtime_endpoint into Credential Types (#17053) 2025-11-24 20:48:51 -08:00
yuneng-jiangandGitHub 3f5a34d72c Deleting a user from team deletes key user created for team (#17057) 2025-11-24 20:47:43 -08:00
Raghav JhavarandGitHub bd8196f982 (fix) propagate x-litellm-model-id in responses (#16986)
* propagate model id on errors too

* make it work for messages and streaming

* fix

* cleanup

* cleanup

* final

* cleanup

* clean up method name and fix responses api streaming

* remove comment
2025-11-24 20:40:43 -08:00
Sameer KankuteandGitHub 282ac87617 Add temperature support for 5.1 models (#17011) 2025-11-24 18:54:22 -08:00
Sameer KankuteandGitHub 35bfcac3bc Add header forwarding in embedding (#16869) 2025-11-24 18:48:10 -08:00
Sameer KankuteandGitHub c6fbdc7dc5 fix bedrock passthrough auth issue (#16879) 2025-11-24 18:44:59 -08:00
Sameer KankuteandGitHub 3b6c170739 Fix the azure auth format for videos (#17009)
* fix the azure auth in correct format

* Add litellm param in validate_environment method

* fix lint errors
2025-11-24 17:40:55 -08:00
Sameer KankuteandGitHub 629404a100 Add cost tracking for cohere embed passthrough endpoint (#17029)
* Add cost tracking for cohere embed passthrough endpoint

* update passthrough code

* update passthrough code

* fixed lint and mypy errors
2025-11-24 17:39:26 -08:00
62b84d6aad Prompt security litellm (#16365)
* add prompt security guardrails provider

* cosmetic

* small

* add file sanitization and update context window

* add pdf and OOXML files support

* add system prompt support

* add tests and documentation

* remove print

* fix PLR0915 Too many statements (96 > 50)

* cosmetic

* fix mypy error

* Fix failed tests due to naming conflict of responses directory with same-named pip package

* Fix mypy error: use 'aembedding' instead of 'embeddings' for async embedding call type

* Fix: Install enterprise package into Poetry virtualenv for tests

The GitHub Actions workflow was installing litellm-enterprise to system Python
using 'python -m pip install -e .', but tests run in Poetry's virtualenv using
'poetry run pytest'. This caused ImportError for enterprise package types.

Changed to 'poetry run pip install -e .' so the package is available in the
same virtualenv where pytest executes.

Fixes enterprise test collection errors in GitHub Actions CI.

* Move Prompt Security guardrail tests to tests/test_litellm/

Per reviewer feedback, move test_prompt_security_guardrails.py from
tests/guardrails_tests/ to tests/test_litellm/proxy/guardrails/ so
it will be executed by GitHub Actions workflow test-litellm.yml.

This ensures the Prompt Security integration tests run in CI.

---------

Co-authored-by: Ori Tabac <oritabac@prompt.security>
Co-authored-by: Vitaly Neyman <vitaly@prompt.security>
2025-11-24 11:44:20 -08:00
John LathouwersandGitHub 61fed95f8c OCI Provider: Fix pydantic validation errors during tool call with streaming. (#16899)
* logic to handle missing required fields in OCI streaming tool calls

* Fix test mocks
2025-11-23 22:03:44 -08:00
adfdcf1d61 [Fix] UI - Hide Default Team Settings From Proxy Admin Viewers (#16900)
* Add fallback in sort to prevent NoneType and str comparison

* Hide Default Team Settings from Proxy Admin Viewers

---------

Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
2025-11-23 22:01:38 -08:00
yuneng-jiangandGitHub 013dcd837f Change provider create fields to JSON (#16985) 2025-11-23 21:57:22 -08:00
soo-jin.kimandGitHub a2a45ce8c9 fix: prevent duplicate spend logs in Responses API for non-OpenAI providers (#16992)
* fix: prevent duplicate spend logs in Responses API for non-OpenAI providers

Fixes #15740

This fixes a logging duplication bug where using kwargs.pop() removed
the litellm_logging_obj before passing kwargs to internal acompletion()
calls, causing duplicate spend log entries for providers without native
Responses API support (Anthropic, Gemini, etc).

By changing from pop() to get(), the logging object is preserved and
reused across the internal completion call, preventing duplicate entries
and maintaining correct cost tracking.

* test: add test for logging object preservation in responses API

Verify that litellm_logging_obj is preserved in kwargs when calling
responses(), ensuring no duplicate spend log entries are created.
2025-11-23 21:57:01 -08:00
7cc92d1ced fix(vertex_ai): handle global location in context caching (#16997)
- Add conditional check for 'global' vertex_location
- Use aiplatform.googleapis.com (no prefix) for global endpoint
- Apply fix to both v1 and v1beta1 APIs
- Matches existing behavior in regular completion calls

Fixes context caching 404 errors when using global location.
Regular completion already handles global correctly, this brings
context caching in line with that behavior.

Related: #11190, #9234

Co-authored-by: prawaan-singh <prawaan.singh@thoughtspot.com>
2025-11-23 21:55:08 -08:00
YutaSaitoandGitHub b72b49757e feat: add backend support for OAuth2 auth_type registration via UI (#17006) 2025-11-23 21:52:18 -08:00
YutaSaitoandGitHub 06f2ecef42 feat: tool permission argument check (#16982) 2025-11-22 19:21:25 -08:00
Krrish Dholakia cc5ecfd479 test: fix tests 2025-11-22 16:50:50 -08:00
Krish DholakiaandGitHub 270d23939e (fix) litellm_logging.py: fix mcp tool call response logging + (fix) responses_bridge: remove unmapped param error mid-stream - allows gpt-5 web search to work via responses api in .completion() (#16946)
* fix: fix getting mcp servers

* fix(litellm_logging.py): handle list objects for final response in standard logging payload

Fixes issue where mcp tool call response wouldn't show up

* fix(litellm_responses_transformation/): remove invalid item error for unmapped objects - breaks stream and there's no real value to this as outside of a few of them, not all can be mapped to chat completions

resolves error for web search calls via chat completions to responses api
2025-11-22 15:48:32 -08:00
Krish DholakiaandGitHub e11d34eb69 Permission Management - disable global guardrails by key/team (#16983)
* feat(teams.py): param for disabling guardrails by team

allows use-case where you don't run global guardrails for team - only run team-specific guardrails

* feat(custom_guardrail.py): add support for disabling global guardrails

only run guardrails requested for in the request/key/team

* feat: support adding disable_global_guardrails to metadata if present in key/team metadata

* feat(create_key_button.tsx): new disable global guardrails field

* feat(key_edit_view.tsx): support disabling global guardrails on key edit

* feat(teams.tsx): add disable global guardrails on create team on UI

* feat(team_info.tsx): allow disabling global guardrails on team update
2025-11-22 15:43:50 -08:00
yuneng-jiangandGitHub 825f61b452 Remove expired proxy admin keys from cache (#16894) 2025-11-22 14:23:28 -08:00
yuneng-jiangandGitHub 22fd323d6b Calling team/permissions_list and team/permissions_update now returns 404 with non-existent team (#16835) 2025-11-22 14:21:58 -08:00
Alexsander HamirandGitHub b02baf53a9 Fix: prevent memory blowout in LoggingWorker (#16559)
* fix: prevent memory blowout in LoggingWorker

Tasks were being executed sequentially with each task awaited before
processing the next one. When the queue had 10k+ tasks, only one could
execute at a time. Since the request rate exceeded execution speed,
objects accumulated in memory (50k+), holding references to heavy
objects and causing memory blowout.

The new implementation uses a semaphore to allow up to 1000 concurrent
tasks while properly tracking and cleaning up each task, significantly
improving throughput and preventing queue buildup.

* fix: require semaphor before removing task from queue

* fix: make worker concurrency configurable

* fix: clean comments

* fix: clarify new env purpose

* fix: add missing lib

* make constants configurable instead of hardcoded

* add more aggressive cleaning when queue is full

* add helpers function for the aggressive cleaning functionality

* use envs instead of static constants

* import and document constants

* add unit test for new functionality

* fix default value on config_settings

* fix: remove unused variables and imports to resolve linter errors

- Remove unused time_since_last_clear variable in logging_worker.py
  The variable was calculated but never used in _handle_queue_full()
  method, causing F841 linter error.

- Remove unused TYPE_CHECKING import in mcp_server/server.py
  The import was not used anywhere in the file, causing F401 linter error.

These changes improve code cleanliness and ensure the codebase passes
all linter checks without affecting functionality.

* add missing log expected by test_queue_full_handling

* fix: clean config_setting.md file

* fix: handle logging errors gracefully during shutdown in _flush_on_exit

During process shutdown, logging handlers may be closed while _flush_on_exit
tries to flush queued logging coroutines. This causes 'ValueError: I/O
operation on closed file' errors when coroutines attempt to log.

Changes:
- Add _safe_log helper method that wraps logging calls and suppresses
  errors when logging handlers are closed (ValueError, OSError, AttributeError)
- Replace all verbose_logger calls in _flush_on_exit with _safe_log
- Remove logging from exception handler in coroutine execution loop
  to prevent cascading errors during shutdown

This ensures graceful shutdown even when logging handlers are closed,
which is common during process termination.
2025-11-22 13:58:29 -08:00
Krish DholakiaandGitHub ac3aa74c22 (feat) Anthropic - support Structured Outputs output_format for Claude 4.5 sonnet and Opus 4.1 + Arize Phoenix - root span logging (#16949)
* feat(anthropic/chat/transformations): for claude-4-5-sonnet and opus-4-1 support passing structured output to anthropic api

* docs: document new feature

* fix: fix output format

* fix: cleanup

* fix(transformation.py): conditionally pass in json tool call

* fix: support ARIZE_SPACE_ID instead of ARIZE_SPACE_KEY

* docs(arize_integration.md): cleanup arize docs

* feat(callback_info_helpers.tsx): allow setting arize space id via ui

* fix: fix linting error

* fix(opentelemetry.py): working arize phoenix root span tracing
2025-11-22 12:08:26 -08:00
Ishaan Jaffer f5c8136243 fix docker model runner tests 2025-11-22 11:07:56 -08:00
Ishaan Jaffer 725982f39e test_dotprompt_with_prompt_version 2025-11-22 11:00:47 -08:00
Ishaan Jaffer 9ea74a1aa9 TestDockerModelRunnerIntegration 2025-11-22 10:46:12 -08:00
Alexsander HamirandGitHub ca2a27c377 fix: add missing mock attributes in websocket and realtime tests (#16974)
- Add scope and url attributes to WebSocket mock in test_user_api_key_auth_websocket
- Add shared_realtime_ssl_context initialization in realtime handler test
2025-11-22 10:44:23 -08:00
Ishaan Jaffer 65b842b6b4 test fix 2025-11-22 10:26:32 -08:00
Ishaan Jaffer 5c289df374 test url with format 2025-11-22 10:10:08 -08:00
Alexsander HamirandGitHub 9a0658084b Fix SSL test failures due to caching and test isolation issues (#16973)
This commit fixes two critical test failures and two test isolation issues
in the SSL configuration tests.

## Critical Test Failures Fixed

### 1. test_get_ssl_configuration
**Problem:** Test was failing with assertion error that ssl.create_default_context
was never called (expected 1 call, got 0).

**Root Cause:** The get_ssl_configuration() function uses a caching mechanism
(_ssl_context_cache) to avoid creating duplicate SSL contexts with the same
configuration. When tests run in sequence, a previous test may have created an
SSL context with the same configuration (same cafile, ssl_security_level,
ssl_ecdh_curve). When this test runs, it retrieves the cached context instead
of creating a new one, so ssl.create_default_context() is never called, causing
the mock assertion to fail.

**Fix:** Clear the SSL context cache at the start of the test to ensure a fresh
context is created, allowing the mock to be called and verified.

### 2. test_ssl_ecdh_curve
**Problem:** Test was failing with assertion error that set_ecdh_curve was
never called (expected 1 call, got 0).

**Root Cause:** Same caching issue as above. Additionally, the test needed to
use a real SSLContext instance instead of a MagicMock because _create_ssl_context
calls methods like set_ciphers() and minimum_version that require a real context.

**Fix:**
- Clear the SSL context cache at the start of the test
- Use a real SSLContext instance and patch set_ecdh_curve on it specifically
- Added explanatory comment about why a real context is needed

## Test Isolation Issues Fixed

### 3. test_ssl_security_level
**Problem:** Test was failing because it expected LiteLLMAiohttpTransport but
got httpx.AsyncHTTPTransport instead.

**Root Cause:** Test isolation issue. Other tests in the file (test_force_ipv4_transport,
test_aiohttp_disabled_transport) set litellm.disable_aiohttp_transport = True
but don't restore the original value. When this test runs after those tests,
aiohttp transport is disabled, causing it to use httpx transport instead.

**Fix:** Explicitly enable aiohttp transport at the start of the test and restore
the original value in a finally block, ensuring the test works regardless of
test execution order.

### 4. test_ssl_verification_with_aiohttp_transport
**Problem:** Same as above - expected LiteLLMAiohttpTransport but got
httpx.AsyncHTTPTransport.

**Root Cause:** Same test isolation issue - aiohttp transport disabled by
previous tests.

**Fix:** Same approach - explicitly enable aiohttp transport and restore
original value in finally block.

## Why These Fixes Work

1. **Cache clearing:** By clearing _ssl_context_cache before each test, we
   ensure that get_ssl_configuration() creates a fresh SSL context, allowing
   mocks to be properly called and verified.

2. **Test isolation:** By saving and restoring the disable_aiohttp_transport
   setting, tests are independent of each other and work correctly regardless
   of execution order.

These are minimal, targeted fixes that address the root causes without
modifying production code or affecting other functionality.
2025-11-22 10:07:30 -08:00
Ishaan Jaffer ee758914e0 test docker model runner 2025-11-22 10:06:14 -08:00
Ishaan Jaffer 3235807d68 test prompt manager 2025-11-22 10:05:55 -08:00
Ishaan Jaffer b2812af0a0 fix MCP tests 2025-11-22 10:02:15 -08:00
Alexsander HamirandGitHub eb5031da1e [Perf] Fix bottlenecks degrading realtime endpoint performance (#16670)
* Cache realtime websocket request body

Move the realtime request payload builder out of the websocket handler and wrap it with an LRU cache so repeated connections reuse the same bytes object. This keeps the JSON formatting cost down while bounding memory usage.

* Optimize realtime websocket caching

Refactored /v1/realtime to use cached helpers for both the JSON body and query params, introduced a reusable request-scope template, and optimized header handling to avoid redundant work.

* Refine realtime websocket header handling

* Reuse websocket scope headers in auth

* Refactor realtime request body helper

Move the realtime request body formatter into proxy common utils so it can be reused across modules. Reuse it in the websocket auth flow to share LRU caching and avoid ad hoc byte builders.

* fix: revert to old pattern

The old pattern was necessary, we can just return the optimized function instead.

* Reuse SSL context for realtime

Create a shared SSLContext for OpenAI realtime websocket dials and pass it into websockets.connect so we stop re-reading verify paths on every session.

* feat: reuse shared TLS context for realtime websockets

- add `SHARED_REALTIME_SSL_CONTEXT` helper so all realtime websocket clients share the same TLS settings
- wire the shared context into OpenAI, Azure, custom HTTPX handlers, and realtime health checks
- update realtime tests to assert that the expected SSL context is passed to `websockets.connect`

This keeps TLS configuration consistent and avoids recreating SSL contexts per connection.

* Reuse HTTP SSL context for realtime

Remove the standalone realtime SSL helper, expose a shared context directly from the HTTP handler, and point all realtime websocket clients and tests to it. Add the websocket header comparison tool.

* Lazy-load shared realtime SSL context

Fix circular imports introduced by eagerly instantiating the shared TLS context. Make the HTTP handler lazily create the context and have realtime clients/tests fetch it on demand, keeping configuration consistent without breaking startup.

* add: unit test for realtime LRU caches

* fix: merge conflict with imports
2025-11-22 10:01:02 -08:00