Lesson 1 of 5 · 2 min
A model call is just a request
Every AI app does the same thing underneath: your code sends text to a model over an API and does something with the reply. The model keeps nothing between calls. A chat is a list that you keep and send again each time.
messages = []
def pretend_model(history):
return f"I can see {len(history)} messages."
for text in ["hello", "what did I say first?", "and now?"]:
messages.append({"role": "user", "content": text})
reply = pretend_model(messages)
messages.append({"role": "assistant", "content": reply})
words = sum(len(m["content"].split()) for m in messages)
print(f"{reply:28} words resent next time: {words}")
The list only grows. That is why long chats become slower and cost more: you pay to send the whole history again.
