Commit graph

28837 commits

Author SHA1 Message Date
Nicolai van der Smagt
09ba89d4fe
fix: add headers to metadata for guardrails on pass-through endpoints (#17992)
Fixes #17477

Guardrails couldn't access request headers (like User-Agent) on Bedrock
pass-through endpoints because headers were only stored in
data["proxy_server_request"]["headers"] but not in data["metadata"]["headers"]
where guardrails typically look for them.

This fix adds headers to metadata in add_litellm_data_to_request() so
guardrails can access User-Agent, API keys, and other header-based checks
on all endpoints including Bedrock pass-through.

Test added to verify headers are available in metadata for guardrails.
2025-12-16 13:41:34 +05:30
Eric84626
50606bf090
Added new step into rotate master key function for processing credentials table (#17952)
* fix: Return 403 exception when calling GET responses api

* fix: added new step into rotate master key function for processing credentials table
2025-12-16 09:40:22 +05:30
Xingjian Li
0eb7d975a1
fix: Support signed URLs with query parameters for Vertex AI Gemini (#17976)
- Fix _get_image_mime_type_from_url() to parse path without query params
- Resolves issues with Tencent Cloud COS and other signed URLs
2025-12-16 09:03:40 +05:30
Igal Boxerman
636efb7795
feat(pillar): add masking support and MCP call support (#17959)
- Add 'mask' action to SUPPORTED_ON_FLAGGED_ACTIONS
  - Automatically sanitizes sensitive content using masked_session_messages
  - Allows requests to proceed with masked content instead of blocking

- Add MCP call support
  - Add pre_mcp_call and during_mcp_call to supported_event_hooks
  - Verify mcp_call is supported in call_type Literal types

- Control exception details based on config
  - Conditionally include scanners/evidence in exceptions based on
    include_scanners and include_evidence settings
  - Reduces payload size when detailed exception info isn't needed

- Add comprehensive test coverage
  - Tests for masking functionality
  - Tests for conditional exception details
  - Tests for MCP call support

- Update documentation
  - Add Mask section explaining masking functionality
  - Clarify exception details control

All changes maintain backward compatibility.
2025-12-16 08:49:03 +05:30
Kris Xia
ae7c994526
fix(proxy): extract model from vertex ai passthrough url pattern (#17970)
extract model id from vertex ai passthrough routes that follow the pattern:
/vertex_ai/*/models/{model_id}:*

the model extraction now handles vertex ai routes by regex matching the model
segment from the url path, which allows proper model identification for
authentication and authorization in proxy pass-through endpoints.

adds comprehensive test coverage for vertex ai model extraction including:
- various vertex api versions (v1, v1beta1)
- different locations (us-central1, asia-southeast1)
- model names with special suffixes (gemini-1.5-pro, gemini-2.0-flash)
- precedence verification (request body model over url)
- non-vertex route isolation
2025-12-16 08:42:57 +05:30
Damien
fc3f82b85a
feat(gemini): support extra_headers in batch embeddings (#18004)
* feat(vertex_ai): support extra_headers in batch embeddings

* test(vertex_ai): add Gemini batch embeddings tests for custom api_base
2025-12-16 08:16:09 +05:30
Cesar Garcia
999ffabc39
fix(gemini): use JSON instead of form-data for image edit requests (#18012)
* fix(gemini): use JSON instead of form-data for image edit requests

Gemini's image edit API expects JSON body, not multipart/form-data.
The handler was sending form-encoded data which caused 400 errors:
"Invalid JSON payload received. Unexpected token."

Changes:
- Add use_multipart_form_data() method to BaseImageEditConfig (default True)
- Modify image_edit_handler to use json= when use_multipart_form_data() is False
- Override use_multipart_form_data() in GeminiImageEditConfig to return False

* test(gemini): add test for use_multipart_form_data
2025-12-16 07:41:02 +05:30
Cesar Garcia
4fdbbdfe6d
fix(anthropic): correct claude-3-7-sonnet max_tokens to 64K default (#17979)
Claude 3.7 Sonnet's default max_output_tokens is 64000, not 128000.
The 128K output limit requires the beta header 'output-128k-2025-02-19'.

This fixes the integration test failure where requests with max_tokens=128000
were being rejected by the Anthropic API.

Fixes test_multiturn_tool_calls in test_anthropic_responses_api.py
2025-12-16 07:27:40 +05:30
Ishaan Jaff
a4fb0df028
[Feat] New provider - Agent Gateway, add pydantic ai agents (#18013)
* init A2AProviderConfigManager

* move file

* move file

* add pydnatic ai folder

* init providers

* test_pydantic_ai_non_streaming

* fix import

* INIT pydantic

* use_a2a_form_fields

* TestPydanticAITransformation
2025-12-15 17:40:58 -08:00
YutaSaito
867ac17677
Merge pull request #18010 from BerriAI/litellm_fix_mcp_deepcopy_error
fix: mcp deepcopy error
2025-12-16 07:37:25 +09:00
Cesar Garcia
df19a747a2
feat(custom_llm): add image_edit and aimage_edit support (#17999)
* feat(custom_llm): add image_edit and aimage_edit support

Add support for image_edit and aimage_edit methods in CustomLLM class,
allowing users to implement custom image editing providers.

Changes:
- Add image_edit() and aimage_edit() methods to CustomLLM base class
- Add custom provider detection in litellm.image_edit() function
- Add tests for sync and async image_edit with custom handlers

* docs: add image_edit to CustomLLM documentation

- Add /v1/images/edits to supported routes
- Add Image Edit section with example
- Update Custom Handler Spec with image_edit methods
2025-12-15 14:16:36 -08:00
Yuta Saito
defea8b887 fix: mcp deepcopy error 2025-12-16 07:02:07 +09:00
Ishaan Jaff
b57b1beb61
[Feat] Guardrails - litellm content filter (#18007)
* add br ssn

* better description
2025-12-15 13:26:20 -08:00
vasilisazayka
d7e0044118
[docs] update SAP docs (#17974)
* docs(sap): update documentation

* docs(sap): update documentation

* docs(sap): update documentation

* docs(sap): update documentation
2025-12-15 13:25:26 -08:00
Alexsander Hamir
764a31f624
refactor: lazy load get_modified_max_tokens (#18002) 2025-12-15 12:33:01 -08:00
Alexsander Hamir
8f647dd25b
[Refactor] litellm/init.py: lazy load caches (#18001) 2025-12-15 12:13:51 -08:00
Alexsander Hamir
0629dcfdd5
[Refactor] litellm/init.py: lazy load http handlers (#17997) 2025-12-15 11:50:22 -08:00
Alexsander Hamir
93b1da7911
[Refactor] lazy imports: Use per-attribute lazy imports and extract shared constants (#17994) 2025-12-15 10:38:54 -08:00
Sameer Kankute
5a642c788a
Merge pull request #17980 from BerriAI/litellm_add_provider_specific_tools_in_responses
Add provider specific tools support in responses api
2025-12-15 22:53:08 +05:30
Sameer Kankute
174ab1fc66
Merge pull request #17967 from BerriAI/litellm_fireworks_ai_reasoning_param_support
Add support for reasoning param for fireworks AI models
2025-12-15 22:04:04 +05:30
Sameer Kankute
8a6f6385ed
Merge pull request #17966 from BerriAI/litellm_fix_gpt-1_image_cost_1
fix: cost calculation of gpt-image 1 model
2025-12-15 22:03:58 +05:30
Sameer Kankute
9866355315 Fix: Remove unused import 2025-12-15 21:59:46 +05:30
AlexsanderHamir
41b67b577b Fix: simplify PR template 2025-12-15 07:44:47 -08:00
Alexsander Hamir
debf3598f8
Add: CI/CD rules to default PR template for LiteLLM team. (#17985) 2025-12-15 07:41:17 -08:00
Alexsander Hamir
d743cde041
add: litellm team PR template (#17983) 2025-12-15 07:21:33 -08:00
Sameer Kankute
57bf6f74e8
Merge pull request #17844 from SamAcctX/patch-2
OpenRouter GPT 5.2, Mistral 3, and Devstral 2
2025-12-15 18:32:50 +05:30
Sameer Kankute
ccf3f7c5be Fix: use simpler implementation 2025-12-15 18:29:16 +05:30
Krish Dholakia
26fd6d5362
Guardrails API - support LLM tool call response checks on /chat/completions, /v1/responses, /v1/messages on regular + streaming calls (#17619)
* fix(unified_guardrails.py): send all chunks on completion of final stream

* feat(generic_guardrail_api.py): handle tool call response on streaming LLM responses

* fix(anthropic/chat/guardrail_translation): initial commit adding anthropic tool response streaming guardrails

enables guardrail checks on tool response from llm's to work via `/v1/messages`

* feat(anthropic/): working guardrail checks on tool response from LLMs

ensures guardrail checks on anthropic /v1/messages works as expected

* feat(responses/guardrail_translation): support tool call response guardrails on streaming for /v1/responses

ensures complete coverage of tool call responses

* refactor(openai.py): refactor to use consistent pydantic model for responses api tool response on streaming

enables non-openai model tool call response to work correctly with guardrail checks on /v1/responses

* test: update tests

* fix: fix linting error

* fix: fix failing tests

* fix: fix import errors

* fix(openai/chat/guardrail_transformation): fix final chunk returned on streaming
2025-12-15 18:19:52 +05:30
Sameer Kankute
54b09cab28 Add test for handling provider specific tools 2025-12-15 17:41:38 +05:30
Sameer Kankute
d3998d00dd Fix mypy errors 2025-12-15 17:41:05 +05:30
SamAcctX
6879924965
chore: GPT 5.2, Devstral 2, Mistral 3 backup json 2025-12-15 05:54:29 -06:00
Sameer Kankute
aa6d0056d3 Add anthropic programatic tool calling support for responses api 2025-12-15 17:22:57 +05:30
Sameer Kankute
f0928e1423 Add anthropic tool caching support 2025-12-15 17:21:24 +05:30
Sameer Kankute
64b12e0225 Add anthropic specific tools 2025-12-15 17:20:03 +05:30
Sameer Kankute
a108c95d1a Add gemini computer use tool support for responses api 2025-12-15 16:45:42 +05:30
Sameer Kankute
f59c2c1177 Add gemini tools support for responses api 2025-12-15 16:45:23 +05:30
Krish Dholakia
a3f5a94784
fix(openai/responses/guardrail_translation): fix basemodel import (#17977)
* fix(openai/responses/guardrail_translation): fix basemodel import

ensures /v1/responses output is correctly processed by guardrail handler

* fix: fix linting error

* fix: fix linting errors
2025-12-15 16:13:45 +05:30
Cesar Garcia
6ddc7875ea
Fix: add OpenAI-compatible API for Anthropic with modify_params=True (#17106)
* docs: add OpenAI-compatible API limitations for Anthropic thinking

Document the fundamental incompatibility between Anthropic extended
thinking and OpenAI-compatible API clients. Explains:

- Why thinking_blocks must be resent (stateless vs stateful APIs)
- OpenAI vs Anthropic architecture differences
- Solutions for client developers

* Update docs

* fix: auto-drop thinking param when thinking_blocks missing

When modify_params=True, LiteLLM now automatically drops the 'thinking'
param if the last assistant message with tool_calls is missing
thinking_blocks. This prevents the Anthropic error:
"Expected thinking or redacted_thinking, but found tool_use"

This workaround addresses the OpenAI-Anthropic API incompatibility where
OpenAI-compatible clients don't preserve thinking_blocks.
2025-12-15 13:35:46 +05:30
Sameer Kankute
57e75a3082 Add support for reasoning param 2025-12-15 09:12:35 +05:30
Sameer Kankute
aa578f78b9 fix: default quality cost calculation of gpt-image 1 model 2025-12-15 08:16:25 +05:30
Sameer Kankute
4f82147746 fix: cost calculation of gpt-image 1 model 2025-12-15 08:16:23 +05:30
YutaSaito
bba229f922
Merge pull request #17963 from BerriAI/litellm_feat_rest-mcp-list-tools-auth-header
add MCP auth header propagation
2025-12-15 08:20:50 +09:00
Yuta Saito
73e00c1382 fix: add MCP auth header propagation 2025-12-15 07:45:35 +09:00
Ishaan Jaffer
87ba4fabd7 docs fix 2025-12-14 14:20:47 -08:00
Ishaan Jaffer
2b434ac744 docs azure ai agents 2025-12-14 14:19:49 -08:00
Ishaan Jaffer
d65d97d609 fix: a2a gateway - azure foundry invoke 2025-12-14 14:06:35 -08:00
Ishaan Jaffer
71ab4a3108 docs 2025-12-14 14:06:16 -08:00
Ishaan Jaffer
493e4b3315 docs 2025-12-14 13:00:56 -08:00
Ishaan Jaffer
cf1eb0a594 docs vllm 2025-12-14 12:36:07 -08:00
Ishaan Jaffer
3cac6b0a40 vllm batch 2025-12-14 12:36:07 -08:00