Move api-specific code to the api package Upstream-commit: 28e4de8bfacc610bfa3a0e15cc633e406ea9e9f5 Component: engine