This made me wonder if I need an API.
As an end user of VirtualBox, you don't need an API.
I want to use the graphics card while running my macOS Virtual
VirtualBox PCI Passthrough support, which is required for what you want to do, is very limited and comes with specific hardware requirements.
The PCI passthrough module is shipped as a VirtualBox extension
package, which must be installed separately. See Section 1.5,
“Installing VirtualBox and extension packs” for more information.
Essentially this feature allows to directly use physical PCI devices
on the host by the guest even if host doesn't have drivers for this
particular device. Both, regular PCI and some PCI Express cards, are
supported. AGP and certain PCI Express cards are not supported at the
moment if they rely on GART (Graphics Address Remapping Table) unit
programming for texture management as it does rather non-trivial
operations with pages remapping interfering with IOMMU. This
limitation may be lifted in future releases.
To be fully functional, PCI passthrough support in VirtualBox depends
upon an IOMMU hardware unit which is not yet too widely available. If
the device uses bus mastering (i.e. it performs DMA to the OS memory
on its own), then an IOMMU is required, otherwise such DMA
transactions may write to the wrong physical memory address as the
device DMA engine is programmed using a device-specific protocol to
perform memory transactions. The IOMMU functions as translation unit
mapping physical memory access requests from the device using
knowledge of the guest physical address to host physical addresses
Intel's solution for IOMMU is marketed as "Intel Virtualization
Technology for Directed I/O" (VT-d), and AMD's one is called AMD-Vi.
So please check if your motherboard datasheet has appropriate
technology. Even if your hardware doesn't have a IOMMU, certain PCI
cards may work (such as serial PCI adapters), but the guest will show
a warning on boot and the VM execution will terminate if the guest
driver will attempt to enable card bus mastering.
I do not want to give the control of the GPU to my VM, I just want to
use it in the same way that the Intel GPU is being used.
In order to accomplish what you want, you are going to have to give up control, that's just a matter of fact.