Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ef07858
fix(passthrough): forward all multipart files with repeated field names
Jun 26, 2026
eb15fe6
refactor(passthrough): address multipart review feedback
Jun 26, 2026
c143291
fix(guardrails): match policy-pipeline block response to direct guard…
yassin-berriai Jun 26, 2026
ec4e014
feat(prometheus): add requested_model label to spend and requests met…
yucheng-berri Jun 26, 2026
01efcc1
fix(ui): stop listing bedrock_mantle models under the Bedrock provide…
mateo-berri Jun 26, 2026
7acc015
fix(mcp): stop logging tool-call input in MCP client (#31393)
ryan-crabbe-berri Jun 27, 2026
2e69708
feat(mcp): shared OAuth token foundation - challenge, store seam, exp…
tin-berri Jun 27, 2026
4157f3b
fix(passthrough): schedule spend logging via durable logging worker (…
mateo-berri Jun 27, 2026
b976545
fix(websearch): wrap agentic loop response in fake stream for streami…
mateo-berri Jun 27, 2026
99b1a32
feat(guardrails): add headroom guardrail for message compression (#31…
krrish-berri-2 Jun 27, 2026
de82f78
fix(websearch): sync tool_choice when converting web_search tools (#3…
shivamrawat1 Jun 27, 2026
e4aedb0
Merge pull request #31391 from BerriAI/litellm_multipart_file_upload
yuneng-berri Jun 27, 2026
ef66620
fix(cost): preserve Anthropic server_tool_use web search usage in cos…
mateo-berri Jun 27, 2026
0216c96
fix(otel): point AgentOps OTLP exporter at otlp.agentops.ai (#31490)
yucheng-berri Jun 27, 2026
4b398ef
feat(mcp): migrate authorization_code MCP to the v2 resolver (single-…
tin-berri Jun 27, 2026
80d3b69
fix(pass-through): remove stale routes by key so the registry stops g…
yassin-berriai Jun 27, 2026
64d8d7f
fix(bedrock): normalize Messages system role and adaptive-thinking fo…
mateo-berri Jun 27, 2026
437acc9
perf(proxy): bound event-loop blocking from oversized requests (#31497)
yassin-berriai Jun 27, 2026
c33a7f8
fix(proxy): cancel upstream LLM stream when client disconnects during…
yassin-berriai Jun 27, 2026
6349065
fix(pass_through): log pre-call guardrail blocks at WARNING, not ERRO…
yassin-berriai Jun 27, 2026
1883f97
fix(proxy/auth): honor user_api_key_cache_ttl for management-object c…
yassin-berriai Jun 27, 2026
b2e708d
feat(prometheus): add per-team litellm_team_members_metric gauge (#31…
yassin-berriai Jun 27, 2026
88c7755
fix(redis): loop-scope async Lua script registration (#31501)
yassin-berriai Jun 27, 2026
48b5a5a
style: unify ruff format width on 120 (#31518)
mateo-berri Jun 27, 2026
71e69d3
chore: ignore ruff-format reformat commits in git blame (#31520)
mateo-berri Jun 27, 2026
d515e5b
fix(vertex_ai): append rawPredict suffix for custom api_base on /v1/m…
shivamrawat1 Jun 27, 2026
5963b93
feat(mcp): cross-replica single-flight refresh for the v2 per-user OA…
tin-berri Jun 27, 2026
ef3dcf9
chore: remove unused keys from model cost map (#31528)
mateo-berri Jun 27, 2026
ac56320
fix(agents): show an agent's attached virtual key in the UI (#29619)
ryan-crabbe-berri Jun 27, 2026
234263f
fix(router): persist global retry_policy via /config/update (#29540)
ryan-crabbe-berri Jun 28, 2026
cc57fe2
chore: update Next.js build artifacts (2026-06-28 00:38 UTC, node v20…
shivamrawat1 Jun 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@

# style(ui): run prettier --write across the dashboard (#29622)
7edf3a9cb55548b143df1692f4ed7c4681d7fcf7

# style: reformat litellm/ with ruff format (#31317)
430b5b8f1b12dc261a49fda99ac5d1b22381a428

# style: unify ruff format width on 120 (#31518)
3dfbeabe626d203ac9de86024519d9a96c484ce4
2 changes: 1 addition & 1 deletion .github/workflows/test-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
echo "No changed litellm Python files to check with ruff format."
exit 0
fi
xargs uv run --no-sync ruff format --check --line-length 88 --exclude '/enterprise/' < "$RUNNER_TEMP/ruff_format_files.txt"
xargs uv run --no-sync ruff format --check --exclude '/enterprise/' < "$RUNNER_TEMP/ruff_format_files.txt"

- name: Debug - Check file state
run: |
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ install-hooks:
./scripts/install_git_hooks.sh

# Formatting
# 88-column wrap matches the Black width the whole repo is formatted to; ruff.toml's
# global line-length is 120 (for E501/isort), so 88 is forced here.
# Wrap width is ruff.toml's single source of truth (line-length = 120), shared by the
# formatter, E501, and the import sorter so there's no 88-vs-120 split to reconcile.
format: install-dev
cd litellm && $(UV_RUN) ruff format --line-length 88 --exclude '/enterprise/' . && cd ..
cd litellm && $(UV_RUN) ruff format --exclude '/enterprise/' . && cd ..

format-check: install-dev
cd litellm && $(UV_RUN) ruff format --check --line-length 88 --exclude '/enterprise/' . && cd ..
cd litellm && $(UV_RUN) ruff format --check --exclude '/enterprise/' . && cd ..

# Linting targets
lint-ruff: install-dev
Expand Down
96 changes: 26 additions & 70 deletions litellm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
warnings.filterwarnings("ignore", message=".*conflict with protected namespace.*")
# Suppress Pydantic 2.11+ deprecation warning about accessing model_fields on instances
# This warning can accumulate during streaming and cause memory leaks
warnings.filterwarnings(
"ignore", message=".*Accessing the.*attribute on the instance is deprecated.*"
)
warnings.filterwarnings("ignore", message=".*Accessing the.*attribute on the instance is deprecated.*")
### INIT VARIABLES #########################
import threading
import os
Expand Down Expand Up @@ -166,13 +164,9 @@ def _dev_env_hot_reload_enabled() -> bool:
]
cold_storage_custom_logger: Optional[_custom_logger_compatible_callbacks_literal] = None
logged_real_time_event_types: Optional[Union[List[str], Literal["*"]]] = None
_known_custom_logger_compatible_callbacks: List = list(
get_args(_custom_logger_compatible_callbacks_literal)
)
_known_custom_logger_compatible_callbacks: List = list(get_args(_custom_logger_compatible_callbacks_literal))
callbacks: List[
Union[
Callable, _custom_logger_compatible_callbacks_literal, "CustomLogger"
] # CustomLogger is lazy-loaded
Union[Callable, _custom_logger_compatible_callbacks_literal, "CustomLogger"] # CustomLogger is lazy-loaded
] = []
callback_settings: Dict[str, Dict[str, Any]] = {}
initialized_langfuse_clients: int = 0
Expand All @@ -183,26 +177,16 @@ def _dev_env_hot_reload_enabled() -> bool:
require_auth_for_metrics_endpoint: Optional[bool] = True
argilla_batch_size: Optional[int] = None
datadog_use_v1: Optional[bool] = False # if you want to use v1 datadog logged payload.
gcs_pub_sub_use_v1: Optional[bool] = (
False # if you want to use v1 gcs pubsub logged payload
)
generic_api_use_v1: Optional[bool] = (
False # if you want to use v1 generic api logged payload
)
gcs_pub_sub_use_v1: Optional[bool] = False # if you want to use v1 gcs pubsub logged payload
generic_api_use_v1: Optional[bool] = False # if you want to use v1 generic api logged payload
argilla_transformation_object: Optional[Dict[str, Any]] = None
_async_input_callback: List[
Union[str, Callable, "CustomLogger"]
] = ( # CustomLogger is lazy-loaded
_async_input_callback: List[Union[str, Callable, "CustomLogger"]] = ( # CustomLogger is lazy-loaded
[]
) # internal variable - async custom callbacks are routed here.
_async_success_callback: List[
Union[str, Callable, "CustomLogger"]
] = ( # CustomLogger is lazy-loaded
_async_success_callback: List[Union[str, Callable, "CustomLogger"]] = ( # CustomLogger is lazy-loaded
[]
) # internal variable - async custom callbacks are routed here.
_async_failure_callback: List[
Union[str, Callable, "CustomLogger"]
] = ( # CustomLogger is lazy-loaded
_async_failure_callback: List[Union[str, Callable, "CustomLogger"]] = ( # CustomLogger is lazy-loaded
[]
) # internal variable - async custom callbacks are routed here.
pre_call_rules: List[Callable] = []
Expand Down Expand Up @@ -261,9 +245,7 @@ def _dev_env_hot_reload_enabled() -> bool:
) # When True, routes all OpenAI /chat/completions requests through the Responses API bridge
# When True, Gemini/Vertex Live setup is deferred until client `session.update`.
# Default False preserves historical behavior (auto-send setup on connect).
gemini_live_defer_setup: bool = (
os.getenv("LITELLM_GEMINI_LIVE_DEFER_SETUP", "false").lower() == "true"
)
gemini_live_defer_setup: bool = os.getenv("LITELLM_GEMINI_LIVE_DEFER_SETUP", "false").lower() == "true"
use_legacy_interactions_schema: bool = (
os.getenv("LITELLM_USE_LEGACY_INTERACTIONS_SCHEMA", "false").lower() == "true"
) # When True, sends Api-Revision: 2026-05-07 to Google so responses use the legacy `outputs`
Expand Down Expand Up @@ -317,19 +299,15 @@ def _dev_env_hot_reload_enabled() -> bool:
"params": ["project", "region_name", "token"],
"providers": ["vertex_ai", "bedrock", "watsonx", "azure", "vertex_ai_beta"],
}
use_litellm_proxy: bool = (
False # when True, requests will be sent to the specified litellm proxy endpoint
)
use_litellm_proxy: bool = False # when True, requests will be sent to the specified litellm proxy endpoint
use_client: bool = False
ssl_verify: Union[str, bool] = True
ssl_security_level: Optional[str] = None
ssl_certificate: Optional[str] = None
user_url_validation: bool = True
user_url_allowed_hosts: List[str] = []
provider_url_destination_allowed_hosts: List[str] = []
ssl_ecdh_curve: Optional[str] = (
None # Set to 'X25519' to disable PQC and improve performance
)
ssl_ecdh_curve: Optional[str] = None # Set to 'X25519' to disable PQC and improve performance
disable_streaming_logging: bool = False
disable_token_counter: bool = False
disable_add_transform_inline_image_block: bool = False
Expand Down Expand Up @@ -370,9 +348,7 @@ def _dev_env_hot_reload_enabled() -> bool:
##################
### PREVIEW FEATURES ###
enable_preview_features: bool = False
return_response_headers: bool = (
False # get response headers from LLM Api providers - example x-remaining-requests,
)
return_response_headers: bool = False # get response headers from LLM Api providers - example x-remaining-requests,
enable_json_schema_validation: bool = False
enable_model_config_credential_overrides: bool = False
enable_key_alias_format_validation: bool = (
Expand All @@ -384,17 +360,13 @@ def _dev_env_hot_reload_enabled() -> bool:
####################
logging: bool = True
enable_loadbalancing_on_batch_endpoints: Optional[bool] = None
require_managed_files: bool = (
False # proxy only - require target_model_names on POST /v1/files
)
require_managed_files: bool = False # proxy only - require target_model_names on POST /v1/files
enable_caching_on_provider_specific_optional_params: bool = (
False # feature-flag for caching on optional params - e.g. 'top_k'
)
caching: bool = False # Not used anymore, will be removed in next MAJOR release - https://github.com/BerriAI/litellm/discussions/648
caching_with_models: bool = False # # Not used anymore, will be removed in next MAJOR release - https://github.com/BerriAI/litellm/discussions/648
cache: Optional["Cache"] = (
None # cache object <- use this - https://docs.litellm.ai/docs/caching
)
cache: Optional["Cache"] = None # cache object <- use this - https://docs.litellm.ai/docs/caching
default_in_memory_ttl: Optional[float] = None
default_redis_ttl: Optional[float] = None
default_redis_batch_cache_expiry: Optional[float] = None
Expand All @@ -404,15 +376,15 @@ def _dev_env_hot_reload_enabled() -> bool:
budget_duration: Optional[str] = (
None # proxy only - resets budget after fixed duration. You can set duration as seconds ("30s"), minutes ("30m"), hours ("30h"), days ("30d").
)
default_soft_budget: float = (
DEFAULT_SOFT_BUDGET # by default all litellm proxy keys have a soft budget of 50.0
)
default_soft_budget: float = DEFAULT_SOFT_BUDGET # by default all litellm proxy keys have a soft budget of 50.0
forward_traceparent_to_llm_provider: bool = False


_current_cost = 0.0 # private variable, used if max budget is set
error_logs: Dict = {}
add_function_to_prompt: bool = False # if function calling not supported by api, append function call details to system prompt
add_function_to_prompt: bool = (
False # if function calling not supported by api, append function call details to system prompt
)
client_session: Optional[httpx.Client] = None
aclient_session: Optional[httpx.AsyncClient] = None
model_fallbacks: Optional[List] = None # Deprecated for 'litellm.fallbacks'
Expand Down Expand Up @@ -476,9 +448,7 @@ def _dev_env_hot_reload_enabled() -> bool:
prometheus_end_user_metrics_max_series_per_metric: Optional[int] = 10000
prometheus_end_user_metrics_ttl_seconds: Optional[float] = 3600.0
prometheus_end_user_metrics_cleanup_interval_seconds: Optional[float] = 60.0
disable_add_prefix_to_prompt: bool = (
False # used by anthropic, to disable adding prefix to prompt
)
disable_add_prefix_to_prompt: bool = False # used by anthropic, to disable adding prefix to prompt
disable_copilot_system_to_assistant: bool = False # If false (default), converts all 'system' role messages to 'assistant' for GitHub Copilot compatibility. Set to true to disable this behavior.
public_mcp_servers: Optional[List[str]] = None
public_mcp_hub_strict_whitelist: bool = True
Expand All @@ -489,9 +459,7 @@ def _dev_env_hot_reload_enabled() -> bool:
# Old format: { "displayName": "url" } (for backward compatibility)
public_model_groups_links: Dict[str, Union[str, Dict[str, Any]]] = {}
#### REQUEST PRIORITIZATION #######
priority_reservation: Optional[Dict[str, Union[float, "PriorityReservationDict"]]] = (
None
)
priority_reservation: Optional[Dict[str, Union[float, "PriorityReservationDict"]]] = None
# priority_reservation_settings is lazy-loaded via __getattr__
# Only declare for type checking - at runtime __getattr__ handles it
if TYPE_CHECKING:
Expand All @@ -502,9 +470,7 @@ def _dev_env_hot_reload_enabled() -> bool:
use_aiohttp_transport: bool = True # Older variable, aiohttp is now the default. use disable_aiohttp_transport instead.
aiohttp_trust_env: bool = False # set to true to use HTTP_ Proxy settings
disable_aiohttp_transport: bool = False # Set this to true to use httpx instead
disable_aiohttp_trust_env: bool = (
False # When False, aiohttp will respect HTTP(S)_PROXY env vars
)
disable_aiohttp_trust_env: bool = False # When False, aiohttp will respect HTTP(S)_PROXY env vars
force_ipv4: bool = False # when True, litellm will force ipv4 for all LLM requests. Some users have seen httpx ConnectionError when using ipv6.
network_mock: bool = False # When True, use mock transport — no real network calls

Expand All @@ -520,9 +486,7 @@ def _dev_env_hot_reload_enabled() -> bool:
content_policy_fallbacks: Optional[List] = None
allowed_fails: int = 3
allow_dynamic_callback_disabling: bool = True
num_retries_per_request: Optional[int] = (
None # for the request overall (incl. fallbacks + model retries)
)
num_retries_per_request: Optional[int] = None # for the request overall (incl. fallbacks + model retries)
####### SECRET MANAGERS #####################
secret_manager_client: Optional[Any] = (
None # list of instantiated key management clients - e.g. azure kv, infisical, etc.
Expand All @@ -539,9 +503,7 @@ def _dev_env_hot_reload_enabled() -> bool:
from litellm.litellm_core_utils.get_model_cost_map import get_model_cost_map

model_cost = get_model_cost_map(url=model_cost_map_url)
cost_discount_config: Dict[
str, float
] = {} # Provider-specific cost discounts {"vertex_ai": 0.05} = 5% discount
cost_discount_config: Dict[str, float] = {} # Provider-specific cost discounts {"vertex_ai": 0.05} = 5% discount
cost_margin_config: Dict[
str, Union[float, Dict[str, float]]
] = {} # Provider-specific or global cost margins. Examples:
Expand Down Expand Up @@ -727,9 +689,7 @@ def is_openai_finetune_model(key: str) -> bool:
def add_known_models(model_cost_map: Optional[Dict] = None):
_map = model_cost_map if model_cost_map is not None else model_cost
for key, value in _map.items():
if value.get("litellm_provider") == "openai" and not is_openai_finetune_model(
key
):
if value.get("litellm_provider") == "openai" and not is_openai_finetune_model(key):
open_ai_chat_completion_models.add(key)
elif value.get("litellm_provider") == "text-completion-openai":
open_ai_text_completion_models.add(key)
Expand Down Expand Up @@ -807,9 +767,7 @@ def add_known_models(model_cost_map: Optional[Dict] = None):
nlp_cloud_models.add(key)
elif value.get("litellm_provider") == "aleph_alpha":
aleph_alpha_models.add(key)
elif value.get(
"litellm_provider"
) == "bedrock" and not is_bedrock_pricing_only_model(key):
elif value.get("litellm_provider") == "bedrock" and not is_bedrock_pricing_only_model(key):
bedrock_models.add(key)
elif value.get("litellm_provider") == "bedrock_converse":
bedrock_converse_models.add(key)
Expand Down Expand Up @@ -1445,9 +1403,7 @@ def add_known_models(model_cost_map: Optional[Dict] = None):
from .types.llms.custom_llm import CustomLLMItem

custom_provider_map: List[CustomLLMItem] = []
_custom_providers: List[
str
] = [] # internal helper util, used to track names of custom providers
_custom_providers: List[str] = [] # internal helper util, used to track names of custom providers
disable_hf_tokenizer_download: Optional[bool] = (
None # disable huggingface tokenizer download. Defaults to openai clk100
)
Expand Down
8 changes: 2 additions & 6 deletions litellm/_lazy_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,7 @@ def _get_lazy_import_registry() -> dict[str, Callable[[str], Any]]:
return _LAZY_IMPORT_REGISTRY


def _generic_lazy_import(
name: str, import_map: dict[str, tuple[str, str]], category: str
) -> Any:
def _generic_lazy_import(name: str, import_map: dict[str, tuple[str, str]], category: str) -> Any:
"""
Generic function that handles lazy importing for most attributes.

Expand Down Expand Up @@ -325,9 +323,7 @@ def _lazy_import_litellm_logging(name: str) -> Any:

def _lazy_import_llm_provider_logic(name: str) -> Any:
"""Handler for LLM provider logic functions (get_llm_provider, etc.)"""
return _generic_lazy_import(
name, _LLM_PROVIDER_LOGIC_IMPORT_MAP, "LLM provider logic"
)
return _generic_lazy_import(name, _LLM_PROVIDER_LOGIC_IMPORT_MAP, "LLM provider logic")


def _lazy_import_utils_module(name: str) -> Any:
Expand Down
12 changes: 3 additions & 9 deletions litellm/_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
"`litellm.set_verbose` is deprecated. Please set `os.environ['LITELLM_LOG'] = 'DEBUG'` for debug logs."
)

_ENABLE_SECRET_REDACTION = (
os.getenv("LITELLM_DISABLE_REDACT_SECRETS", "").lower() != "true"
)
_ENABLE_SECRET_REDACTION = os.getenv("LITELLM_DISABLE_REDACT_SECRETS", "").lower() != "true"


def _redact_string(value: str) -> str:
Expand Down Expand Up @@ -64,9 +62,7 @@ def filter(self, record: logging.LogRecord) -> bool:
# Redact exception tracebacks
if record.exc_info and record.exc_info[1] is not None:
try:
record.exc_text = _redact_string(
self._formatter.formatException(record.exc_info)
)
record.exc_text = _redact_string(self._formatter.formatException(record.exc_info))
except Exception:
pass

Expand Down Expand Up @@ -189,9 +185,7 @@ def format(self, record):
json_record["logger"] = f"{record.filename}:{record.lineno}"

if record.exc_info:
json_record["stacktrace"] = record.exc_text or self.formatException(
record.exc_info
)
json_record["stacktrace"] = record.exc_text or self.formatException(record.exc_info)

return safe_dumps(json_record)

Expand Down
Loading
Loading