diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 0cd79aa5ab..322a7f72ad 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -1296,7 +1296,7 @@ async def get_models( models = get_filtered_models(models, user) log.debug( - f"/api/models returned filtered models accessible to the user: {json.dumps([model['id'] for model in models])}" + f"/api/models returned filtered models accessible to the user: {json.dumps([model.get('id') for model in models])}" ) return {"data": models} diff --git a/backend/open_webui/routers/openai.py b/backend/open_webui/routers/openai.py index 5b54796a70..e26ef24d0b 100644 --- a/backend/open_webui/routers/openai.py +++ b/backend/open_webui/routers/openai.py @@ -362,7 +362,9 @@ async def get_all_models_responses(request: Request, user: UserModel) -> list: response if isinstance(response, list) else response.get("data", []) ): if prefix_id: - model["id"] = f"{prefix_id}.{model['id']}" + model["id"] = ( + f"{prefix_id}.{model.get('id', model.get('name', ''))}" + ) if tags: model["tags"] = tags