Commit Graph
5374 Commits
Author SHA1 Message Date
Ishaan JaffandGitHub 747829dadb [Fix] Claude Code + Bedrock Converse Usage - ensure budget tokens are passed to converse api correctly (#19107)
* test_bedrock_converse_budget_tokens_preserved

* test_openai_model_with_thinking_converts_to_reasoning_effort

* fix translate_anthropic_thinking_to_reasoning_effort

* test_bedrock_converse_budget_tokens_preserved

* test_anthropic_messages_bedrock_converse_with_thinking
2026-01-14 12:02:27 -08:00
Rayan PalandGitHub f880ea537f fix(vertex): add type object to tool schemas missing type field (#19103)
Tools with no parameters (like EnterPlanMode from Anthropic Agents SDK)
send schemas with only $schema and no type field. Gemini rejects these
with "functionDeclaration parameters schema should be of type OBJECT".

Adds type: object when schema has no type and no anyOf/oneOf/allOf.
2026-01-15 00:43:35 +05:30
Peter GolmandGitHub c215b3a79f fix: preserve llm_provider-* headers in error responses (#19020)
Extract and preserve provider-specific headers (llm_provider-*) when
handling error responses from LLM providers. This ensures that useful
debugging information from providers is available even when requests
fail with BadRequestError or similar exceptions.
2026-01-14 22:49:39 +05:30
Sameer KankuteandGitHub cd2d381dd4 Merge pull request #19042 from BerriAI/litellm_staging_01_13_2026
Staging 01/13/2026
2026-01-14 21:29:09 +05:30
Sameer KankuteandGitHub 4aadc0d41f Merge pull request #19074 from BerriAI/litellm_19046-bug-retry-policies-are-not-applied-on-responses-calls
Add retry policy support to responses API
2026-01-14 17:56:11 +05:30
Sameer KankuteandGitHub 26d8ef734c Merge pull request #19070 from BerriAI/litellm_19066-bug-gemini-image-generation-returns-incorrect-prompt_tokens_details
Fix: [Bug]: Gemini Image Generation Returns Incorrect prompt_tokens_d…
2026-01-14 17:55:09 +05:30
Sameer KankuteandGitHub 49d873e894 Merge pull request #19067 from BerriAI/litellm_caching_fix
Fix: anthropic token counter with thinking
2026-01-14 17:52:56 +05:30
Sameer KankuteandGitHub b677ea1113 Merge pull request #19064 from BerriAI/litellm_openai_content_none_fix
Fix: Responses content can't be none
2026-01-14 17:52:31 +05:30
Sameer Kankute 7dbf09cb12 Fix all 130126 tests 2026-01-14 17:47:03 +05:30
Sameer KankuteandGitHub b4a48f7996 Revert "feat(gemini): add opt-in support for responseJsonSchema (#18147)"
This reverts commit 4e417f9ef1.
2026-01-14 17:06:13 +05:30
Sameer KankuteandGitHub ff467c797d Merge pull request #19079 from BerriAI/main
merge main
2026-01-14 16:44:31 +05:30
rohan.w.charles bc88dbfbc9 fix: implement mid-stream fallback handling based on user preference 2026-01-14 16:28:51 +05:30
Sameer Kankute 52d3c9dcfc Add retry policy support to responses API 2026-01-14 14:55:17 +05:30
Sameer KankuteandGitHub b2d4f67e17 Merge pull request #19023 from eagle-p/feat/guardrail-clean-error-message
fix(guardrails): use clean error messages for blocked requests
2026-01-14 14:03:16 +05:30
Sameer KankuteandGitHub 11cc8dc9d2 Merge pull request #19037 from Jetemple/json-log-fix
fix: enable JSON logging via configuration and add regression test
2026-01-14 13:51:36 +05:30
Sameer Kankute 6991342dc4 Fix: [Bug]: Gemini Image Generation Returns Incorrect prompt_tokens_details 2026-01-14 13:47:46 +05:30
Sameer Kankute 0563ce42a4 Fix: anthropic token counter with thinking 2026-01-14 12:59:23 +05:30
Sameer Kankute 1b34d17935 Fix: Responses content can't be none 2026-01-14 12:13:18 +05:30
YutaSaitoandGitHub 8d204f0a84 Merge pull request #19060 from BerriAI/litellm_fix_anthropic-during-call-error
[fix] anthropic during call error
2026-01-14 15:13:09 +09:00
yuneng-jiangandGitHub 39f56abd8d Merge pull request #18878 from BerriAI/litellm_hakhundov_contribution
[Fix] Feature Flag for Fix SCIM GET /Users error and enforce SCIM 2.0 compliance
2026-01-13 20:46:28 -08:00
Yuta Saito 82ed6283fa test: reorganize unified guardrail tests into nested classes 2026-01-14 13:38:43 +09:00
Yuta Saito c5ced033c9 fix: anthropic during call guardrail error 2026-01-14 13:37:01 +09:00
YutaSaitoandGitHub 95b419d65b Merge pull request #18938 from BerriAI/litellm_fix_generate_two_telemetry
[fix] generate two telemetry in responses
2026-01-14 12:35:23 +09:00
Ishaan JaffandGitHub 1b00576711 [Feat] New Model - Azure Model Router on LiteLLM AI Gateway (#19054)
* fix - azure model router integration

* fix:_check_provider_match

* fix:_get_response_model

* tests azure model router

* test_azure_ai_model_router_streaming_model_in_chunk

* fix LlmProviders.AZURE.value

* test_azure_ai_model_router_streaming_cost_with_stream_options

* def test_get_model_from_chunks_azure_model_router():

* _get_model_from_chunks

* docs azure model router

* azure model router
2026-01-13 18:31:43 -08:00
Yuta Saito 2814d3dd3d test: cover success handler sync/async logging branches 2026-01-14 10:52:14 +09:00
YutaSaitoandGitHub a66e007574 Merge pull request #19051 from BerriAI/litellm_fix_mcp-rest-auth-checks
[fix] mcp rest auth checks
2026-01-14 10:39:28 +09:00
Alexsander HamirandGitHub 15c3bc219b [Refactor] Add CI enforcement for O(1) operations in _get_model_cost_key to prevent performance regressions (#19052)
* Optimize _get_model_cost_key to avoid expensive scans

- Remove expensive O(n) scan fallback that was causing 42.87% CPU overhead
- Only scan when size mismatch detected (O(1) check)
- Add warning in docstring: Only O(1) lookup operations are acceptable
- Clean up comments to be more concise
- Keep stale entry rebuild for pop() case (only triggers when stale entry found)

This fixes the performance issue where the scan was being triggered on every
failed lookup, causing severe CPU overhead during router operations.

* Add code quality check to enforce O(1) operations in _get_model_cost_key

- Add check_get_model_cost_key_performance.py to statically analyze _get_model_cost_key
- Detects O(n) operations (loops, comprehensions, problematic function calls)
- Recursively checks called functions to find nested O(n) operations
- Allows conditional O(n) rebuilds in helper functions (_rebuild_model_cost_lowercase_map, _handle_stale_map_entry_rebuild, _handle_new_key_with_scan)

* Integrate _get_model_cost_key performance check into CI pipeline

- Add check_get_model_cost_key_performance.py to check_code_and_doc_quality job
- Ensures O(1) requirement is enforced in CI to prevent performance regressions

* Remove unused performance test and clean up utils.py

- Remove test_get_model_info_performance.py (no longer needed)
- Remove extra blank line in utils.py

* Document allowed helper functions and exception process in _get_model_cost_key

- Add documentation listing allowed helper functions with O(n) operations
- Explain why these are acceptable (conditionally called)
- Add instructions for adding new exceptions to check_get_model_cost_key_performance.py

* Fix docstring detection and type checker error in performance check

- Add proper docstring tracking to skip docstring content (fixes false positive for 'map' in docstring)
- Add None check for docstring_quote to fix type checker error
- Restore _handle_new_key_with_scan to allowed_helpers list

* Remove check_get_model_cost_key_performance from CI pipeline

- Temporarily remove the performance check from CI to avoid blocking builds

* Restore performance check and remove memory leak tests from CI

- Add back check_get_model_cost_key_performance.py to CI pipeline
- Remove memory_leak_tests job that was causing port conflicts

* Remove extra blank line in CI config
2026-01-13 17:08:03 -08:00
Raghav JhavarandGitHub 272a48d880 [bug fix] do not fallback to token counter if disable_token_counter is enabled (#19041)
* do not fallback to token counter if disable_token_counter is enabled, and return errors instead

* add exceptions and exception utils to map the same as /v1/chat/completions

* use safe_json_loads
2026-01-13 16:53:38 -08:00
yuneng-jiang c05190f5b1 Merge remote-tracking branch 'origin' into litellm_hakhundov_contribution 2026-01-13 16:27:48 -08:00
Alexsander HamirandGitHub a1dd3ead4d [Perf] Remove bottleneck causing high CPU usage & overhead under heavy load (#19049) 2026-01-13 15:22:09 -08:00
Yuta Saito df37770a70 test: add permission test 2026-01-14 07:58:21 +09:00
Cesar GarciaandGitHub 4e417f9ef1 feat(gemini): add opt-in support for responseJsonSchema (#18147)
* feat(gemini): add opt-in support for responseJsonSchema

Add support for Gemini's native responseJsonSchema parameter which uses
standard JSON Schema format instead of OpenAPI-style responseSchema.

Benefits of responseJsonSchema (Gemini 2.0+ only):
- Standard JSON Schema format (lowercase types)
- Supports additionalProperties for stricter validation
- Better compatibility with Pydantic's model_json_schema()
- No propertyOrdering required

Usage:
```python
response_format={
    "type": "json_schema",
    "json_schema": {"schema": {...}},
    "use_json_schema": True  # opt-in
}
```

This is backwards compatible - existing code continues to use
responseSchema by default.

Closes #16340

* docs: add documentation for use_json_schema parameter

Document the new use_json_schema option for Gemini 2.0+ models
in the JSON Mode documentation.

* refactor(gemini): use responseJsonSchema by default for Gemini 2.0+

Remove opt-in flag `use_json_schema` and automatically detect model version:
- Gemini 2.0+: uses responseJsonSchema (standard JSON Schema, supports additionalProperties)
- Gemini 1.5: uses responseSchema (OpenAPI format, legacy)

This follows LiteLLM's philosophy of abstracting provider differences -
users write the same code regardless of model version.
2026-01-14 04:11:41 +05:30
Harshit JainandGitHub fbb8f98213 fix: num_retries in litellm_params (#18968) as per config (#18975) 2026-01-14 04:07:36 +05:30
Debnil SurandGitHub d94af171db fix(exception_mapping): handle exceptions without response parameter (#18919)
When extract_and_raise_litellm_exception tries to raise a LiteLLM exception
from an error string, it was always passing the response parameter. However,
some exceptions like APIConnectionError don't accept this parameter, causing
a TypeError.

This fix tries to raise the exception with the response parameter first,
and falls back to raising without it if a TypeError occurs.

This fixes the error:
TypeError: APIConnectionError.__init__() got an unexpected keyword argument 'response'

Which was occurring when Gemini returned UNEXPECTED_TOOL_CALL finish reason
and LiteLLM tried to convert the error to an APIConnectionError.

Fixes: cascading error when Gemini uses thinking feature (__thought__ tool calls)
2026-01-14 04:03:05 +05:30
Ryan MalloyandGitHub f76938af5e fix(ollama): set finish_reason to tool_calls and remove broken capability check (#18924)
* Update CLAUDE.md with qwen3 tool_calls bug fix instructions (#18922)

* fix(ollama): set finish_reason to "tool_calls" when tool_calls present

When qwen3 models return tool_calls through Ollama, the finish_reason
was incorrectly left as "stop" instead of being set to "tool_calls".
This caused clients to miss the tool_calls in the response.

Added _get_finish_reason helper method following OpenAI provider's
pattern, and fixed both streaming and non-streaming response paths.

Fixes: https://github.com/BerriAI/litellm/issues/18922

* fix(ollama): pass tools directly without model capability check

The previous code tried to check model capability via get_model_info()
which made network calls to localhost:11434. When Ollama is remote,
this fails and falls back to JSON format, breaking tool calling.

Ollama 0.4+ supports native tool calling - let Ollama handle
model capability detection instead of LiteLLM.

Fixes #18922

* fix(ollama): transform tool_calls response to OpenAI format

Ollama returns tool_calls with arguments as dict, but OpenAI format
requires arguments to be a JSON string. Also ensures 'type': 'function'
field is present.

Completes the fix for #18922

* fix(ollama): set finish_reason to "tool_calls" when tool_calls present

Fixes #18922

Two issues addressed:

1. Remove broken model capability check
   - get_model_info() fails when Ollama runs on remote server
   - Broken fallback triggered JSON prompt injection
   - Now passes tools directly - Ollama 0.4+ handles detection

2. Set finish_reason correctly
   - Was hardcoded to "stop" even with tool_calls present
   - Clients use this to know how to process the response
   - Now returns "tool_calls" when tool_calls are in response

Both streaming and non-streaming responses are fixed.

Tests:
- All 14 existing Ollama tests pass
- Added 3 focused tests for the fixes
2026-01-14 03:52:26 +05:30
xiaofanandGitHub f8836cb2a7 Fix Swagger UI path with server_root_path in OpenAPI schema (#18947)
Adds 'servers' field to OpenAPI schema when server_root_path is set, ensuring correct Swagger UI execute path for reverse proxies and subpath deployments. Includes tests to verify correct server URL handling for various root path formats.
2026-01-14 03:48:43 +05:30
Mateusz SzewczykandGitHub 72dc65fbb4 chore: allow passing scope id for watsonx inferencing (#18959)
* chore: allow inference with space

* make lint and make format
2026-01-14 03:47:20 +05:30
Matthias HumtandGitHub 9adc19deab Normalize OpenAI SDK BaseModel choices/messages to avoid Pydantic serializer warnings (#18972)
* Normalize BaseModel choices + suppress serializer warnings

* Fix ModelResponse normalization and test deps
2026-01-14 03:40:11 +05:30
cbb72045a3 fix(ui): use non-streaming method for endpoint v1/a2a/message/send in… (#19025)
* Add end to end integration tests for batches

* Add end to end integration tests for batches

* Add end to end integration tests for batches

* Fix linter errors: remove unused imports and variables

* Add end to end integration tests for batches

* Add end to end integration tests for batches

* Add end to end integration tests for batches

* Add end to end integration tests for batches

* chore: document temporary grype ignore for CVE-2019-1010022

* chore: add config option

* chore: add ALLOWED_CVES

* refetch after key create

* test: remove flaky azure oidc embedding test

* fixing build

* bump: version 1.80.15 → 1.80.16

* [Fix] MSFT SSO - allow setting custom MSFT Base URLs (#18977)

* fix TestCustomMicrosoftSSO

* init CustomMicrosoftSSO

* use CustomMicrosoftSSO

* docs fix

* docs fix

* [Feat] UI Feedback Form - why LiteLLM  (#18999)

* init survey prompt

* init survey modal

* init Survey Modal

* POST feedback hook

* survey Modal

* add other

* in product survey fixes

* fix survey prompt

* fix survey

* fix build

* ui new build

* [Feat] MSFT SSO - allow overriding env var attribute names  (#18998)

* add MSFT SSO constants

* fix MSFT SSO env vars

* test_microsoft_sso_handler_openid_from_response_with_custom_attributes

* Add pricing of azure_ai/claude-opus-4-5

* test: temporarily disable flaky responses_id_security tests

* fix(ui): use non-streaming method for endpoint v1/a2a/message/send in A2A playground

'

---------

Co-authored-by: Ephrim Stanley <ephrim.stanley@point72.com>
Co-authored-by: Yuta Saito <uc4w6c@bma.biglobe.ne.jp>
Co-authored-by: yuneng-jiang <yuneng.jiang@gmail.com>
Co-authored-by: YutaSaito <36355491+uc4w6c@users.noreply.github.com>
Co-authored-by: Ishaan Jaff <ishaanjaffer0324@gmail.com>
Co-authored-by: Sameer Kankute <sameer@berri.ai>
2026-01-14 03:29:10 +05:30
Jack Temple 9e08c2207f fix: enable JSON logging via configuration and add regression test 2026-01-13 09:38:19 -07:00
Sameer KankuteandGitHub 93203cda7c Merge pull request #19027 from BerriAI/litellm_add_0_budget_model_bypass
[Feat] Add support for 0 cost models
2026-01-13 18:05:36 +05:30
Sameer KankuteandGitHub e98c2e4425 Merge pull request #19012 from BerriAI/litellm_fix_model_deployment_routing
Fix: Model matching priority in configuration
2026-01-13 17:55:01 +05:30
Sameer KankuteandGitHub bb0ab38636 Merge pull request #19007 from BerriAI/litellm_fix_header_forwarding_passthrough
Fix: Header forwarding in bedrock passthrough
2026-01-13 17:50:14 +05:30
Sameer KankuteandGitHub 54f6f55c98 Merge pull request #18873 from BerriAI/litellm_staging_01_09_2026
staging 01/09/2025
2026-01-13 17:31:44 +05:30
Sameer Kankute de6330b6b6 Fix test_async_otel_callback[False] 2026-01-13 16:59:17 +05:30
Sameer Kankute 762a3ef090 Add support for 0 cost models 2026-01-13 16:39:57 +05:30
Sameer KankuteandGitHub d656f01bc9 Merge pull request #19009 from Dima-Mediator/fix-image-tokens-spend-logging
Fix image tokens spend logging for /images/generations
2026-01-13 15:03:37 +05:30
Igal Boxerman 8cff86ff01 fix(guardrails): use clean error messages for blocked requests (#19022)
- Add `should_wrap_with_default_message` parameter to GuardrailRaisedException
- Update Generic Guardrail API to use clean error messages without wrapper
- When should_wrap_with_default_message=False, exception shows the original
  blocked_reason directly (e.g., "pii detected") instead of verbose format
- Update test to verify GuardrailRaisedException is raised with clean message
2026-01-13 11:02:06 +02:00
Yuta Saito 2c8ac2c3f1 test: temporarily disable flaky responses_id_security tests 2026-01-13 15:51:37 +09:00
Sameer KankuteandGitHub ecb3959c3c Merge pull request #18208 from Chesars/fix/case-insensitive-model-cost-lookup
fix: case-insensitive model cost map lookup
2026-01-13 11:53:43 +05:30