The basics
An API (application programming interface) is a set of rules that lets one program ask another for data or actions, such as sending a question to an AI model.
Programs need to talk to each other. An API is the agreed menu for that conversation: here is what you can ask for, here is how to ask, and here is what you get back. A weather app does not run its own satellites; it calls a weather service's API and receives the forecast.
AI models are mostly used through APIs. A developer's app sends the user's text over the internet to the model provider, along with settings like temperature, and gets the generated reply back. This means a small app can use a huge model without owning any of the hardware.
Using an API usually costs money per use, often priced by the number of tokens sent and received. It also means your data travels to another company's servers, which matters for privacy. Open-weights models are the alternative when you want to run the model yourself.
When a language-learning app sends your sentence to a model to check the grammar and shows the correction, it is calling the model provider's API behind the scenes.