[ ABORT TO HUD ]
SEQ. 1
SEQ. 2

Stateful Threads & Runs

🤖 The Assistants API 25 min 400 BASE XP

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

  1. Create an Assistant.
  2. Create a Thread when a user starts a conversation.
  3. Add a User Message to the Thread.
  4. Create a Run to let the Assistant process the Thread.
  5. Poll the Run status (or use streaming) until it completes.
  6. 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.
SYNAPSE VERIFICATION
QUERY 1 // 2
How does the Assistants API differ from the Chat Completions API regarding conversation history?
It doesn't support history
It is stateful and manages the conversation history in 'Threads' automatically
It requires you to store history in a SQL database
It only remembers the last prompt
Watch: 139x Rust Speedup
Stateful Threads & Runs | The Assistants API — OpenAI Academy