Turning G-sync on/off programatically

Is it possible to control G-sync behaviour via NVAPI or any other way?

NVidia Pendulum demo does it, so it must be possible.

I’d appreciate any help, thank you.