API design is mostly about designing the 1st. The 2nd is just a mechanical consequence of it.
The worst APIs I've seen originated from confused mental models. You can't create a simple language to specify how to do XYZ if you don't have a crystal clear understanding of XYZ.