Advice on Klipper and an external motor interaction

Here is my use case. After the print head has moved to a certain location, I want to run a motor connected to my rPi for a variable amount of time. After the motor has stop I want to then move the print head to another location. I’ve been going in circles on how to do to this two way interaction. Do I call the Klipper APIs directly or via Moonraker? Does my rPi need to be a MCU? Could I achieve what I want via macros? What is considered best practice for this type of interaction? Any help would be appreciated.