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 `<region>.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
This commit is contained in:
Classic298 2026-09-30 18:09:06 +02:00 • committed by GitHub
parent 101cdb6f78
commit 9d2c3965ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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