Commit Graph

4133 Commits

Author SHA1 Message Date
YutaSaito f487f4e3a9 feat: add dynamic OAuth2 metadata discovery for MCP servers (#16676)
* feat: add dynamic OAuth2 metadata discovery for MCP servers

* fix: lint error
2025-11-14 18:14:43 -08:00
Ishaan Jaff 8a43fbe8f7 Revert "[Feat] VertexAI - Add BGE Embeddings support (#16033)" (#16677)
This reverts commit 7133488282.
2025-11-14 17:41:06 -08:00
Ishaan Jaffer c18f411a5e test_encrypt_response_id_success 2025-11-14 17:28:15 -08:00
Cesar Garcia 0a0b5eee47 fix: Resolve pytest module name collision for test_transformation.py files (#16661)
Fixes #16613

The issue was caused by two test files having the same module name
(test_transformation.py) in different directories, which caused pytest
to fail with an import file mismatch error.

Changes:
- Renamed tests/test_litellm/llms/xai/responses/test_transformation.py
  to test_xai_responses_transformation.py
- Renamed tests/test_litellm/llms/openai_like/chat/test_transformation.py
  to test_openai_like_chat_transformation.py

Both files now have unique, descriptive names that reflect their
specific test purposes and prevent module name collisions.
2025-11-14 16:50:40 -08:00
Emerson Gomes 1dac777346 Add Vertex Kimi-K2-Thinking (#16671)
* Add Vertex Kimi-K2-Thinking

* Update model_prices_and_context_window.json

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update litellm/model_prices_and_context_window_backup.json

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-14 16:49:48 -08:00
Ishaan Jaff b360cc957e [Feat] Model Management API - Add API Endpoint for creating model access group (#16663)
* add NewModelGroupRequest

* add endpoint for create_model_group

* fix model_access_group_management_router

* add UpdateModelGroupRequest, info and delete

* fix model management tag

* fix validate_models_exist

* fix get_all_access_groups_from_db

* test_create_duplicate_access_group_fails

* test fixes

* fix working create access groups

* fix access group management endpoints

* add is db model checks for model access groups
2025-11-14 16:40:43 -08:00
yuneng-jiang f1ff195bd8 Add Model uses endpoint info (#16664) 2025-11-14 16:08:27 -08:00
Ishaan Jaff 2bd6d0d82b [Feat] Bedrock Batches - Add support for custom KMS encryption keys in Bedrock Batch operations (#16662)
* add s3_encryption_key_id

* add s3EncryptionKeyId to BedrockS3OutputDataConfig

* use s3EncryptionKeyId in bedrock output

* docs s3_encryption_key_id

* test_bedrock_batch_with_encryption_key_in_post_request
2025-11-14 16:00:43 -08:00
Cesar Garcia 65061bafc7 feat(openai): Add support for reasoning_effort='none' in GPT-5.1 (#16658)
* feat(openai): Add support for reasoning_effort='none' in GPT-5.1

OpenAI's GPT-5.1 introduced a new reasoning effort parameter 'none'
which replaces the previous 'minimal' setting for faster, lower-latency
responses. This is now the default setting for GPT-5.1.

Changes:
- Updated REASONING_EFFORT type to include 'none' value
- Added GPT-5.1, GPT-5-mini, and GPT-5-nano to documentation
- Updated docs to reflect 'none' as GPT-5.1's default reasoning effort
- Added test to verify reasoning_effort='none' passes through correctly

Fixes #16633

* feat(responses): Add support for reasoning_effort='none' in Responses API transformation
2025-11-14 13:41:49 -08:00
Alexsander Hamir c7847125c2 [Perf] Embeddings: Use router's O(1) lookup and shared sessions (#16344)
* Refactor proxy embeddings to use shared processor

- allow ProxyBaseLLMRequestProcessing to accept the aembedding route so embeddings requests reuse the base pipeline hooks

- route embeddings requests through base_process_llm_request, sharing logging, hook execution, retries, and header handling with chat/responses

- tighten token array decoding logic by using router deployment lookups and the unified error handler

* Fix: Correctly process embedding requests with token arrays

The `test_embedding_input_array_of_tokens` test was failing due to a regression that caused embedding requests with token arrays to be processed incorrectly. This prevented the `aembedding` function from being called as expected.

This was caused by a combination of three distinct issues:

1.  In `litellm/proxy/common_request_processing.py`, the `function_setup` utility was called with `aembedding` as the `original_function` for embedding routes. This has been corrected to `embedding` to ensure proper request setup.

2.  In `litellm/proxy/proxy_server.py`, a `TypeError` occurred because the `get_deployment` method was called with the `model_name` keyword argument instead of the expected `model_id`. This has been corrected. Additionally, the check for token arrays was improved to validate that all elements in the input subarray are integers.

3.  In `litellm/proxy/litellm_pre_call_utils.py`, the check for the `enforced_params` enterprise feature was too strict. It blocked valid requests even when the `enforced_params` list was empty. The condition has been adjusted to trigger the check only for non-empty lists.

Finally, the `test_embedding_input_array_of_tokens` assertion was updated to be more robust. The previous `assert_called_once_with` was overly strict, causing failures when unrelated internal parameters were added to the function call. The test now first asserts that `aembedding` is called and then separately verifies the `model` and `input` arguments. This makes the test more resilient to future changes without sacrificing its ability to catch regressions.

* test: align proxy embedding assertions

Update the embedding proxy test to match the new request pipeline: keep the data the proxy builds, expect the extra control kwargs, let the post-call hook return the actual response, and assert the normalized 'embeddings' hook type. This proves the refactor still forwards metadata and returns the mocked payload.

* Update proxy exception test

The proxy now forwards additional kwargs (request_timeout, litellm_call_id, litellm_logging_obj) to llm_router.aembedding. The test needs to accept these to match the real call signature and keep validating the error path instead of the kwargs list.

* testing: unsure of this change

I don't remember why I changed this, will revert and see if any tests fail since the manual test isn't failing without it.

* fix: remove unrelated change

This change was not related to the embeddings refactor and actually belonged to a different branch.
2025-11-14 09:21:45 -08:00
Sameer Kankute 13993d6ea3 Add fal-ai/flux/schnell support (#16580) 2025-11-13 22:31:31 -08:00
yuneng-jiang 379aa7b79a Pagination for /spend/logs/session/ui endpoint (#16603) 2025-11-13 22:03:00 -08:00
YutaSaito 331be4f57b fix: avoid crashing when MCP server record lacks credentials (#16601) 2025-11-13 22:01:11 -08:00
pnookala-godaddy 44bb18a6ba fix: forward OpenAI organization for image generation (#16607) 2025-11-13 21:51:27 -08:00
yuneng-jiang 792339200a Migrate Add Model Fields to backend (#16620) 2025-11-13 21:48:57 -08:00
Ishaan Jaff 4a486dc669 [Bug fix] Fixes SambaNova API rejecting requests when message content is passed as a list format (#16612)
* add runwayml_models

* test_call_with_end_user_over_budget

* TestSambanovaContentListHandling

* add _transform_messages for sambanova
2025-11-13 17:03:14 -08:00
Ishaan Jaffer 3c662eadb4 add runwayml/eleven_multilingual_v2 pricing 2025-11-13 16:45:35 -08:00
Ishaan Jaffer ee8b1cfabc test_call_with_end_user_over_budget 2025-11-13 16:26:02 -08:00
Ishaan Jaff 124ba463f8 [Feat] RunwayML - Add support for /audio/speech eleven_multilingual_v2 endpoint (#16604)
* init RunwayMLTextToSpeechConfig

* add RunwayMLTextToSpeechConfig

* add  RunwayMLTextToSpeechConfig

* test_runwayml_tts_async

* runway ml speech

* fix voices

* fix test

* docs runway lm

* add runwayml here

* fix RunwayMLTextToSpeechConfig

* test_openai_voice_mapping_to_runwayml
2025-11-13 14:32:09 -08:00
Nicholas Couture 4be372eb48 fix: support Anthropic tool_use and tool_result in token counter (#16351)
* fix: support Anthropic tool_use and tool_result in token counter

* refactor(token_counter): add dynamic field inference for Anthropic content blocks

* test: Add additional tests

* make format

* Fix lint error

* Fix mypy narrow type lint errors
2025-11-13 14:30:46 -08:00
Ishaan Jaff 7133488282 [Feat] VertexAI - Add BGE Embeddings support (#16033)
* Support for Custom Vertex AI Models via PSC Endpoint with api_base (#15953)

* Support for Custom Vertex AI Models via PSC Endpoint with api_base

* Add docs related psc

* remove not needed files

* remove print statemnt

* fix mypy errors

* add TextEmbeddingBGEInput

* add VertexBGEConfig

* add BGE handling

* test_vertex_ai_bge_embedding_with_custom_api_base

* fix request transform vertex BGE

* test_vertex_ai_bge_embedding_with_custom_api_base

* tes BGE

* test_is_bge_model_detection

* docs cleanup

* handling BGE URL

* fix VertexBGEConfig

* test_vertex_ai_bge_with_endpoint_id_pattern

* docs vertex BGE

* docs

* docs fix

* fix VertexAIModelRoute

* from ..common_utils import VertexAIError, get_vertex_base_model_name
add

* fix VertexAIGemmaModels

* fix get_vertex_base_model_name

* test_vertex_ai_bge_psc_endpoint_url_construction

---------

Co-authored-by: Sameer Kankute <sameer@berri.ai>
2025-11-13 12:41:00 -08:00
YutaSaito 8e0b66a814 fix: exclude unauthorized MCP servers from allowed server list (#16551)
* fix: exclude unauthorized MCP servers from allowed server list

* fix: test after resolving merge conflicts
2025-11-13 12:33:54 -08:00
Jón Levy 555d7b8be8 feat(bedrock): Add bearer token authentication support for AgentCore (#16556) 2025-11-13 08:17:36 -08:00
Cesar Garcia 491f57a349 feat: Add support for reasoning_effort="none" for Gemini models (#16548)
Implements support for reasoning_effort="none" parameter for Gemini models,
providing significant cost savings (up to 96% cheaper) by disabling thinking
budget while maintaining response quality.

Changes:
- Added "supports_reasoning": true to gemini-2.0-flash-thinking-exp-01-21 in model config
- Implemented mapping for reasoning_effort="none" to thinkingConfig {thinkingBudget: 0, includeThoughts: false}
- Added unit test to verify the mapping works correctly

Performance impact:
- Without reasoning_effort: ~313 tokens
- With reasoning_effort="none": ~12 tokens (96% cheaper)

Closes #16420

Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
2025-11-12 19:41:07 -08:00
Cesar Garcia 049d45ea90 fix(gemini): Preserve non-ASCII characters in function call arguments (#16550)
Fixes #16533

Before this fix, non-ASCII characters (Japanese, Spanish, Chinese, etc.)
in function call arguments were being escaped as Unicode sequences.

Example:
- Before: "やあ" → "\u3084\u3042"
- After: "やあ" → "やあ" (preserved)

Changes:
- Add ensure_ascii=False to json.dumps() in _transform_parts()
- Add test for Japanese and Spanish Unicode character preservation

This is not a breaking change as both formats are equivalent in JSON.
The fix improves readability and aligns with OpenAI's behavior.
2025-11-12 19:01:38 -08:00
Sameer Kankute 018bd2e039 Add Gemini image edit support (#16430)
* Add gemini image edit support

* fix lint errors

* fix lint errors

* fix lint errors

* Add docs
2025-11-12 18:48:27 -08:00
yuneng-jiang 8bf491c939 [Fix] /spend/logs/ui Access Control (#16446)
* RBAC for /spend/logs/ui

* Addressing comments
2025-11-12 18:44:21 -08:00
yuneng-jiang cb27d6c456 [Fix] UI - Delete Callbacks Failing (#16473)
* Temp commit for branch switching

* Created normalize callback name util function and tests
2025-11-12 18:43:37 -08:00
Sameer Kankute 92bd12c862 Fix raising wrong 429 error on wrong exception (#16482)
* fix raising wrong 429 error on wrong exception

* remove double re import
2025-11-12 18:41:12 -08:00
Sameer Kankute 394da34a0b Add all gemini image models support in image generation (#16526) 2025-11-12 18:26:44 -08:00
yuneng-jiang 898f15c33c Add Langfuse OTEL and SQS to health check (#16514) 2025-11-12 18:25:30 -08:00
Ishaan Jaff b30439257b [Feat] Add RunwayML Img Gen API support (#16557)
* TestRunwaymlImageGeneration

* fix RUNWAYML

* rename

* fix rename

* get_runwayml_image_generation_config

* get_runwayml_image_generation_config

* TestRunwaymlImageGeneration

* add RUNWAYML_POLLING_TIMEOUT

* fix rnwayml transform img gen

* runwayml_image_cost_calculator

* runwayml_image_cost_calculator

* docs runwayml

* fix runwayML polling

* test_get_first_default_fallback
2025-11-12 18:20:14 -08:00
YutaSaito 2843dab7fe fix: allow tool call even when server name prefix is missing (#16425)
* fix: allow tool call even when server name prefix is missing

* fix: test

* fix: test

* fix: test
2025-11-12 13:50:52 -08:00
Ishaan Jaff 061b7b2713 [Fix] Bedrock Embeddings - Ensure correct aws_region is used when provided dynamically (#16547)
* test_bedrock_embedding_uses_correct_region_when_specified

* fix aws_region_name in bedrock embeddings
2025-11-12 12:38:58 -08:00
Ishaan Jaff abde56391b [Fix] - Bedrock Knowledge Bases - add support for filtering kb queries (#16543)
* test_e2e_bedrock_knowledgebase_retrieval_with_llm_api_call_with_tools_and_filters

* fix vs registry

* fix merging params

* test_bedrock_kb_request_body_has_transformed_filters

* fix typing / linting
2025-11-12 12:38:50 -08:00
Mubashir Osmani e6bbf3ce81 fix: app_roles missing from jwt payload (#16448)
* fix: jwt app_roles missing

* add test
2025-11-12 12:07:04 -08:00
Jean-Adrien Ducastaing 086e557d78 fix: use vllm passthrough config for hosted vllm provider instead of raising error (#16537)
* fix(passthrough): use VLLM passthrough config for hosted VLLM provider instead of raising an error

* test(passthrough): add tests for hosted VLLM passthrough configuration and routing

* fix account linking for CLA
2025-11-12 09:12:14 -08:00
Sameer Kankute 517eb0ee10 Use safe loading of creds (#16479) 2025-11-11 19:16:29 -08:00
Andrew Maguire bd15250960 fix: Add atexit handlers to flush callbacks for async completions (#16487)
Fixes #16486

## Problem
Callbacks configured via litellm.success_callback (e.g., PostHog, LangSmith)
were not being invoked for litellm.acompletion() in short-lived scripts.
The callbacks worked correctly for synchronous completions but async
completions would queue callbacks that were lost when the script exited
before GLOBAL_LOGGING_WORKER could process them.

Root cause: asyncio.run() closes the event loop immediately after the
async function completes, preventing the background worker from processing
queued callbacks.

## Solution
Implemented a two-level atexit handler approach:

1. GLOBAL_LOGGING_WORKER atexit handler (logging_worker.py):
   - Processes remaining callbacks from queue before exit
   - Creates new event loop to run pending coroutines synchronously
   - Applies time and iteration limits to prevent blocking shutdown

2. Integration-specific atexit handlers (posthog.py as example):
   - Flushes internal queue to external service
   - Uses synchronous HTTP client for reliable delivery
   - Each integration needs its own handler due to varying sync APIs

## Changes
- litellm/litellm_core_utils/logging_worker.py:
  - Added _flush_on_exit() method
  - Registered atexit handler in __init__
  - Processes up to MAX_ITERATIONS_TO_CLEAR_QUEUE events
  - Time-limited to MAX_TIME_TO_CLEAR_QUEUE seconds

- litellm/integrations/posthog.py:
  - Added _flush_on_exit() method
  - Registered atexit handler in __init__
  - Groups events by credentials for batch sending
  - Uses sync_client for reliable HTTP delivery

- tests/logging_callback_tests/test_posthog.py:
  - Added test_async_callback_atexit_handler_exists()
  - Added test_posthog_atexit_flushes_internal_queue()
  - Added test_sync_callback_not_affected_by_atexit()

## Testing
- All existing tests pass
- Manual end-to-end testing confirms fix:
  - Async events now arrive in PostHog
  - Sync events continue working (no regression)
- Unit tests verify atexit handlers registered and functional

## Impact
- Fixes async callback delivery for ALL integrations using GLOBAL_LOGGING_WORKER
- No breaking changes - only adds missing functionality
- Sync path unchanged - no performance impact
2025-11-11 19:12:53 -08:00
Alan Ponnachan 8cb610b8b2 Sanitize null token values in provider responses (#16493) 2025-11-11 19:08:00 -08:00
yuneng-jiang ba674f241c [Fix] Use user budget instead of key budget when creating new team (#16074)
* Use end user budget instead of key budget when creating new team

* Fixed implementation to use user's max budget from the UserTable instead of EndUserTable
2025-11-11 18:55:05 -08:00
yuneng-jiang 67478a9074 [Fix] Litellm tags usage add request_id (#16111)
* Add request_id into tag spend

* Linting
2025-11-11 18:53:48 -08:00
Ishaan Jaff 50b5cf5215 [Feat] New Provider - Add RunwayML Provider for video generations (#16505)
* add RUNWAYML

* init folders

* add RunwayMLVideoConfig

* add RUNWAYML_DEFAULT_API_VERSION

* add RunwayMLVideoConfig

* fix getting status

* add async_transform_video_content_response

* add runwayml transform_video_content_response

* fix config.yaml

* add runwayml docs

* add runwayml to videos

* docs runwayml video gen

* add new models to model cost map

* TestRunwayMLVideoTransformation

* fix linting errors
2025-11-11 18:48:23 -08:00
jwang-gif 443bada425 Add Zscaler AI Guard hook (#15691)
* Add Zscaler AI Guard hook

Co-authored-by: Angela Tao <atao@zscaler.com>

* Fix lint error, update document

* Fix lint error, update document

* update document

* fix mypy type error

* fix mypy issue

* fix test

* fix test

* improve document

* remove unuseful code

* use litellm httphandler

* update test cases

* revover guardrail_initializers.py and guardrail_registry.py

* remove unuse import

* app apply_guardrail

* remove functions repleased by apply_guardrail, update test and doc

* remove functions repleased by apply_guardrail, update test and doc

---------

Co-authored-by: Angela Tao <atao@zscaler.com>
2025-11-11 15:34:27 -08:00
Ishaan Jaff 5c9f50d584 [AI Gateway] - End User Budgets - Allow pointing max_end_user budget to an id, so the default ID applies to all end users (#16456)
* add _apply_budget_limits_to_end_user_params

* add _apply_budget_limits_to_end_user_params

* add _apply_budget_limits_to_end_user_params

* test_default_budget_applied_to_end_user_without_budget

* docs fix

* fix config
2025-11-11 08:20:13 -08:00
Ishaan Jaff e94186629d [Fix] Bedrock Knowledge bases - ensure users can access search_results for both stream + non stream response to /chat/completions (#16459)
* fix message with provider_specific_fields

* test_provider_specific_fields_in_proxy_http_response

* test_provider_specific_fields_in_proxy_http_response
2025-11-11 08:19:57 -08:00
Daniel Sabanov 0ecc38519e [Bug] Updated spend would not be sent to CloudZero (#16201)
* Address a bug where cloudzero spend is not sent to cloudzero if a spend
update happens

* revert change unrelated to PR

* use polars for mocking instead of sqlite
2025-11-10 19:43:15 -08:00
yellowsubmarine372 b6dbd4fa28 fix: apply provided timeout value to ClientTimeout.total (#16395) 2025-11-10 19:37:42 -08:00
Alan Ponnachan 5f12e4be1e fix(langfuse): Handle null usage values to prevent validation errors (#16396)
* langfuse null validation fix

* formatting
2025-11-10 19:34:56 -08:00
Alan Ponnachan 7b292ccdf5 router fallback for unknown models (#16419) 2025-11-10 19:33:01 -08:00