You can use the system-get-version API. It returns an in-clustered element, set to true if running cDOT, or false/missing if running 7-mode.
Note that this element is not returned for systems running ONTAP 8.0.*, even clustered. If you have such systems, you'll likely need a workaround, like sending an API that is present in 8.0.* cDOT but not 7-mode and checking if it succeeds.