How it works
Last updated
Last updated
The Assistants API is designed to help developers build powerful AI assistants capable of performing a variety of tasks.
Assistants can call OpenAIβs models with specific instructions to tune their personality and capabilities. They can access multiple tools in parallel, which can be OpenAI-hosted tools like code_interpreter and file_search, or custom tools you build and host via function calling. Assistants can also access persistent threads to store message history and manage context length. Furthermore, they can handle files in various formats for tasks that require file manipulation.
Assistant: A purpose-built AI that uses OpenAIβs models and calls tools.
Thread: Represents a conversation session between an Assistant and a user, storing messages and handling truncation.
Message: A message created by an Assistant or a user, which can include text, images, and other files.
Run: An invocation of an Assistant on a Thread, where the Assistant uses its configuration and the Threadβs messages to perform tasks.
Run Step: A detailed list of steps taken by the Assistant during a Run, which includes calling tools and creating messages.
The API automatically manages truncation to stay within the model's maximum context length. You can customize this by specifying max_prompt_tokens
and max_completion_tokens
.
Run objects can have multiple statuses:
RunStatus.Queued: The run is waiting to start.
RunStatus.InProgress: The run is currently executing.
RunStatus.Completed: The run successfully completed.
RunStatus.RequiresAction: The run requires additional information.
RunStatus.Expired: The run expired due to time constraints.
RunStatus.Cancelling: The run is being cancelled.
RunStatus.Cancelled: The run was successfully cancelled.
RunStatus.Failed: The run failed due to an error.
RunStatus.Incomplete: The run ended due to token limits being reached.
Assistants, Threads, Messages, and Vector Stores created via the API are scoped to the Project they are created in. Implement authorization and restrict API key access to ensure data security.
Now you have explored how Assistants work, the next step is to explore Assistant Tools, covering topics like Function calling, File Search, and Code Interpreter.