refactor headless example, support for 0.7 and both generic and generated APIs