@app.post("/user/{user_uuid}/models/secret/{name}/{model_uuid}/validate")
async def validate_secret_model(
user_uuid: UUID, name: str, model_uuid: UUID, model: dict[str, Any]
) -> dict[str, Any]:
type: str = "secret"
found_model = await DefaultDB.backend().find_model(model_uuid=model_uuid)
if "api_key" not in model:
model["api_key"] = found_model["json_str"]["api_key"]
try:
validated_model = Registry.get_default().validate(type, name, model)
return validated_model.model_dump()
except ValidationError as e:
raise HTTPException(status_code=422, detail=json.loads(e.json())) from e