mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-15 04:19:08 +00:00
Resolve watsonx model_id body key for virtual-key scope checks (fixes #41467)
Add the /watsonx branch to get_model_from_request reading the native model_id body key, so the models[] allowlist check runs on the watsonx pass-through route instead of being skipped when resolution returns None.
This commit is contained in:
parent
78848d01a3
commit
6f1bffddb7
1 changed files with 10 additions and 0 deletions
|
|
@ -2036,6 +2036,16 @@ def get_model_from_request(
|
|||
if vertex_match:
|
||||
model = vertex_match.group(1)
|
||||
|
||||
# If still not found, read the Watsonx body key. Watsonx generation and
|
||||
# chat requests carry the model under "model_id" (the native Watsonx ML
|
||||
# API shape, and the key litellm's own Watsonx client writes), so without
|
||||
# this branch the model resolves to None and the key's model allowlist is
|
||||
# never checked on /watsonx routes.
|
||||
if model is None and route.lower().startswith("/watsonx"):
|
||||
watsonx_model: Final = request_data.get("model_id")
|
||||
if isinstance(watsonx_model, str) and watsonx_model:
|
||||
model = watsonx_model
|
||||
|
||||
if route.lower().startswith("/bedrock"):
|
||||
bedrock_model: Final = _model_from_bedrock_route(route)
|
||||
return model if bedrock_model is None else bedrock_model
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue