mirror of
https://github.com/tiennm99/litellm.git
synced 2026-06-18 00:48:01 +00:00
feat(ui): add forward_client_headers_to_llm_api toggle to general settings (#21776)
* feat(ui): add forward_client_headers_to_llm_api toggle to general settings * feat(ui): add forward_client_headers_to_llm_api toggle to UI Settings tab - Add toggle to UISettings.tsx frontend (switch + label + description) - Add field to UISettings model and ALLOWED_UI_SETTINGS_FIELDS - Sync setting to general_settings on get/update so proxy picks it up at runtime --------- Co-authored-by: shin-bot-litellm <shin-bot-litellm@users.noreply.github.com>
This commit is contained in:
@@ -2149,6 +2149,10 @@ class ConfigGeneralSettings(LiteLLMPydanticObjectBase):
|
||||
None,
|
||||
description="If True, models and config are stored in and loaded from the database. Default is False.",
|
||||
)
|
||||
forward_client_headers_to_llm_api: Optional[bool] = Field(
|
||||
None,
|
||||
description="If True, forwards client headers (e.g. Authorization) to the LLM API. Required for Claude Code with Max subscription.",
|
||||
)
|
||||
|
||||
|
||||
class ConfigYAML(LiteLLMPydanticObjectBase):
|
||||
|
||||
@@ -11387,6 +11387,7 @@ async def get_config_list(
|
||||
"mcp_internal_ip_ranges": {"type": "List"},
|
||||
"mcp_trusted_proxy_ranges": {"type": "List"},
|
||||
"always_include_stream_usage": {"type": "Boolean"},
|
||||
"forward_client_headers_to_llm_api": {"type": "Boolean"},
|
||||
}
|
||||
|
||||
return_val = []
|
||||
|
||||
@@ -88,6 +88,11 @@ class UISettings(BaseModel):
|
||||
description="If true, requires authentication for accessing the public AI Hub."
|
||||
)
|
||||
|
||||
forward_client_headers_to_llm_api: bool = Field(
|
||||
default=False,
|
||||
description="If enabled, forwards client headers (e.g. Authorization) to the LLM API. Required for Claude Code with Max subscription.",
|
||||
)
|
||||
|
||||
|
||||
class UISettingsResponse(SettingsResponse):
|
||||
"""Response model for UI settings"""
|
||||
@@ -101,6 +106,7 @@ ALLOWED_UI_SETTINGS_FIELDS = {
|
||||
"disable_team_admin_delete_team_user",
|
||||
"enabled_ui_pages_internal_users",
|
||||
"require_auth_for_public_ai_hub",
|
||||
"forward_client_headers_to_llm_api",
|
||||
}
|
||||
|
||||
|
||||
@@ -937,6 +943,15 @@ async def get_ui_settings():
|
||||
k: v for k, v in ui_settings.items() if k in ALLOWED_UI_SETTINGS_FIELDS
|
||||
}
|
||||
|
||||
# Sync forward_client_headers_to_llm_api into general_settings so the proxy
|
||||
# picks it up at runtime (covers server restart scenarios).
|
||||
if "forward_client_headers_to_llm_api" in ui_settings:
|
||||
from litellm.proxy.proxy_server import general_settings
|
||||
|
||||
general_settings["forward_client_headers_to_llm_api"] = ui_settings[
|
||||
"forward_client_headers_to_llm_api"
|
||||
]
|
||||
|
||||
# Build config-like object for schema helper
|
||||
config: Dict[str, Any] = {"litellm_settings": {"ui_settings": ui_settings}}
|
||||
|
||||
@@ -1000,6 +1015,15 @@ async def update_ui_settings(
|
||||
},
|
||||
)
|
||||
|
||||
# Sync forward_client_headers_to_llm_api to general_settings so the proxy
|
||||
# picks it up at runtime (general_settings is checked in pre-call utils).
|
||||
if "forward_client_headers_to_llm_api" in ui_settings:
|
||||
from litellm.proxy.proxy_server import general_settings
|
||||
|
||||
general_settings["forward_client_headers_to_llm_api"] = ui_settings[
|
||||
"forward_client_headers_to_llm_api"
|
||||
]
|
||||
|
||||
return {
|
||||
"message": "UI settings updated successfully",
|
||||
"status": "success",
|
||||
|
||||
@@ -16,6 +16,7 @@ export default function UISettings() {
|
||||
const property = schema?.properties?.disable_model_add_for_internal_users;
|
||||
const disableTeamAdminDeleteProperty = schema?.properties?.disable_team_admin_delete_team_user;
|
||||
const requireAuthForPublicAIHubProperty = schema?.properties?.require_auth_for_public_ai_hub;
|
||||
const forwardClientHeadersProperty = schema?.properties?.forward_client_headers_to_llm_api;
|
||||
const enabledPagesProperty = schema?.properties?.enabled_ui_pages_internal_users;
|
||||
const values = data?.values ?? {};
|
||||
const isDisabledForInternalUsers = Boolean(values.disable_model_add_for_internal_users);
|
||||
@@ -60,6 +61,20 @@ export default function UISettings() {
|
||||
});
|
||||
};
|
||||
|
||||
const handleToggleForwardClientHeaders = (checked: boolean) => {
|
||||
updateSettings(
|
||||
{ forward_client_headers_to_llm_api: checked },
|
||||
{
|
||||
onSuccess: () => {
|
||||
NotificationManager.success("UI settings updated successfully");
|
||||
},
|
||||
onError: (error) => {
|
||||
NotificationManager.fromBackend(error);
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
const handleToggleRequireAuthForPublicAIHub = (checked: boolean) => {
|
||||
updateSettings(
|
||||
{ require_auth_for_public_ai_hub: checked },
|
||||
@@ -144,6 +159,23 @@ export default function UISettings() {
|
||||
</Space>
|
||||
</Space>
|
||||
|
||||
<Space align="start" size="middle">
|
||||
<Switch
|
||||
checked={Boolean(values.forward_client_headers_to_llm_api)}
|
||||
disabled={isUpdating}
|
||||
loading={isUpdating}
|
||||
onChange={handleToggleForwardClientHeaders}
|
||||
aria-label={forwardClientHeadersProperty?.description ?? "Forward client headers to LLM API"}
|
||||
/>
|
||||
<Space direction="vertical" size={4}>
|
||||
<Typography.Text strong>Forward client headers to LLM API</Typography.Text>
|
||||
<Typography.Text type="secondary">
|
||||
{forwardClientHeadersProperty?.description ??
|
||||
"If enabled, forwards client headers (e.g. Authorization) to the LLM API. Required for Claude Code with Max subscription."}
|
||||
</Typography.Text>
|
||||
</Space>
|
||||
</Space>
|
||||
|
||||
<Divider />
|
||||
|
||||
{/* Page Visibility for Internal Users */}
|
||||
|
||||
Reference in New Issue
Block a user