Commit Graph

4622 Commits

Author SHA1 Message Date
yuneng-jiang 8039c5052f Merge pull request #17681 from BerriAI/litellm_ui_fallback_login_alert
[Fix] Change deprecation banner to only show on /sso/key/generate
2025-12-08 21:18:38 -08:00
YutaSaito 5b926ae2c6 fix: resolve UI session MCP permissions across real teams (#17620)
* fix: resolve UI session MCP permissions across real teams

* fix: remove user from logs
2025-12-08 19:03:01 -08:00
Earl St Sauver ad9c69860e Fix Cerebras context window errors not recognized (#17587)
Add detection for Cerebras's context window exceeded error format:
"Current length is X while limit is Y"

This ensures LiteLLM raises ContextWindowExceededError instead of
generic BadRequestError when Cerebras API calls exceed the model's
context limit, enabling downstream libraries like DSPy to properly
catch and handle these errors for automatic context management.
2025-12-08 19:02:06 -08:00
Cesar Garcia a7ad8a36a4 chore: cleanup unused scripts and fix misplaced test file (#17611)
Remove scripts/ directory containing unused development/debug scripts:
- mock_ibm_guardrails_server.py
- test_groq_streaming_issue.py (debug for #12660)
- test_mock_ibm_guardrails.py
- update_readme_providers_table.py

Move misplaced test file to correct location:
- test_litellm/ -> tests/test_litellm/ (from PR #17221)
2025-12-08 19:00:55 -08:00
Cesar Garcia 0295f912be fix(openai): include 'user' param for responses API models (#17648)
The 'user' parameter was being ignored when using responses API models
(e.g., model="openai/responses/gpt-4.1") because the model name check
in get_supported_openai_params() didn't account for the "responses/" prefix.

Fix: Normalize the model name by stripping "responses/" prefix before
checking if the model is in the list of supported OpenAI models.

This is a minimal, non-breaking change that:
- Adds 2 lines of code in gpt_transformation.py
- Only affects the parameter support check, not the model variable itself
- Includes unit and integration tests
2025-12-08 18:52:47 -08:00
Cesar Garcia fd9ff90307 fix(responses): prevent streaming tool_calls from being dropped when text + tool_calls (#17652)
When OpenAI Responses API returns both text AND tool_calls, the bridge
transformation was emitting is_finished=True after the text message completed,
causing subsequent tool_call chunks to be dropped.

The fix:
- response.output_item.done for messages no longer emits is_finished=True
- Added handler for response.completed to properly signal stream end
2025-12-08 18:51:59 -08:00
Emil Svensson 61e737e361 fix Azure AI Anthropic api-key header and passthrough cost calculation (#17656)
* refactor: remove api-key conversion logic for Azure Anthropic

Co-authored-by: Erdem Halil <erdemhalil@users.noreply.github.com>

* fix(passthrough): pass custom_llm_provider to completion_cost for Azure AI Anthropic

The passthrough logging for Anthropic was failing when using Azure AI Anthropic
because the completion_cost function was not receiving the custom_llm_provider
parameter, causing it to fail with "LLM Provider NOT provided" error.

This fix:
- Retrieves custom_llm_provider from logging_obj.model_call_details
- Prepends provider prefix to model name for cost calculation
- Passes both formatted model and custom_llm_provider to completion_cost
- Centralizes provider prefix logic in _create_anthropic_response_logging_payload

This ensures cost calculation works correctly for Azure AI Anthropic requests
with models like azure_ai/claude-sonnet-4-5_gb_20250929.

Co-authored-by: Erdem Halil <erdemhalil@users.noreply.github.com>

* test: add unit tests for Azure AI Anthropic fixes

- Add tests for custom_llm_provider cost calculation in passthrough logging
- Add tests for ProviderConfigManager returning AzureAnthropicMessagesConfig
- Update existing tests to reflect removal of api-key to x-api-key conversion

Co-authored-by: Erdem Halil <erdemhalil@users.noreply.github.com>

---------

Co-authored-by: Erdem Halil <erdemhalil@users.noreply.github.com>
2025-12-08 18:50:26 -08:00
Cesar Garcia 7c2e2111c0 fix(router): handle tools=None in filter_web_search_deployments (#17684)
Fixes #17672

Changed `request_kwargs.get("tools", [])` to `request_kwargs.get("tools") or []`
to handle the case where tools is explicitly set to None.
2025-12-08 18:36:46 -08:00
Ishaan Jaff a904067d38 [Feat] New model - add bedrock writer models (#17685)
* add new bedrock models

* test bedrock writer models

* docs bedrock writer palmyra

* add palymra models

* add bedrock writer models

* docs fix
2025-12-08 17:49:06 -08:00
Ishaan Jaff 074445edb1 [Fix] AI Gateway Auth - allow using wildcard patterns for public routes (#17686)
* edit auth utils to allow wildcard patterns

* docs fix private / public routes

* test_route_in_additional_public_routes_wildcard_match
2025-12-08 17:39:53 -08:00
Ishaan Jaff 2f335ac5a6 [Feat] Dynamic Rate Limiter - allow specifying ttl for in memory cache (#17679)
* fix _get_saturation_value_from_cache

* fix _get_saturation_check_cache_ttl

* fix test_saturation_check_cache_ttl_configuration

* docs saturation_check_cache_ttl
2025-12-08 17:20:52 -08:00
yuneng-jiang 8338bd9c53 Change deprecation banner to only show on /sso/key/generate 2025-12-08 16:30:37 -08:00
Ishaan Jaff 601da4a3d1 [Feat] New model - add nvidia nim llama-3.2-nv-rerankqa-1b-v2 (#17670)
* fix get_nvidia_nim_rerank_config

* add NvidiaNimRankingConfig

* add get_nvidia_nim_rerank_config

* add test_nvidia_nim_rerank_ranking_endpoint

* add /ranking model provider support

* feat: add nvidia/llama-3.2-nv-rerankqa-1b-v2
2025-12-08 15:25:23 -08:00
_juliettech ee0812a297 Add Helicone as a provider and update observability documentation (#17663)
* Add Helicone as a provider to liteLLM

* Add Helicone provider integration
2025-12-08 12:34:11 -08:00
vasilisazayka c87874c29e [New provider] Sap gen ai hub (#16053)
* add sap gen ai hub

* add async tests

* add async and streaming support

* add embedding model support

* add embedding support

* remove unused import

* fix structured output

* clean-up

* remove timeout and add tool support

* remove unused code

* fix(sap): improve streaming robustness; restore embed URL builder compatibility
- sap/embed/transformation: add api_key and litellm_params to get_complete_url to align with core flow and prevent failures
- sap/chat/handler: wrap async/sync streaming iterators to safely handle Stop(Async)Iteration and errors
- sap/chat/transformation: remove unused imports and dead code

* fix(sap): linter fix

* fix(sap): made gen_ai_hub optional: import check + OptionalDependencyError with install hint if missing.

* test(sap): add chat/stream/async tests and OptionalDependencyError check

* Fix tool call handling in SAP GenAI Hub transformation
Add sap models to model_prices_and_context_window.json and model_prices_and_context_window_backup.json

* fix(sap): delete unnecessary code, linter fix

* fix(sap): - refactor chat transformation
- add support of list and dict content

* fix(sap): - fix tests

* fix(sap): - fix lint

* Update transformation.py

* fix(sap): fix model description and fix after rebase

* change(sap): - http calls in chat handler, response transformation and auth handling without sap sdk.

* change(sap): switching to v2 (chat handler, chat transformation), code clean up

* add deployment discovery and improved crendentials handling

* add deployment discovery and improved crendentials handling

* change(sap): - fix sync stream

* change(sap): - fix sync stream

* fix(sap): - fix response format

* fix(sap): - switch embedding to v2 and http request
- reimplement stream creator
- improve request transformation

* fix async streaming

* fix(sap): linters, transformation models, remove sap dependency test

* fix(sap): code clean up

* add unit test for sap chat completion

* linters fix

* move token, rg and base_url to properties

* (sap): add embedding unit test

Signed-off-by: Vasilisa Parshikova <vasilisa.parshikova@sap.com>

* fix(sap): bypass response format for some models

Signed-off-by: Vasilisa Parshikova <vasilisa.parshikova@sap.com>

* fix(sap): fix chat transformation and list of supported params

Signed-off-by: Vasilisa Parshikova <vasilisa.parshikova@sap.com>

* fix(sap): fix lint

* add sap service key module parameter

* fix(sap): remove unused code

* fix(sap): remove prices

* add service key support

* fix(sap): - add message content validations
- change get_supported_openai_params in chat transformation

* typo in mock

* fix(sap): - fix in supported params map

* fix(sap): - fix in message content validation

* fix(sap): - fix in message content validation

* fix(sap): - use litellm client for credentials

* fix(sap): - linter fix

* fix(sap): - use build in custom_http_client
- move credentials handling to transformation

* fix(sap): - handle stream_options

* fix(sap): - fix tests

* fix(sap): - code clean up, linter fix

* skip other authentication options when creds are provided

* fix local variable

---------

Signed-off-by: Vasilisa Parshikova <vasilisa.parshikova@sap.com>
Co-authored-by: Mathis Boerner <mathis.boerner@sap.com>
Co-authored-by: karimmohraz <37623804+karimmohraz@users.noreply.github.com>
Co-authored-by: Karim <karim.mohraz@sap.com>
2025-12-08 12:31:06 -08:00
Alexsander Hamir 958c190134 Fix flanky tests (#17665)
* Fix test_delete_polling_removes_from_cache mock setup

- Mock async_delete_cache to properly execute the real implementation path
- Ensures init_async_client() is called and delete() is invoked on the returned client
- Fixes AssertionError: Expected 'delete' to be called once. Called 0 times.

* fix: resolve timeout in add_model_tab test by mocking useProviderFields hook

- Mock useProviderFields hook to prevent network calls and React Query delays
- Use waitFor to properly handle async operations
- Test now passes reliably without 10s timeout

* fix: add test timeout to prevent CI timeout failure

- Add 15 second timeout to 'should display Test Connect and Add Model buttons' test
- Test takes ~6 seconds locally, but CI was timing out at default 5 second limit
- Ensures test has sufficient time to complete in CI environment

* test: quarantine flaky test_oidc_circleci_with_azure

Quarantine test that fails with 401 Unauthorized from Azure OAuth.
The test is flaky and blocks CI builds. Marked with @pytest.mark.skip
until Azure authentication can be fixed or migrated to our own account.
2025-12-08 12:21:26 -08:00
Sameer Kankute 05f800fe7d Merge pull request #17653 from BerriAI/litellm_fireworks_rerank_model
(Feat) Add fireworks rerank support
2025-12-08 21:33:08 +05:30
Sameer Kankute 7aaab32313 Merge pull request #17651 from BerriAI/litellm_audio_caching_fix
Use audio content for caching
2025-12-08 20:57:09 +05:30
Sameer Kankute 76469182bc Merge pull request #17641 from BerriAI/litellm_responses_api_usage_populated
Add usage details in responses usage object
2025-12-08 20:38:31 +05:30
Sameer Kankute 87cf6f3ffe Add fireworks rerank support 2025-12-08 20:29:50 +05:30
Sameer Kankute f486fb2283 Use audio content for caching 2025-12-08 19:31:22 +05:30
Cesar Garcia b6b155d67b fix(anthropic): handle partial JSON chunks in streaming responses (#17493)
Fixes #17473 - Anthropic streaming fails with JSONDecodeError when
network fragmentation causes SSE data to arrive in partial chunks.

Changes:
- Add accumulated_json buffer and chunk_type to ModelResponseIterator
- Add _handle_accumulated_json_chunk() to accumulate partial JSON
- Add _parse_sse_data() to handle both complete and partial chunks
- Modify __next__ and __anext__ to use accumulation logic
- Add unit tests for partial chunk handling
2025-12-07 23:34:42 -08:00
Tamir Kiviti 0f5694c8eb add onyx guardrail hooks integration (#16591)
* add onyx guardrail hooks integration

* fix lint issue

* fix lint issue

* update PR to use the new custom guardrail interface

* lint fix
2025-12-07 23:33:28 -08:00
Raney Cain eb689a1f07 fix(proxy): async_post_call_streaming_iterator_hook now properly iterates async generators (#17626)
The async_post_call_streaming_iterator_hook function was broken:
1. Was a sync function (def) not async generator
2. Returned AsyncGenerator without iterating it
3. Callback generators were chained but never consumed

This fix:
1. Makes the function an async generator (async def + yield)
2. Actually iterates through the chained callbacks with 'async for'
3. Properly yields chunks to the caller

Fixes #9639
2025-12-07 23:29:42 -08:00
Kevin Marx 0650b5e80d fix(anthropic): prevent duplicate tool_result blocks with same (#17632)
tool_use_id
2025-12-07 23:24:58 -08:00
Chetan Choudhary d8ac213c6a Native Webhook Integration Sumologic (#17630)
* Fix: Support generic_api_compatible_callbacks.json in callback initialization

- Added check in _add_custom_callback_generic_api_str to load callbacks from generic_api_compatible_callbacks.json
- Added SumoLogic webhook integration to generic_api_compatible_callbacks.json
- Fixes bug where callbacks in JSON file were not being loaded

* Added 3 unit tests for JSON callback loading
2025-12-07 23:23:39 -08:00
Sameer Kankute 41f0cf8523 Add usage details in responses usage object 2025-12-08 11:51:47 +05:30
Sameer Kankute b83bc10562 Merge pull request #16862 from xianzongxie-stripe/add_polling_via_cache_feature
Add polling via cache feature
2025-12-08 08:41:25 +05:30
yuneng-jiang 321ffd7258 Merge pull request #17180 from BerriAI/litellm_non_root_docker_logo_fix
[Fix] Add User Writable Directory to Non Root Docker for Logo
2025-12-06 22:22:27 -08:00
yuneng-jiang e2e35c3f87 Merge pull request #17522 from BerriAI/litellm_custom_webhook_fix
[Fix] Custom Callback on UI
2025-12-06 22:22:02 -08:00
yuneng-jiang d3d005f9bf fixing tests 2025-12-06 21:23:49 -08:00
yuneng-jiang f9a4ba3359 Merge pull request #16795 from BerriAI/litellm_add_model_fix_team_admin
[Fix] Make /litellm_model_cost_map public
2025-12-06 21:06:39 -08:00
yuneng-jiang a560db56d5 Merge remote-tracking branch 'origin' into litellm_scim_v2_fix 2025-12-06 20:01:05 -08:00
yuneng-jiang 1d95595522 Merge remote-tracking branch 'origin' into litellm_non_root_docker_logo_fix 2025-12-06 20:00:33 -08:00
yuneng-jiang 539e3721f2 Merge remote-tracking branch 'origin' into litellm_add_model_fix_team_admin 2025-12-06 20:00:01 -08:00
yuneng-jiang 96f39484f1 Merge remote-tracking branch 'origin' into litellm_custom_webhook_fix 2025-12-06 19:59:15 -08:00
Ishaan Jaffer 2b069a343b test_init_custom_logger_compatible_class_as_callback 2025-12-06 16:21:50 -08:00
Ishaan Jaffer c78c2cf3e9 test_async_no_duplicate_spend_logs 2025-12-06 16:14:56 -08:00
Krish Dholakia 14d331e9ea fix(vertex_llm_base.py): Add missing scopes to identity pool credentials (#17560)
* fix(vertex_llm_base.py): Fixes https://github.com/BerriAI/litellm/issues/17377

* test: update tests
2025-12-06 16:03:51 -08:00
Ishaan Jaffer b6562b9d88 test_thought_true_with_empty_text_creates_block 2025-12-06 16:00:05 -08:00
Sameer Kankute 5f27c70bb0 Add beta header in vertex request for claude websearch request (#16269)
* Add beta header in vertex request for claude websearch request

* add condition if header present don't overide

---------

Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
2025-12-06 15:29:35 -08:00
Anil Kodali 1a50a89cd3 [New Model] Add Amazon Nova as first party provider for chat completions (#17351)
* Add Amazon Nova as a first party provider

* Added new provider folder under llms/ to outline the openai supported params

* Updated supported endpoints on the documnetation
2025-12-06 14:43:55 -08:00
Ishaan Jaffer 71ea926f9a test_no_duplicate_spend_logs 2025-12-06 09:56:05 -08:00
Sungjun.Kim ca7241188a feat: Add xhigh reasoning effort for gpt-5.1-codex-max (#17585)
Co-authored-by: Ishaan Jaff <ishaanjaffer0324@gmail.com>
2025-12-06 09:48:18 -08:00
Alexsander Hamir 09dcd381d7 fix: mark test_caching_with_reasoning_content as flaky and handle InternalServerError (#17603)
- Add @pytest.mark.flaky(retries=3, delay=1) decorator to handle intermittent Anthropic API failures
- Add error handling to skip test when Anthropic API returns InternalServerError
- Prevents false test failures due to external API 500 errors
2025-12-06 09:41:09 -08:00
Alexsander Hamir 1254a92e66 fix: make test_log_langfuse_v2_handles_null_usage_values more robust (#17599)
- Reset mock call counts at start of test to ensure clean state
- Add span method to mock trace to handle log_provider_specific_information_as_span calls
- Re-establish mock chain before test call to ensure fresh state
- Add exception handling to catch and report errors during test execution
- Add verification that trace was called before checking generation

This should fix the flaky test that was failing intermittently with
'Expected generation to have been called once. Called 0 times.'
2025-12-06 09:21:00 -08:00
Alexsander Hamir 53e2516ace fix: make test_watsonx_gpt_oss_prompt_transformation deterministic (#17597)
- Remove network dependency by mocking HuggingFace template fetch
- Use mock template that produces correct format for test validation
- Test now focuses on transformation logic, not network calls
- Fixes flaky test failures due to network timeouts/rate limits

The test verifies that prompt transformation occurs (not simple
concatenation), which doesn't require the actual HuggingFace template.
Mocking makes the test deterministic and faster while still validating
the core behavior.
2025-12-06 08:48:39 -08:00
Alexsander Hamir 73075c7d24 fix: add retry logic for flaky Azure image generation health check test (#17595)
- Add missing @pytest.mark.asyncio decorator
- Implement retry logic with exponential backoff (3 retries)
- Only retry on transient Azure internal server errors
- Fail immediately on non-transient errors

This fixes the flaky test_azure_img_gen_health_check which was failing
due to transient Azure internal server errors that are outside our control.
2025-12-06 08:11:52 -08:00
Alexsander Hamir 1e89aa3068 Fix: Resolve flakiness in three integration tests (#17594)
Fixed three flaky tests that were intermittently failing in CI:

1. test_no_duplicate_spend_logs (test_litellm/responses/test_no_duplicate_spend_logs.py)
   Problem: Used await asyncio.sleep(1) to wait for async logging completion,
            which created race conditions. The async logging worker queues tasks
            in the background, and sleep() doesn't guarantee completion.

   Fix: Replaced sleep() with GLOBAL_LOGGING_WORKER.flush() which properly waits
        for the logging queue to empty, ensuring all async logging tasks complete
        before assertions run.

2. test_log_langfuse_v2_handles_null_usage_values (test_litellm/integrations/test_langfuse.py)
   Problem: Used datetime.datetime.now() twice for start_time and end_time, which
            could cause timing inconsistencies between test runs, especially in
            CI environments with variable execution speeds.

   Fix: Use fixed timestamps instead of datetime.now() to ensure consistent timing
        across all test runs, eliminating timing-related flakiness.

3. test_watsonx_gpt_oss_prompt_transformation (test_litellm/llms/watsonx/test_watsonx.py)
   Problem: Directly accessed mock_post.call_args without checking if it exists,
            which could be None if the mock wasn't called or if an exception
            occurred before the POST request. The test catches exceptions and
            continues, making this a potential failure point.

   Fix: Added proper assertions and use call_args_list[0] for safer access:
        - Assert that call_args_list has at least one call
        - Assert that call_args is not None
        - Assert that 'data' key exists in kwargs
        This ensures the test fails with clear error messages rather than
        intermittent AttributeError exceptions.

All fixes maintain the original test intent while making them deterministic
and reliable in CI environments.
2025-12-06 07:57:03 -08:00
Alexsander Hamir 00a9f99718 Fix flaky test: test_logging_non_streaming_request (#17592)
- Filter async_log_success_event calls by expected input message
- Bridge models (openai/codex-mini-latest) may make internal calls that also log
- Test now asserts exactly one call with the expected input 'Hey' instead of asserting total call count
- Makes test robust to bridge-related double logging while still validating core behavior
2025-12-06 07:40:23 -08:00