Moving Beyond Chat Completions
The Chat Completions API is stateless—you must send the entire conversation history with every request. The Assistants API introduces stateful infrastructure.
Core Concepts
- Assistant: An AI entity with custom instructions, a model choice, and enabled tools.
- Thread: A persistent conversation session. You add Messages to a Thread.
- Message: Text or files added to a Thread by a user or an Assistant.
- Run: The execution of an Assistant on a Thread. This is an asynchronous process.
The Workflow
- Create an Assistant.
- Create a Thread when a user starts a conversation.
- Add a User Message to the Thread.
- Create a Run to let the Assistant process the Thread.
- Poll the Run status (or use streaming) until it completes.
- Retrieve the Assistant's new Messages from the Thread.
Why use it? The Assistants API handles context window management automatically. If the conversation gets too long, it truncates older messages seamlessly to fit the model's limits.