fix: strip prefix id from model name in /responses endpoint (#28575)

The /openai/responses endpoint forwarded the prefixed model id (e.g.
"myprovider.gpt-4o") to the upstream provider instead of the stripped
native name, causing "model not found" errors when a connection has a
Prefix ID configured.

generate_chat_completion() already strips the prefix before forwarding;
apply the same strip_provider_model_prefix() call in responses() after
the urlIdx routing (which needs the prefixed id) and re-serialize the
body afterwards.

Also fixes the Azure non-v1 deployment path, which built the deployment
URL from the prefixed model name.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
xyonium
2026-08-17 14:53:00 +08:00
committed by GitHub
parent 3df485582d
commit 686d8dc54c

View File

@@ -1847,8 +1847,6 @@ async def responses(
# Enforce per-model access control
await check_model_access(user, await Models.get_model_by_id(model_id), BYPASS_MODEL_ACCESS_CONTROL)
body = JSONCodec.dumps(payload)
if model_id:
models = request.app.state.OPENAI_MODELS
if not models or model_id not in models:
@@ -1859,6 +1857,9 @@ async def responses(
url, key, api_config = await get_openai_connection(idx)
payload['model'] = strip_provider_model_prefix(payload['model'], api_config.get('prefix_id'))
body = JSONCodec.dumps(payload)
r = None
streaming = False