Commit Graph
5955 Commits
Author SHA1 Message Date
Sameer KankuteandGitHub 25fa1ad4e7 Merge pull request #20386 from naaa760/fix/extra-head-chat-comp-brid
fix(proxy): forward extra headers in chat
2026-02-04 09:11:43 +05:30
naaa760 0cb6b58768 fix(proxy): forward extra_headers in chat 2026-02-04 08:56:50 +05:30
Sameer KankuteandGitHub f11c16a0e7 Merge pull request #20334 from BerriAI/litellm_fireworks_ai_field_remoal
Fix: Extra inputs are not permitted, field: 'messages[2].provider_specific_fields
2026-02-04 08:50:04 +05:30
Sameer KankuteandGitHub bd87c446f2 Merge pull request #20329 from BerriAI/litellm_delete_files_bug
Add support for delete and GET via file_id for gemini
2026-02-04 08:49:24 +05:30
66eadfabe4 [Bug] Ensure MCP permissions are enforced when using JWT Auth (#20383)
* fix: enforce team MCP permissions when using JWT authentication

Root cause: When JWT auth was used with teams in groups (via team_ids_jwt_field),
the team's MCP permissions were not being enforced because:

1. The default team_allowed_routes did not include mcp_routes
2. allowed_routes_check() failed for MCP endpoints like /mcp/tools/list
3. find_team_with_model_access() skipped the team due to failed route check
4. team_id was None in UserAPIKeyAuth
5. MCPRequestHandler._get_allowed_mcp_servers_for_team() returned empty list

Fix: Add 'mcp_routes' to the default team_allowed_routes in LiteLLM_JWTAuth.

This ensures that teams can access MCP endpoints by default, allowing the
team's MCP server permissions to be properly enforced.

Added tests:
- test_reproduce_jwt_mcp_enforcement_issue: Reproduces the exact bug scenario
- test_verify_mcp_routes_in_default_team_allowed_routes: Verifies fix
- test_mcp_route_check_passes_for_team: Verifies route check works

Co-authored-by: ishaan <ishaan@berri.ai>

* test: add comprehensive E2E tests for JWT + team MCP permission enforcement

Added tests:
- test_e2e_jwt_team_mcp_permissions_enforced: Full E2E test verifying JWT auth
  with teams in groups properly sets team_id and MCPRequestHandler returns
  the team's MCP servers
- test_e2e_jwt_without_team_no_mcp_servers: Verifies no MCP servers returned
  when JWT has no teams
- test_e2e_jwt_team_mcp_key_intersection: Verifies intersection logic when
  both key and team have MCP permissions (result = intersection)

These tests verify the complete flow:
1. JWT token with team in groups field
2. JWT auth properly sets team_id on UserAPIKeyAuth
3. MCPRequestHandler.get_allowed_mcp_servers() returns team's MCP servers
4. Key/team permission intersection works correctly

Co-authored-by: ishaan <ishaan@berri.ai>

* test: add simple tests for JWT + MCP permission enforcement

Simple, focused tests that validate:
1. test_simple_jwt_mcp_permissions_enforced: JWT user with team gets team's MCP servers
2. test_simple_jwt_no_team_no_mcp_servers: JWT user without team gets no MCP servers
3. test_simple_jwt_team_id_required_for_mcp_permissions: Verifies team_id is required
4. test_jwt_auth_sets_team_id_for_mcp_route: JWT auth sets team_id for MCP routes

These tests directly verify the core MCP permission enforcement logic works
when using JWT authentication with teams.

Co-authored-by: ishaan <ishaan@berri.ai>

* Add test: MCP route without model still returns team_id

Co-authored-by: ishaan <ishaan@berri.ai>

* Add 2 debug logs for JWT+MCP troubleshooting

- handle_jwt.py: Log team route check result (team_id, route, is_allowed)
- user_api_key_auth_mcp.py: Log team_id when looking up MCP permissions

Co-authored-by: ishaan <ishaan@berri.ai>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: ishaan <ishaan@berri.ai>
2026-02-03 19:13:13 -08:00
yuneng-jiangandGitHub f9669cc132 Merge pull request #20375 from BerriAI/litellm_user_update_fix
[Fix] /user/update Allow for max_budget Resets
2026-02-03 17:02:16 -08:00
yuneng-jiang cf256c742f allow max_budget reset 2026-02-03 16:32:21 -08:00
michelligabrieleandGitHub a50896f91e fix: revert httpx client caching that caused closed client errors (#20025)
AsyncHTTPHandler.__del__ was closing httpx clients still in use by
AsyncOpenAI/AsyncAzureOpenAI due to independent cache lifecycles.
Restores standalone httpx client creation for OpenAI/Azure providers.
2026-02-03 16:15:04 -08:00
Ishaan JaffandGitHub d267c69086 [Feat] Use A2A registered agents with /chat/completions (#20362)
* test_a2a_registry_integration

* fix: render agents on model dropdown on UI

* init append_agents_to_model_group

* route_a2a_agent_request

* is_a2a_agent_model

* route_a2a_agent_request

* fix: error handling

* docs A2A usage

* docs fix

* feat: working A2a streaming

* fix transform
2026-02-03 15:25:38 -08:00
Xiaohan FuandGitHub 2b25d03046 Fix fail-open for grayswan and pass metadata to cygnal api endpoint (#19837)
* fix fail-open for grayswan; pass metadata to cygnal api endpoint; update docs

* pass litellm_metadata to cygnal in payload

* switch error msg to const, and clean exception handling.

* update pyproject.toml as requested

* Revert "update pyproject.toml as requested"

This reverts commit 4eece154d056ba33689a5584c86c8fc352bb7cdd.
2026-02-03 14:41:31 -08:00
cc76f95555 fix: check for model_response_choices before guardrail input (#19784)
* fix: check for model_response_choices before guardrail input

* test: add tests for responses api translation

* fix: protect other guardrail translations

* refactor: remove type ignores

* anthropic request body got mutated fix

* add warning when extra_body is provided but user is non premium

* fix: resolve mypy union-attr errors in anthropic guardrail handler

Cast choices[0] to Choices type before accessing .message attribute
to satisfy mypy's union type checking for Choices | StreamingChoices.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* add logger when model response has no choices for streaming /response and /messages

* update pyproject.toml as requested

* Revert "update pyproject.toml as requested"

This reverts commit 541a2b075a91b1b2d9efaf0407572f35bf5d4324.

* update pyproject.toml as requested

* Revert "update pyproject.toml as requested"

This reverts commit 716ea0caa1fee5e5f028d3f86479fedea2fac68b.

---------

Co-authored-by: Xiaohan Fu <xiaohan@grayswan.ai>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 14:41:13 -08:00
Ishaan JaffGitHubgreptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
9ed11c5cdf [Feat] Allow calling A2A agents through LiteLLM /chat/completions API (#20358)
* init A2AConfig

* add transform files

* feat: A2A

* feat A2AConfig

* fix get_secret_str

* init: A2AConfig

* init A2AConfig common utils

* A2AConfig

* test_a2a_completion_async_non_streaming

* fix

* Update litellm/main.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* add multi part conversation support

* extract_text_from_a2a_message

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-02-03 12:52:33 -08:00
Sameer Kankute ff568de2cb Add get files API support and tests 2026-02-03 18:57:39 +05:30
Sameer KankuteandGitHub b7f0d05dfd Merge pull request #20337 from BerriAI/main
update 02 staging PR
2026-02-03 17:08:01 +05:30
Sameer Kankute 3765d88809 Fix: Extra inputs are not permitted, field: 'messages[2].provider_specific_fields' 2026-02-03 16:23:18 +05:30
Sameer Kankute 31cdffd3a4 Revert "fix: prevent error when max_fallbacks exceeds available models (#20071)"
This reverts commit ef73f330f1.
2026-02-03 15:15:30 +05:30
Sameer Kankute 9a6bafe89e Fix litellm/tests/test_litellm/proxy/_experimental/mcp_server/test_semantic_tool_filter.py tests 2026-02-03 15:01:10 +05:30
Sameer Kankute eb8f4d3e05 Revert "fix: models loadbalancing billing issue by filter (#18891) (#19220)"
This reverts commit 72e5193451.
2026-02-03 15:00:57 +05:30
Cesar GarciaandGitHub b33e1e8019 feat(sdk): add proxy_auth for auto OAuth2/JWT token management (#20238)
Adds litellm.proxy_auth to automatically obtain and refresh OAuth2/JWT
tokens when connecting to LiteLLM Proxy or any OAuth2-protected endpoint.

- Add ProxyAuthHandler for token lifecycle (obtain, cache, refresh)
- Add AzureADCredential wrapper for azure-identity credentials
- Add GenericOAuth2Credential for any OAuth2 provider (Okta, Auth0, etc)
- Auto-inject Authorization headers in completion() and embedding()

Closes #19834
2026-02-02 22:04:08 -08:00
Ishaan JaffandGitHub 5cfcf67d7c [Feat] /chat/completions - allow using OpenAI style tools for web_search with VertexAI/gemini models (#20280)
* test_gemini_openai_web_search_tool_to_google_search

* feat: Handle OpenAI style web search tools
2026-02-02 19:36:36 -08:00
Harshit JainandGitHub ec279eb426 fix: proxy failure cases, now log ip and user agent, key hash, name (#20145) 2026-02-02 19:26:50 -08:00
04c348e7bb fixes failure metrics labels (#20152)
Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
2026-02-02 19:20:14 -08:00
Harshit JainandGitHub 76a399ba69 feat(guardrails): implement team-based isolation guardrails mgmnt (#19889)
* feat(guardrails): implement team-based isolation guardrails mgmnt

* fix lint errors

* add allow_team_guardrail_config for admin permissions
2026-02-02 19:14:55 -08:00
Ishaan JaffGitHubgreptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
079f49ff6a [Feat] - MCP Semantic Filtering Support (#20296)
* init: SemanticMCPToolFilter

* init: SemanticToolFilterHook

* test_e2e_semantic_filter

* mock tests: test_semantic_filter_basic_filtering

* Update litellm/proxy/_experimental/mcp_server/semantic_tool_filter.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* refactor folder/file organization

* docs fix

* fix filter

* fix: filter_tools

* fix linting tool filrer

* initialize_from_config

* fix: _expand_mcp_tools

* _initialize_semantic_tool_filter

* working: async_post_call_response_headers_hook

* clean up semantic tool filter

* add _initialize_semantic_tool_filter

* build_router_from_mcp_registry

* _get_tools_by_names

* fiix config

* async_post_call_response_headers_hook

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-02-02 18:28:53 -08:00
yuneng-jiang edfe2394b9 reset_spend endpoint 2026-02-02 15:52:30 -08:00
shin-bot-litellmandGitHub 31241416d4 feat: add base /scim/v2 endpoint for SCIM resource discovery (#20301)
Add the following SCIM v2 discovery endpoints per RFC 7643/7644:

- GET /scim/v2 - Base resource discovery (ListResponse of ResourceTypes)
- GET /scim/v2/ResourceTypes - List all supported resource types
- GET /scim/v2/ResourceTypes/{id} - Get a specific resource type (User/Group)
- GET /scim/v2/Schemas - List all supported schemas
- GET /scim/v2/Schemas/{uri} - Get a specific schema by URI

These endpoints are required by identity providers (Okta, Azure AD, etc.)
for SCIM resource discovery. Previously, GET /scim/v2 returned 404.

Also adds SCIMResourceType, SCIMSchema, and SCIMSchemaAttribute Pydantic
models to the SCIM types module.

Fixes #20295
2026-02-02 14:27:00 -08:00
yuneng-jiangandGitHub f1227ce5a8 Merge pull request #20111 from BerriAI/litellm_sso_map_teams
[Feature] SSO Config Team Mappings
2026-02-02 14:18:25 -08:00
shin-bot-litellmandGitHub 923b1cfd92 fix: MCP "Session not found" error on VSCode reconnect (#20298)
* fix: strip stale mcp-session-id header to prevent 'Session not found' error loop

When VSCode reconnects to LiteLLM's MCP endpoint after a reload, it sends
a stale mcp-session-id header. The session was already cleaned up, causing
a 404 'Session not found' error. VSCode retries with the same stale ID,
creating an infinite error loop.

Before forwarding requests to the StreamableHTTP session manager, check if
the mcp-session-id header references a valid session. If the session doesn't
exist, strip the header so a new session is created automatically.

Fixes #20292

* refactor: extract stale session handling into _strip_stale_mcp_session_header helper
2026-02-02 14:15:31 -08:00
yuneng-jiang 1f51f067eb Merge remote-tracking branch 'origin' into litellm_sso_map_teams 2026-02-02 12:40:12 -08:00
yuneng-jiangandGitHub b30c17c72d Merge pull request #20210 from BerriAI/litellm_key_block_rev
[Fix] Remove Key Blocking on Login
2026-02-02 12:00:26 -08:00
ryan-crabbeandGitHub 7a6820defa perf: cache _get_relevant_args_to_use_for_logging() at module level (#20077)
* perf: cache _get_relevant_args_to_use_for_logging() as module-level frozenset

The set of valid LLM API parameter names for logging was being rebuilt
on every request from 8 OpenAI SDK type annotations + set operations.
Since these are static TypedDict annotations that never change at
runtime, compute once at import time and store as a class-level
frozenset.

Line profiler: get_standard_logging_model_parameters() dropped from
774ms to 77ms across 12K calls (90% reduction, ~25µs/req saved).

* test: add tests for cached ModelParamHelper logging args

Verify cached frozenset matches dynamic computation and that
prompt content keys (messages, prompt, input) are excluded from
logged model parameters.
2026-02-02 10:54:49 -08:00
Sameer Kankute 7329fa8e7a fix: litellm_oss_staging_01_31_2026_3 failing tests 2026-02-02 18:50:58 +05:30
a513cfdefa fix: Set standard_logging_object for pass-through endpoints (#19887)
Pass-through endpoints (like vLLM classify) were not setting
standard_logging_object because _get_assembled_streaming_response
returns None for non-ModelResponse results.

This caused model_max_budget_limiter.async_log_success_event to raise
ValueError('standard_logging_payload is required').

The fix adds an elif branch in async_success_handler that mirrors the
non-pass-through code path.

Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
2026-02-02 18:25:02 +05:30
Nate TessmanandSameer Kankute d7997db912 fix: Include hidden params in chat response to responses api response transformation (#20084)
* Include hidden_params in chat completion to responses transformation

* add tests
2026-02-02 18:24:21 +05:30
Lovro SederandSameer Kankute 726988aed4 Fix Azure AI Anthropic CountTokens 401 auth error (#20069)
Add x-api-key header to CountTokens handler to match chat completion
authentication. Azure AI Anthropic requires this header per Microsoft's
native API format.
2026-02-02 18:24:06 +05:30
Abdullah Habib BiswasandSameer Kankute ef73f330f1 fix: prevent error when max_fallbacks exceeds available models (#20071) 2026-02-02 18:23:53 +05:30
07bffddbfa fix(bedrock): deduplicate toolResult and toolUse blocks in Converse message transformation (#20049)
Bedrock rejects requests when toolResult or toolUse blocks within a
single message contain duplicate IDs. The Converse message transformer
merges consecutive tool/assistant messages without checking for
duplicate toolUseId values, causing BedrockException errors.

Add _deduplicate_bedrock_content_blocks() — a generalized helper that
removes duplicate blocks by ID, logs a warning for each dropped
duplicate via verbose_logger, and preserves non-tool blocks (e.g.
cachePoint). Apply it at all four merge sites (sync/async × toolResult/
toolUse).

The Anthropic /messages path was fixed in PR #19324; this applies the
equivalent fix to the Bedrock Converse path.

Fixes #20048

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 18:23:43 +05:30
c9757cd0d7 fix(guardrails): populate applied_guardrails when Model Armor blocks content (#20034)
Previously, when Model Armor guardrail blocked a request/response,
the `applied_guardrails` field was not populated in the logs because
`add_guardrail_to_applied_guardrails_header()` was called after the
HTTPException was raised.

This fix moves the `add_guardrail_to_applied_guardrails_header()` call
to before the blocking check in all hooks:
- async_pre_call_hook (pre_call mode)
- async_moderation_hook (during_call mode)
- async_post_call_success_hook (post_call mode)
- async_post_call_streaming_iterator_hook (streaming)

This ensures that even when a guardrail blocks content, the guardrail
name is properly recorded in the logs for observability.

Added regression tests to verify applied_guardrails is populated when
content is blocked.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-02 18:21:44 +05:30
Harshit JainandSameer Kankute 6d86808eaf feat: enforce model-level TPM/RPM limits (enforce_model_rate_limits) … (#19230)
* feat: enforce model-level TPM/RPM limits (enforce_model_rate_limits) flag

* fix lint errors
2026-02-02 18:18:46 +05:30
Harshit JainandSameer Kankute a457162517 fix: handle deprecated 'redis_db' arg to prevent crash (#19808)
* fix: handle deprecated 'redis_db' arg to prevent crash

* renamed: changed dir
2026-02-02 18:18:05 +05:30
Cesar GarciaandSameer Kankute 61a84e9fdb fix(anthropic-adapter): truncate tool names exceeding OpenAI's 64-char limit (#20107)
When using LiteLLM's Anthropic /v1/messages endpoint to route requests to
OpenAI models, requests fail if any tool name exceeds OpenAI's 64-character
limit. Anthropic API has no such limit, causing compatibility issues.

Changes:
- Add truncate_tool_name() function using {55-char-prefix}_{8-char-hash} format
- Modify translate_anthropic_tools_to_openai() to truncate and return mapping
- Modify translate_anthropic_tool_choice_to_openai() to truncate tool name
- Restore original tool names in responses using the mapping
- Support tool name restoration in streaming responses
- Add backwards-compatible API (existing methods still work)

The fix only applies when routing Anthropic requests to OpenAI models.
Native Anthropic/Claude requests pass through unchanged.
2026-02-02 18:16:07 +05:30
Harshit JainandSameer Kankute 72e5193451 fix: models loadbalancing billing issue by filter (#18891) (#19220)
* fix: models loadbalancing billing issue by filter (#18891)

* fix: models loadbalancing billing issue by filter

* fix: separate key and team access groups in metadata

* fix: lint issues
2026-02-02 18:14:39 +05:30
Aarish AlamandSameer Kankute 3e04e20205 🐛 Bug Fix #19642 : bug in Vertex AI context caching (#19657)
* add vertex tests

* add uperbound

* add pagination tests
2026-02-02 18:13:34 +05:30
ChesarsandSameer Kankute 3215dc4d4e feat(vertex_ai): add global endpoint support for Qwen MaaS models
Fixes #19788

- Add `supported_regions: ["global"]` to Qwen MaaS models in model_prices_and_context_window.json
- Update `get_supported_regions()` to read directly from `model_cost` dict
- Update `get_complete_vertex_url()` to use `get_vertex_region()` for global-only models
- Update `create_vertex_url()` to generate correct URL for global location (without region prefix)
- Add tests for Qwen global endpoint support
2026-02-02 18:13:10 +05:30
Emerson GomesandSameer Kankute bb5397d9b2 fix: enforce scheme for Azure AI rerank api_base 2026-02-02 18:13:04 +05:30
ChesarsandSameer Kankute 11fd92c21b refactor(image-gen): move thought_signature to provider_specific_fields
Per review feedback, thought_signature should not be a root-level
param on ImageObject as it's not OpenAI compatible. Moved to
provider_specific_fields dict to match the pattern used in chat
completions (Message, Delta, Choices, etc).
2026-02-02 18:12:41 +05:30
ChesarsandSameer Kankute b2463291c7 fix(image-gen): add thought_signature to ImageObject for Gemini 3 Pro
Fixes #17184 - Gemini 3 Pro image preview model returns a thoughtSignature
field required for interactive image editing. This change:

- Adds thought_signature field to ImageObject class
- Updates Gemini and Vertex AI transformations to extract thoughtSignature
- Adds test for thought_signature in response transformation
2026-02-02 18:12:28 +05:30
Sameer KankuteandGitHub 27b4052231 Merge pull request #20244 from BerriAI/litellm_nova_sonic_imp_2_feb
[Feat]Add support for nova sonic Speech to speech model
2026-02-02 18:04:02 +05:30
Sameer Kankute bb363f0307 Fix: test_bedrock_optional_params_embeddings_dimension 2026-02-02 17:49:18 +05:30
Sameer Kankute 01cdc272ec Fix: test_bedrock_optional_params_embeddings_dimension 2026-02-02 17:47:20 +05:30