An AI API is the door a program uses to send text to a model and get the answer back, without going through a chat screen. The app builds the request, authenticates itself with a secret key and pays for what it uses. That is how the AI buttons inside many apps work.
📱The app builds a request→🔑Authenticates with its key→🤖The model answers→💰Pays for what it uses
Put it to the test
A question from the app. Pick an answer.
A text API sends you the monthly bill. What does it usually measure?
Text APIs usually measure text, not time: what you sent and what it generated, counted in tokens. Others, like some voice APIs, bill by the minute.
Input is your message and the context sent with it; output is what the model writes. Each part is counted in tokens and has its own rate.
A short question and a very long one do not cost the same: the tokens in each are counted, not the questions.
Picture a recipe app. You type "I have rice, eggs and a tomato." The app does not pass just that to the model: it builds a request with its own instructions ("you are a cooking assistant, answer with a 3 step recipe"), adds your message and sends it through the API. A few seconds later it gets the text back, often in a data format like JSON, and shows it with its own design.
Each request is usually independent: the model does not remember the previous one. If the app wants it to follow a conversation, it sends the history again with each request, and all of that goes into the context window. Some APIs keep the conversation on the provider side; otherwise, the "memory" is built by the app.
The API key is like your card
To use an API you create a key in the provider's account: a long string of letters and numbers. With it the provider knows who is asking and who to bill. Anyone holding your key can use the API in your name, and the bill comes to you.
The most common mistake is leaving it where others can see it: pasted in the code of a web page or a mobile app (it can be extracted), or pushed to a public GitHub repository. The key belongs on your server, in an environment variable, and the app asks the server. If it leaks, delete it and create a new one; and if the provider allows it, set a monthly spending limit.
An API is not the chat app
A chat app like ChatGPT is a finished product: you open it, type and you are done. The API is a building block for your own. That is why it is billed differently: the chat is usually free or a flat fee, while the API is usually pay per use, based on the tokens you send and receive. Also, with many providers they are separate accounts: paying for the chat plan usually does not include API credit.
If you code from Latin America, keep in mind that many providers ask for a card that accepts international payments and work with credit loaded in advance. Loading a small amount at first and watching the usage dashboard is the cheapest way to learn what your app really spends.