Is there an API or source code available for nvpmodel?

Not an API, but you may have a look to :

cat /etc/nvpmodel.conf
ls /etc/nvpmodel/*

I want to set power mode by C code.
Is there any elegant way or should I use system() function?

Probably system() would be the easiest way, but you may use sysfs if you prefer, using paths as from /etc/nvpmodel.conf.