Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e58a561
Merge pull request #27906 from BerriAI/litellm_internal_staging
shin-berri May 14, 2026
a72414a
Merge pull request #28100 from BerriAI/litellm_internal_staging
yuneng-berri May 17, 2026
79b4578
Merge pull request #28292 from BerriAI/litellm_internal_staging
yuneng-berri May 19, 2026
35f6961
Merge pull request #28680 from BerriAI/litellm_internal_staging
yuneng-berri May 23, 2026
06f6cfc
Merge pull request #28709 from BerriAI/litellm_internal_staging
yuneng-berri May 23, 2026
a021a5b
Merge pull request #29243 from BerriAI/litellm_internal_staging
yuneng-berri May 29, 2026
5be0797
Merge pull request #29372 from BerriAI/litellm_internal_staging
yuneng-berri May 31, 2026
521ddc3
fix(proxy): resolve managed video model ids for auth (#29545)
shivamrawat1 Jun 3, 2026
8373712
fix(key_generate): allow team members to create keys on org-scoped te…
milan-berri Jun 3, 2026
2110b41
fix(vertex): strip output_config.effort for Vertex Claude models that…
mateo-berri Jun 3, 2026
ed04563
fix: passthrough endpoints duplicate logs (#29598)
mateo-berri Jun 3, 2026
0aea62b
Merge pull request #29632 from BerriAI/litellm_cherrypick_1_88_0_rc2
mateo-berri Jun 3, 2026
26e9689
fix(key_generate): exempt UI/CLI session tokens from the budget ceili…
yuneng-berri Jun 3, 2026
c2a0a6a
Merge pull request #29637 from BerriAI/litellm_cherrypick_1_88_0_rc3
mateo-berri Jun 4, 2026
c5d214c
fix(key_generate): harden GHSA-q775 session-token exemption against d…
mateo-berri Jun 4, 2026
67428bd
Merge pull request #29639 from BerriAI/litellm_ghsa_q775_defaults_rc188
mateo-berri Jun 4, 2026
3d00874
fix(proxy): match passthrough registry routes bare-to-bare with SERVE…
Sameerlite Jun 4, 2026
bde16ff
test(proxy): patch utils.get_server_root_path in passthrough auth tests
Sameerlite Jun 4, 2026
aa2deee
build(deps): bump pyjwt to 2.13.0 and ws override to 8.20.1
yuneng-berri Jun 8, 2026
f685f2f
Merge pull request #29987 from BerriAI/litellm_deps_pyjwt_ws_backport…
yuneng-berri Jun 8, 2026
b577372
chore(release): bump version to 1.88.1
yuneng-berri Jun 8, 2026
9c117a5
Merge pull request #29989 from BerriAI/litellm_bump_version_1_88_1
yuneng-berri Jun 9, 2026
5278206
feat(proxy): read cold-storage prompts back in the logs detail view
Bytechoreographer Jun 13, 2026
b7490e9
fix(proxy): release budget reservation when a request is cancelled mi…
Bytechoreographer Jun 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@ def transform_anthropic_messages_request(
"model", None
) # do not pass model in request body to vertex ai

sanitize_vertex_anthropic_output_params(anthropic_messages_request)
sanitize_vertex_anthropic_output_params(anthropic_messages_request, model)

return anthropic_messages_request
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,38 @@
keeps the parent module's import surface narrow.
"""

# Keys inside ``output_config`` that Vertex AI Claude does not accept.
# Add an entry only when a 400 "Extra inputs are not permitted" is
# reproducible against the live Vertex endpoint.
# Keys inside ``output_config`` that Vertex AI Claude rejects regardless of
# the target model. Add an entry only when a 400 "Extra inputs are not
# permitted" is reproducible against the live Vertex endpoint for every model.
VERTEX_UNSUPPORTED_OUTPUT_CONFIG_KEYS: frozenset = frozenset()


def sanitize_vertex_anthropic_output_params(data: dict) -> None:
def _model_accepts_output_config_effort(model: str) -> bool:
"""Whether ``model`` accepts ``output_config.effort`` on Vertex.

Opus/Sonnet 4.6+ advertise ``supports_output_config`` (or a reasoning
effort level) and accept it; Haiku 4.5 advertises neither and 400s on
``output_config.effort: Extra inputs are not permitted``. Imported lazily
so this stays a leaf module (see module docstring).
"""
from litellm.llms.anthropic.chat.transformation import AnthropicConfig

return AnthropicConfig._model_supports_effort_param(model)


def sanitize_vertex_anthropic_output_params(data: dict, model: str) -> None:
"""
Strip Vertex-unsupported keys from ``output_config`` /
``output_format`` in-place; forward whatever remains.

Behavior:
* ``output_config`` containing only unsupported keys (e.g. ``effort``
alone) is removed entirely so the request body has no empty dict.
* ``output_config`` containing a mix of supported + unsupported keys
has the unsupported subset filtered out and the rest forwarded.
* ``output_config`` that is supported in full passes through unchanged.
* ``output_config.effort`` is dropped for models that don't accept it
(e.g. Haiku 4.5) and forwarded for those that do (Opus/Sonnet 4.6+).
Clients like Claude Code inject it into every Messages payload, so the
gate has to live here rather than rely on the caller.
* Keys in ``VERTEX_UNSUPPORTED_OUTPUT_CONFIG_KEYS`` are always filtered.
* ``output_config`` left empty after filtering is removed so the request
body has no empty dict.
* ``output_format`` is forwarded as-is (Vertex AI Claude accepts it).
* Non-dict values for ``output_config`` are dropped to avoid sending
malformed payloads downstream.
Expand All @@ -37,11 +52,19 @@ def sanitize_vertex_anthropic_output_params(data: dict) -> None:
if not isinstance(output_config, dict):
data.pop("output_config", None)
return
sanitized = {
k: v
for k, v in output_config.items()
if k not in VERTEX_UNSUPPORTED_OUTPUT_CONFIG_KEYS
}

drop_keys = set(VERTEX_UNSUPPORTED_OUTPUT_CONFIG_KEYS)
if "effort" in output_config and not _model_accepts_output_config_effort(model):
from litellm._logging import verbose_logger

verbose_logger.debug(
"Dropping unsupported output_config.effort for vertex_ai model=%s "
"(no supports_output_config in the model map)",
model,
)
drop_keys.add("effort")

sanitized = {k: v for k, v in output_config.items() if k not in drop_keys}
if sanitized:
data["output_config"] = sanitized
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def transform_request(

data.pop("model", None) # vertex anthropic doesn't accept 'model' parameter

sanitize_vertex_anthropic_output_params(data)
sanitize_vertex_anthropic_output_params(data, model)

tools = optional_params.get("tools")
tool_search_used = self.is_tool_search_used(tools)
Expand Down
1 change: 1 addition & 0 deletions litellm/proxy/auth/auth_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ async def common_checks( # noqa: PLR0915
route=route,
request_headers=_safe_get_request_headers(request=request),
request_query_params=_safe_get_request_query_params(request=request),
llm_router=llm_router,
)

# 1. If team is blocked
Expand Down
35 changes: 29 additions & 6 deletions litellm/proxy/auth/auth_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,9 @@ def _route_uses_model_routing_sources(route: str) -> bool:


def _extract_models_from_managed_resource_id(
resource_id: Any, resource_id_field: Optional[str] = None
resource_id: Any,
resource_id_field: Optional[str] = None,
llm_router: Optional[Router] = None,
) -> List[str]:
if not isinstance(resource_id, str) or not resource_id:
return []
Expand Down Expand Up @@ -1301,16 +1303,18 @@ def _extract_models_from_managed_resource_id(
)

if resource_id_field == "video_id":
model_id = decode_video_id_with_provider(resource_id).get("model_id")
_append_model_candidates(
candidates=candidates,
value=decode_video_id_with_provider(resource_id).get("model_id"),
value=_resolve_model_id_with_router(model_id, llm_router),
)
else:
model_id = decode_character_id_with_provider(resource_id).get(
"model_id"
)
_append_model_candidates(
candidates=candidates,
value=decode_character_id_with_provider(resource_id).get(
"model_id"
),
value=_resolve_model_id_with_router(model_id, llm_router),
)
except Exception as e:
verbose_proxy_logger.debug(
Expand All @@ -1320,11 +1324,26 @@ def _extract_models_from_managed_resource_id(
return _dedupe_model_candidates(candidates)


def _resolve_model_id_with_router(
model_id: Optional[str], llm_router: Optional[Router]
) -> Optional[str]:
if model_id is None or llm_router is None:
return model_id
try:
return llm_router.resolve_model_name_from_model_id(model_id) or model_id
except Exception as e:
verbose_proxy_logger.debug(
"Unable to resolve model_id from managed resource ID: %s", str(e)
)
return model_id


def _extract_model_candidates_from_request(
request_data: dict,
route: str,
request_headers: Optional[Mapping[str, Any]] = None,
request_query_params: Optional[Mapping[str, Any]] = None,
llm_router: Optional[Router] = None,
) -> List[str]:
candidates: List[str] = []
uses_model_routing_sources = _route_uses_model_routing_sources(route=route)
Expand Down Expand Up @@ -1374,7 +1393,9 @@ def _extract_model_candidates_from_request(
_append_model_candidates(
candidates,
_extract_models_from_managed_resource_id(
request_data.get(field), resource_id_field=field
request_data.get(field),
resource_id_field=field,
llm_router=llm_router,
),
)

Expand All @@ -1396,12 +1417,14 @@ def get_model_from_request(
route: str,
request_headers: Optional[Mapping[str, Any]] = None,
request_query_params: Optional[Mapping[str, Any]] = None,
llm_router: Optional[Router] = None,
) -> Optional[Union[str, List[str]]]:
candidates = _extract_model_candidates_from_request(
request_data=request_data,
route=route,
request_headers=request_headers,
request_query_params=request_query_params,
llm_router=llm_router,
)
model = _format_model_candidates(candidates)

Expand Down
8 changes: 8 additions & 0 deletions litellm/proxy/auth/user_api_key_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,14 @@ def _get_model_from_request_context(
request_data: dict,
route: str,
request: Optional[Request],
llm_router: Optional[Any] = None,
) -> Optional[Union[str, List[str]]]:
return get_model_from_request(
request_data=request_data,
route=route,
request_headers=_safe_get_request_headers(request=request),
request_query_params=_safe_get_request_query_params(request=request),
llm_router=llm_router,
)


Expand Down Expand Up @@ -1034,6 +1036,7 @@ async def _user_api_key_auth_builder( # noqa: PLR0915
request_data=request_data,
route=route,
request=request,
llm_router=llm_router,
)
skip_budget_checks = False
if model is not None and llm_router is not None:
Expand Down Expand Up @@ -1451,6 +1454,7 @@ async def _user_api_key_auth_builder( # noqa: PLR0915
request_data=request_data,
route=route,
request=request,
llm_router=llm_router,
)
skip_budget_checks = False
if model is not None and llm_router is not None:
Expand Down Expand Up @@ -1579,6 +1583,7 @@ async def _user_api_key_auth_builder( # noqa: PLR0915
request_data=request_data,
route=route,
request=request,
llm_router=llm_router,
)
current_models = _get_model_names_for_budget_checks(
model=current_model
Expand Down Expand Up @@ -2159,6 +2164,7 @@ def _should_skip_budget_checks(
request_data=request_data,
route=route,
request=request,
llm_router=llm_router,
)
if model is not None and llm_router is not None:
return _is_model_cost_zero(model=model, llm_router=llm_router)
Expand Down Expand Up @@ -2475,6 +2481,7 @@ async def _enforce_key_and_fallback_model_access(
request_data=request_data,
route=route,
request=request,
llm_router=llm_router,
)

if model is not None:
Expand Down Expand Up @@ -2616,6 +2623,7 @@ async def _run_post_custom_auth_checks(
request_data=request_data,
route=route,
request=request,
llm_router=llm_router,
)
current_models = _get_model_names_for_budget_checks(model=current_model)

Expand Down
18 changes: 18 additions & 0 deletions litellm/proxy/common_request_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,15 @@ async def _on_deferred_stream_complete(
user_api_key_dict=user_api_key_dict,
response=response, # type: ignore[arg-type]
)
except asyncio.CancelledError:
from litellm.proxy.spend_tracking.budget_reservation import (
release_budget_reservation_on_cancel,
)

await release_budget_reservation_on_cancel(
getattr(user_api_key_dict, "budget_reservation", None)
)
raise
except Exception:
_exception_raised = True
raise
Expand Down Expand Up @@ -2054,6 +2063,15 @@ async def async_streaming_data_generator(
)
)
yield serialize_chunk(chunk)
except (asyncio.CancelledError, GeneratorExit):
from litellm.proxy.spend_tracking.budget_reservation import (
release_budget_reservation_on_cancel,
)

await release_budget_reservation_on_cancel(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High: Budget bypass on cancelled streams

A caller can start an expensive streaming request, receive generated chunks, then disconnect before the stream completes; this branch releases the reservation with actual_cost=0.0, and the success cost callback never runs. Reconcile the generated partial stream cost on cancellation, or otherwise keep a bounded reservation/charge path for streams that have already produced output instead of unconditionally releasing it.

getattr(user_api_key_dict, "budget_reservation", None)
)
raise
except Exception as e:
verbose_proxy_logger.exception(
"litellm.proxy.proxy_server.async_data_generator(): Exception occured - {}".format(
Expand Down
21 changes: 20 additions & 1 deletion litellm/proxy/management_endpoints/key_management_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,11 @@ async def _common_key_generation_helper( # noqa: PLR0915
# params can fill it, so the ceiling check only fires when the caller
# explicitly requested a budget.
_requested_max_budget = data.max_budget
# Same rationale for team_id: capture it before the defaults loop can inject
# one from default_key_generate_params, so the session-token exemption below
# only fires when the caller actually requested a team key (not a personal
# key whose team_id was auto-filled by config defaults).
_requested_team_id = data.team_id

# check if user set default key/generate params on config.yaml
if litellm.default_key_generate_params is not None:
Expand Down Expand Up @@ -722,8 +727,17 @@ async def _common_key_generation_helper( # noqa: PLR0915
# Delegated-authority ceiling (GHSA-q775-qw9r-2r4g): a non-admin caller
# with an explicit budget cannot grant a key a higher budget than their own.
# Callers with max_budget=None (unlimited) can delegate any budget.
# A UI/CLI session token's max_budget is a per-session chat spend cap
# (max_ui_session_budget), not a delegation authority, so it is exempt only
# when creating a team key - that key's spend is bounded by the team budget
# at request time. Personal keys keep the ceiling; nothing else bounds them.
is_ui_session_team_key = (
user_api_key_dict.team_id == UI_SESSION_TOKEN_TEAM_ID
and _requested_team_id is not None
)
if (
user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN.value
and not is_ui_session_team_key
and _requested_max_budget is not None
and user_api_key_dict.max_budget is not None
and _requested_max_budget > user_api_key_dict.max_budget
Expand Down Expand Up @@ -894,7 +908,12 @@ async def _common_key_generation_helper( # noqa: PLR0915
user_api_key_dict.user_role is not None
and user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN.value
)
if not _is_proxy_admin:
_org_inherited_from_team = (
team_table is not None
and team_table.organization_id is not None
and data.organization_id == team_table.organization_id
)
if not _is_proxy_admin and not _org_inherited_from_team:
await _validate_caller_can_assign_key_org(
user_api_key_dict=user_api_key_dict,
organization_id=data.organization_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ def _create_anthropic_response_logging_payload(

handles streaming and non-streaming responses
"""
# Only record complete_streaming_response for actual streaming responses.
# perform_redaction scrubs this field only when stream is True, so setting
# it on a non-streaming response would bypass message redaction.
if logging_obj.model_call_details.get("stream") is True:
logging_obj.model_call_details["complete_streaming_response"] = (
litellm_model_response
)
try:
# Get custom_llm_provider from logging object if available (e.g., azure_ai for Azure Anthropic)
custom_llm_provider = logging_obj.model_call_details.get(
Expand Down
Loading