IMHO, it all depends on how complex your task is and how experienced you are in solving that particular task class. Even the most ardent proponents of TDD suggest that you do spikes (write some throwaway code) in order to see what design is applicable to your problem.
On the other hand, if your task is relatively straightforward, you can anticipate the required API and start with tests first.
On the other hand, if your task is relatively straightforward, you can anticipate the required API and start with tests first.