When to call an API, when to use a framework, when to host your own model.
The default should be: call the smallest abstraction that gets the job done. Most "AI platforms" you're considering buying you don't need.
while loop. This covers 80% of real applications. Start here.