OpenAI Assistants
Abstract
OpenAI Assistants are pre-built agents from OpenAI. You describe the assistant, connect tools and files, and OpenAI manages the memory, conversation streams, and task execution.
What Are They
The Assistants API is a managed service that handles the complex mechanics of an agent:
- storing conversation history;
- managing streams;
- calling tools;
- processing files;
- running code.
You don't assemble the agent from chains manually—you configure a pre-built one.
Key Concepts
| Object | What It Does |
|---|---|
| Assistant | The agent itself: instructions, model, tools |
| Thread | A separate conversation with history |
| Message | A user or assistant message |
| Run | An agent run to process a conversation |
Tools
Assistants support:
- Code Interpreter — writes and runs Python;
- File Search — searches uploaded files;
- Function Calling — calls your APIs.
How It Works
Create Assistant
↓
Create Thread
↓
Add Message
↓
Create Run
↓
Check Run status
↓
Get response
The code looks like this:
assistant = client.beta.assistants.create(
name="AI-Librarian",
instructions="Answer based on library files",
tools=[{"type": "file_search"}],
model="gpt-4o",
)
thread = client.beta.threads.create()
client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content="What is RAG?",
)
run = client.beta.threads.runs.create(
thread_id=thread.id,
assistant_id=assistant.id,
)
When to Use
- Need to quickly launch an agent without complex infrastructure.
- Need a Code Interpreter.
- Need to work with files.
- Already using OpenAI APIs.
When to Build Your Own
- Need full control over memory and tools.
- Need other models besides OpenAI.
- Need complex multi-agent logic.
- Data privacy is important.