Commit graph

6027 commits

Author SHA1 Message Date
Ishaan Jaff
21d611554b
[Fix] MSFT SSO - allow setting custom MSFT Base URLs (#18977)
* fix TestCustomMicrosoftSSO

* init CustomMicrosoftSSO

* use CustomMicrosoftSSO

* docs fix

* docs fix
2026-01-12 18:26:53 -08:00
YutaSaito
9114e44b49
Merge pull request #18993 from BerriAI/litellm_fix_remove_flaky_test
[test] remove flaky azure oidc embedding test
2026-01-13 10:37:30 +09:00
Yuta Saito
a57f1e2e08 test: remove flaky azure oidc embedding test 2026-01-13 10:34:01 +09:00
yuneng-jiang
567f723214 Merge remote-tracking branch 'origin' into litellm_user_promethus_metrics 2026-01-12 15:59:16 -08:00
yuneng-jiang
a0a8412a7c Merge remote-tracking branch 'origin' into litellm_hakhundov_contribution 2026-01-12 15:58:12 -08:00
yuneng-jiang
c75a370619
Merge pull request #18910 from BerriAI/litellm_org_filtering_search
[Feature] /organization/list Query Params
2026-01-12 15:57:26 -08:00
YutaSaito
9caf685f1e
Merge pull request #18940 from BerriAI/litellm_fix_extra_headers
[fix] forward MCP extra headers case-insensitively
2026-01-13 06:03:19 +09:00
Ephrim Stanley
99cb59c2d2 Add end to end integration tests for batches 2026-01-12 13:58:47 -05:00
Sameer Kankute
c2fcc6aa92
Merge pull request #18945 from BerriAI/litellm_add_anthropic_tool_call_results
Add: missing anthropic tool results in response
2026-01-12 22:11:51 +05:30
Sameer Kankute
01e690307e Fix: litellm/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py 2026-01-12 22:02:18 +05:30
Ephrim Stanley
3256eb21a0 Add end to end integration tests for batches 2026-01-12 10:43:09 -05:00
Ephrim Stanley
935c249c45 Add end to end integration tests for batches 2026-01-12 09:53:54 -05:00
Sameer Kankute
5618da6605
Merge pull request #18960 from BerriAI/litellm_fix_embedding_forwardable_headers
Fix: Header forwarding for embeddings endpoint
2026-01-12 18:30:55 +05:30
Sameer Kankute
4c0ca53153
Merge pull request #18962 from BerriAI/main
merge main
2026-01-12 18:30:28 +05:30
Sameer Kankute
9a27a52424
Merge pull request #18956 from BerriAI/litellm_staging_01_12_2026
Litellm staging 01 12 2026
2026-01-12 18:27:57 +05:30
Sameer Kankute
8b5e2bcf25
Merge pull request #18957 from BerriAI/litellm_respones_api_gaurdrails1
Fix: gaurdrail moderation support with responses API
2026-01-12 18:16:22 +05:30
Sameer Kankute
ebf61998e0
Merge pull request #18954 from BerriAI/litellm_replicate_support
[Feat] Add all chat replicate models support
2026-01-12 18:15:46 +05:30
Sameer Kankute
f44178c18d
Merge pull request #18948 from BerriAI/litellm_gemini_imageConfig
Fix: [Bug]: Gemini Image Generation: imageConfig parameters
2026-01-12 18:14:19 +05:30
Sameer Kankute
98f1a0d0c4
Merge pull request #18946 from BerriAI/litellm_add_max_completion_tokens_with_thinking_budget
Fix: respect max_completion_tokens in thinking feat
2026-01-12 18:13:23 +05:30
Sameer Kankute
ec3e30a221
Merge branch 'main' into litellm_add_anthropic_tool_call_results 2026-01-12 18:13:06 +05:30
Sameer Kankute
db32ac217a
Merge pull request #18944 from BerriAI/litellm_fix_bedrock_passthrough_model_id
Fix : model id encoding for bedrock passthrough
2026-01-12 18:08:53 +05:30
Sameer Kankute
27b4c68662
Merge pull request #18942 from BerriAI/litellm_add_ssl_verify_bedrock2
[Bug]: Add Custom CA certificates to boto3 clients
2026-01-12 18:06:32 +05:30
Sameer Kankute
dbec9c7084 Fix: Header forwarding for embeddings endpoint 2026-01-12 18:00:48 +05:30
Cesar Garcia
a8282839e8
fix(text_completion): support token IDs (list of integers) as prompt (#18011)
* fix(text_completion): support token IDs (list of integers) as prompt

Add support for passing token IDs (list of integers) to the text_completion
endpoint for OpenAI-compatible providers (openai, azure, vllm, etc.).

Fixes #17118

* test(text_completion): replace live test with mock test for token IDs

Move token IDs test from local_testing to test_litellm with mocks
per PR review feedback.
2026-01-12 17:33:24 +05:30
Cesar Garcia
c81cd081e9
feat(bedrock): add OpenAI-compatible service_tier parameter translation (#18091)
* feat(bedrock): add OpenAI-compatible service_tier parameter translation

Translates OpenAI's service_tier parameter (string) to Bedrock's
serviceTier format (object with type field).

* docs(bedrock): add OpenAI-compatible service_tier parameter documentation

Document the automatic translation from OpenAI-style service_tier
parameter to Bedrock's native serviceTier format.

* feat(bedrock): add service_tier to response when present

According to OpenAI's API documentation, when service_tier is sent in the
request, it should be returned in the response. This commit implements
this behavior for Bedrock Converse API to maintain compatibility with
OpenAI's API.

Changes:
- Added serviceTier field to ConverseResponseBlock type definition
- Moved ServiceTierBlock definition before ConverseResponseBlock to fix
  type reference order
- Added response transformation to map Bedrock serviceTier (object) to
  OpenAI service_tier (string format)
- Added 4 new tests for response transformation with service_tier

The service_tier is only added to the response when present in Bedrock's
response, maintaining backward compatibility.
2026-01-12 17:28:49 +05:30
Sameer Kankute
ab85eb8f43 Fix: gaurdrail moderation support with responses API 2026-01-12 17:27:13 +05:30
Cesar Garcia
9a8e781cb9
fix(anthropic): preserve web_fetch_tool_result in multi-turn conversations (#18142)
Fixes #18137

Similar to the fix for web_search_tool_result (#17746, #17798), this PR
preserves web_fetch_tool_result blocks in multi-turn conversations.

Changes:
- Add handling for web_fetch_tool_result in transformation.py (non-streaming)
- Add capture of web_fetch_tool_result in handler.py (streaming)
- Fix streaming tool arguments bug where empty input {} was prepended to
  actual arguments by using empty string instead of str({})
- Add unit tests for web_fetch_tool_result handling
2026-01-12 17:18:33 +05:30
Cesar Garcia
f7912990b7
fix(gemini): add presence_penalty support for Google AI Studio (#18154)
Fixes #14753

Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
2026-01-12 17:12:19 +05:30
Cesar Garcia
573df855d3
fix(oci): handle OpenAI-style image_url object in multimodal messages (#18272)
The OCI adapter now accepts both string and object formats for image_url:
- String: "image_url": "https://example.com/image.png"
- Object: "image_url": {"url": "https://example.com/image.png"}

This fixes compatibility with OpenAI Vision API format.
2026-01-12 17:08:32 +05:30
Cesar Garcia
0ed261b34e
fix(gemini): fix negative text_tokens when using cache with images (#18768)
* fix(gemini): prevent negative text_tokens with explicit caching (#18750)

## Problem
When using Gemini with explicit caching (especially with images),
text_tokens would become negative (e.g., -3327) due to incorrectly
subtracting total cached_tokens from modality-specific text_tokens.

## Root Cause
The old code did:
```python
text_tokens = text_tokens - cached_tokens  # 737 - 4064 = -3327
```

This was wrong because:
- cached_tokens includes ALL modalities (text + image + audio + video)
- text_tokens only contains text
- Subtracting total from specific caused negative values

## Solution
Parse cacheTokensDetails to get per-modality cached token breakdown:
```python
if "cacheTokensDetails" in usage_metadata:
    cached_text_tokens = parse from cacheTokensDetails["TEXT"]
    text_tokens = text_tokens - cached_text_tokens  # Correct!
```

Now we subtract cached tokens per modality, preventing negatives.

## Changes
- Parse cacheTokensDetails field from Gemini response
- Calculate non-cached tokens per modality (text, image, audio)
- Remove incorrect global cached_tokens subtraction
- Add tests for explicit caching and implicit/no caching scenarios

## Testing
- Added test_gemini_cache_tokens_details_no_negative_values
- Added test_gemini_without_cache_tokens_details
- All existing Gemini caching tests pass

Fixes #18750

* feat: add cache_read_input_tokens to Usage object

Addresses reviewer feedback to include cached tokens at the top level
of the Usage object. This aligns with how Anthropic provider handles
cached tokens and ensures they are visible in the final usage response.

* fix: add cacheTokensDetails field to UsageMetadata TypedDict

Fixes mypy error where cacheTokensDetails was being accessed but not defined
in the UsageMetadata TypedDict type definition.
2026-01-12 17:04:33 +05:30
Cesar Garcia
932f06104d
fix: include IMAGE token count in cost calculation for Gemini models (#18876)
* fix: include IMAGE token count as separate usage count and pricing

* fix: remove duplicate TypedDict key and variable definitions

- Remove duplicate input_cost_per_image_token in ModelInfoBase TypedDict
- Remove duplicate image_tokens variable declaration in _calculate_usage()

Fixes MyPy errors:
- types/utils.py:146: Duplicate TypedDict key
- vertex_and_google_ai_studio_gemini.py:1541: Name already defined

---------

Co-authored-by: Thomas Rehn <271119+tremlin@users.noreply.github.com>
2026-01-12 17:03:42 +05:30
Harshit Jain
5ce3a56ac3
add better err handling for antropic (#18955) 2026-01-12 17:03:03 +05:30
Ryan Malloy
c2366194d4
fix(anthropic): prevent dropping thinking when any message has thinking_blocks (#18929)
* fix(anthropic): prevent dropping thinking when any message has thinking_blocks

When Claude returns multiple assistant messages in a conversation, some may
have thinking_blocks while others may not (Claude's behavior varies). The
previous logic only checked the LAST assistant message with tool_calls,
dropping the thinking param if it had no thinking_blocks.

This caused errors when earlier messages still contained thinking_blocks:
"When thinking is disabled, an assistant message cannot contain thinking"

The fix adds a new check: only drop thinking if NO assistant messages
have thinking_blocks. If any message has thinking_blocks, we keep
thinking enabled.

Fixes #18926

* chore: re-trigger CI
2026-01-12 16:29:44 +05:30
Igal Boxerman
6bb63525db
fix(guardrails): fix SerializationIterator error and pass tools to guardrail (#18932)
* fix(generic-guardrail-api): fix SerializationIterator error on multimodal requests

When sending multimodal messages (with images) through the Generic Guardrail API,
the `model_dump()` call fails with "Object of type SerializationIterator is not
JSON serializable" error.

Root cause: The `ChatCompletionAssistantMessage` type defines `content` as an
`Iterable` (not just `List`), and Pydantic's `model_dump()` creates a
`SerializationIterator` for iterables which is not JSON serializable.

Fix: Use `model_dump(mode="json")` which properly converts all iterables to
lists and ensures all complex objects are JSON serializable.

* fix(guardrails): pass tools (function definitions) to guardrail inputs

The unified guardrail handler was not passing the `tools` parameter
(function definitions) from the request to the guardrail inputs.
This meant guardrails could not inspect or validate tool definitions.

Added extraction of `data.get("tools")` and inclusion in the
GenericGuardrailAPIInputs passed to `apply_guardrail()`.

* test(guardrails): add tests for tools passed to guardrail

Added tests verifying that tools (function definitions) are correctly
passed to guardrails in the unified guardrail handler:
- test_tools_passed_to_guardrail
- test_multiple_tools_passed_to_guardrail
- test_no_tools_in_request
- test_tools_and_tool_calls_both_passed
2026-01-12 16:27:54 +05:30
Jonathan Hoyt
1169be44b5
fix(google_genai): forward extra_headers in generateContent adapter (#18935)
When using the generateContent endpoint with non-Google providers like
github_copilot, the extra_headers from model config were not being
forwarded to the underlying litellm.completion/acompletion calls.

This caused providers requiring custom headers (e.g., Editor-Version
for GitHub Copilot authentication) to reject requests with errors like
"missing Editor-Version header for IDE auth".

Changes:
- Forward extra_headers in _prepare_completion_kwargs() handler
- Pass extra_headers explicitly to adapter in generate_content()
- Pass extra_headers explicitly to adapter in agenerate_content_stream()
- Pass extra_headers explicitly to adapter in generate_content_stream()
- Add tests for extra_headers forwarding behavior
- Update existing test to expect extra_headers in passed fields

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-12 16:23:58 +05:30
Sameer Kankute
3d38ec4756 Add all replicate models in model cost map 2026-01-12 15:19:49 +05:30
Sameer Kankute
68fdcaea4a Fix: [Bug]: Gemini Image Generation: imageConfig parameters (imageSize, aspectRatio) are completely ignored #18656 2026-01-12 13:38:37 +05:30
Sameer Kankute
508e4da40e Fix: respect max_completion_tokens in thinking feat 2026-01-12 12:44:46 +05:30
Sameer Kankute
c96a7e80dd
Merge pull request #18898 from yogeshwaran10/litellm_fix_gemini_token_usage_details
fix: missing completion_tokens_details in gemini 3 flash when reasoning_effort is not used (#18896)
2026-01-12 12:33:40 +05:30
Sameer Kankute
3c1ffda117 Add: missing anthropic tool results 2026-01-12 11:44:07 +05:30
yogeshwaran10
0e960df8f4 refactor(tests): move gemini token usage tests to test_vertex_and_google_ai_studio_gemini.py 2026-01-12 11:20:13 +05:30
Sameer Kankute
dabb459d2b Fix : model id encoding for bedrock passthrough 2026-01-12 10:57:17 +05:30
Sameer Kankute
aa97a34a83 Fix tests/test_litellm/llms/bedrock/test_base_aws_llm.py 2026-01-12 09:05:28 +05:30
Sameer Kankute
a9e57cf272 [Bug]: Add Custom CA certificates to boto3 clients 2026-01-12 09:05:09 +05:30
Yuta Saito
76f79610b3 fix: forward MCP extra headers case-insensitively 2026-01-12 10:32:51 +09:00
YutaSaito
c171954629
Merge pull request #18912 from BerriAI/litellm_fix_pangea_guardrail
[fix] respect pangea guardrail default_on during initialization
2026-01-12 05:43:54 +09:00
Ishaan Jaffer
7aee1fcb81 OCR test fixes 2026-01-11 08:00:31 -08:00
Yuta Saito
cef087f88b fix: respect pangea guardrail default_on during initialization 2026-01-11 08:33:31 +09:00
Ishaan Jaffer
f1d516f0ae test fixes 2026-01-10 15:15:41 -08:00
Ishaan Jaffer
1ebe979eee test_manus_responses_api_with_file_upload 2026-01-10 15:12:00 -08:00