diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py
index cde626b55..d3ea27299 100644
--- a/backend/open_webui/utils/middleware.py
+++ b/backend/open_webui/utils/middleware.py
@@ -658,6 +658,12 @@ async def chat_completion_files_handler(
def apply_params_to_form_data(form_data, model):
params = form_data.pop("params", {})
+ custom_params = params.pop("custom_params", {})
+
+ if custom_params:
+ # If custom_params are provided, merge them into params
+ params = deep_update(params, custom_params)
+
if model.get("ollama"):
form_data["options"] = params
diff --git a/backend/open_webui/utils/payload.py b/backend/open_webui/utils/payload.py
index f4592cea9..bff819580 100644
--- a/backend/open_webui/utils/payload.py
+++ b/backend/open_webui/utils/payload.py
@@ -1,5 +1,6 @@
from open_webui.utils.task import prompt_template, prompt_variables_template
from open_webui.utils.misc import (
+ deep_update,
add_or_update_system_message,
)
@@ -59,6 +60,11 @@ def apply_model_params_to_body(
# inplace function: form_data is modified
def apply_model_params_to_body_openai(params: dict, form_data: dict) -> dict:
+ custom_params = params.pop("custom_params", {})
+ if custom_params:
+ # If there are custom parameters, we need to apply them first
+ params = deep_update(params, custom_params)
+
mappings = {
"temperature": float,
"top_p": float,
@@ -76,6 +82,11 @@ def apply_model_params_to_body_openai(params: dict, form_data: dict) -> dict:
def apply_model_params_to_body_ollama(params: dict, form_data: dict) -> dict:
+ custom_params = params.pop("custom_params", {})
+ if custom_params:
+ # If there are custom parameters, we need to apply them first
+ params = deep_update(params, custom_params)
+
# Convert OpenAI parameter names to Ollama parameter names if needed.
name_differences = {
"max_tokens": "num_predict",
diff --git a/src/lib/components/chat/Controls/Controls.svelte b/src/lib/components/chat/Controls/Controls.svelte
index 99d909276..d25d89a45 100644
--- a/src/lib/components/chat/Controls/Controls.svelte
+++ b/src/lib/components/chat/Controls/Controls.svelte
@@ -86,7 +86,7 @@