From 9d2c3965ff8ff8cc52dd2700a4a865ecf851f735 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Wed, 30 Sep 2026 18:09:06 +0200 Subject: [PATCH] fix: send max_completion_tokens for Bedrock-prefixed OpenAI models (#30976) On an Amazon Bedrock OpenAI-compatible connection, GPT-5.6 and GPT-6 models have ids like `us.openai.gpt-6-sol` or `openai.gpt-6-luna`. These were not recognised as new OpenAI models, so `max_tokens` went upstream unchanged and Bedrock rejected it with a 400. Title and emoji generation failed on every chat, and any request with a token limit failed too. Setting `max_completion_tokens` by hand did not help, because non-OpenAI URLs convert it back to `max_tokens`. `is_openai_new_model()` now drops a leading `openai.` or `.openai.` (`us.`, `eu.`, `global.`, `us-gov.`) before matching, so these ids get the same handling as bare `gpt-5` ids. Ids that are not new models, such as `openai.gpt-oss-120b-1:0` and `gpt-4o`, are unchanged, and so is the LiteLLM `openai/` prefix. Fixes #30510 --- backend/open_webui/routers/openai.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/routers/openai.py b/backend/open_webui/routers/openai.py index b8a75c2bfb..66351100cd 100644 --- a/backend/open_webui/routers/openai.py +++ b/backend/open_webui/routers/openai.py @@ -1109,7 +1109,8 @@ def get_azure_allowed_params(api_version: str) -> set[str]: def is_openai_new_model(model: str) -> bool: - model_lower = model.lower() + # Amazon Bedrock ids carry a provider prefix, e.g. us.openai.gpt-6-sol + model_lower = re.sub(r'^(?:[a-z-]+\.)?openai\.', '', model.lower()) # o-series models (o1, o3, o4, o5, ...) if re.match(r'^o\d+', model_lower): return True