@@ -56,6 +56,7 @@ class SetupApiKeyRequest(BaseModel):
5656class ModelSettingsRequest (BaseModel ):
5757 """Request model for updating per-model settings."""
5858
59+ model_alias : Optional [str ] = None
5960 model_type_override : Optional [str ] = None
6061 max_context_window : Optional [int ] = None
6162 max_tokens : Optional [int ] = None
@@ -123,6 +124,7 @@ class GlobalSettingsRequest(BaseModel):
123124
124125 # Auth settings
125126 api_key : Optional [str ] = None
127+ skip_api_key_verification : Optional [bool ] = None
126128
127129
128130class HFDownloadRequest (BaseModel ):
@@ -1008,6 +1010,7 @@ async def list_models(is_admin: bool = Depends(require_admin)):
10081010 # Add settings if available
10091011 if settings :
10101012 model_data ["settings" ] = {
1013+ "model_alias" : settings .model_alias ,
10111014 "model_type_override" : settings .model_type_override ,
10121015 "max_context_window" : settings .max_context_window ,
10131016 "max_tokens" : settings .max_tokens ,
@@ -1121,6 +1124,25 @@ async def update_model_settings(
11211124 # (clear to default) from "not sent" (don't touch).
11221125 sent = request .model_fields_set
11231126 prev_engine_type = entry .engine_type # Track for requires_reload check
1127+ if "model_alias" in sent :
1128+ alias_value = request .model_alias .strip () if request .model_alias else None
1129+ if alias_value == "" :
1130+ alias_value = None
1131+ if alias_value is not None :
1132+ all_settings = settings_manager .get_all_settings ()
1133+ for mid , ms in all_settings .items ():
1134+ if mid != model_id and ms .model_alias == alias_value :
1135+ raise HTTPException (
1136+ status_code = 400 ,
1137+ detail = f"Alias '{ alias_value } ' is already used by model '{ mid } '" ,
1138+ )
1139+ for mid in engine_pool ._entries :
1140+ if mid != model_id and mid == alias_value :
1141+ raise HTTPException (
1142+ status_code = 400 ,
1143+ detail = f"Alias '{ alias_value } ' conflicts with model directory name '{ mid } '" ,
1144+ )
1145+ current_settings .model_alias = alias_value
11241146 if "model_type_override" in sent :
11251147 valid_types = {"llm" , "vlm" , "embedding" , "reranker" }
11261148 # Treat empty string as None (auto-detect)
@@ -1374,6 +1396,7 @@ async def get_global_settings(is_admin: bool = Depends(require_admin)):
13741396 "auth" : {
13751397 "api_key_set" : bool (global_settings .auth .api_key ),
13761398 "api_key" : global_settings .auth .api_key or "" ,
1399+ "skip_api_key_verification" : global_settings .auth .skip_api_key_verification ,
13771400 },
13781401 "claude_code" : {
13791402 "context_scaling_enabled" : global_settings .claude_code .context_scaling_enabled ,
@@ -1433,6 +1456,9 @@ async def update_global_settings(
14331456 # Apply server settings
14341457 if request .host is not None :
14351458 global_settings .server .host = request .host
1459+ # Reset skip_api_key_verification when host is not localhost
1460+ if request .host != "127.0.0.1" :
1461+ global_settings .auth .skip_api_key_verification = False
14361462 if request .port is not None :
14371463 global_settings .server .port = request .port
14381464 if request .log_level is not None :
@@ -1633,6 +1659,14 @@ async def update_global_settings(
16331659 runtime_applied .append ("api_key" )
16341660 logger .info ("API key updated via admin settings" )
16351661
1662+ if request .skip_api_key_verification is not None :
1663+ # Only allow enabling when host is localhost
1664+ if request .skip_api_key_verification and global_settings .server .host != "127.0.0.1" :
1665+ global_settings .auth .skip_api_key_verification = False
1666+ else :
1667+ global_settings .auth .skip_api_key_verification = request .skip_api_key_verification
1668+ runtime_applied .append ("skip_api_key_verification" )
1669+
16361670 # Validate settings
16371671 errors = global_settings .validate ()
16381672 if errors :
0 commit comments