Both, the API response includes a breakdown. In the best case 1 token = 1 word (for example "and", "the", etc). Depending on input, for English it seems reasonable to multiply the word count by about 1.3 to get a rough token count
This pricing model seems fair since you can pass in huge prompts and request a single word reply, or a few words that expect a large reply