> For the complete documentation index, see [llms.txt](https://docs.aimlapi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aimlapi.com/solutions/openai/assistants/assistant-api.md).

# Assistant API

**Assistants** are AI-driven entities with assigned roles and instructions, allowing them to process messages, use tools, and maintain context within threads for structured and interactive responses.\
One Assistant can be used across multiple Threads and users.

This page provides API schemas for the following methods:

<table data-full-width="true"><thead><tr><th width="295.01666259765625"></th><th></th></tr></thead><tbody><tr><td><a href="#create-an-assistant">Create an Assistant</a></td><td><img src="/files/j1sGKuO2wS5fYyQZ5SGg" alt="" data-size="line"> <code>https://api.aimlapi.com/assistants</code></td></tr><tr><td><a href="#retrieve-a-list-of-assistants-along-with-their-parameters">Retrieve a list of Assistants along with their parameters</a></td><td><img src="/files/vAXd7V6xv3QmKrLeptB1" alt="" data-size="line"> <code>https://api.aimlapi.com/assistants</code></td></tr><tr><td><a href="#retrieve-information-about-a-specific-assistant-by-its-id">Retrieve information about a specific Assistant by its ID</a></td><td><img src="/files/vAXd7V6xv3QmKrLeptB1" alt="" data-size="line"> <code>https://api.aimlapi.com/assistants/{assistantId}</code></td></tr><tr><td><a href="#modify-a-specific-assistant-by-its-id">Modify a specific Assistant by its ID</a></td><td><img src="/files/j1sGKuO2wS5fYyQZ5SGg" alt="" data-size="line"> <code>https://api.aimlapi.com/assistants/{assistantId}</code></td></tr><tr><td><a href="#delete-a-specific-assistant-by-its-id">Delete a specific Assistant by its ID</a></td><td><img src="/files/ejZ6RTFbVq5OB7Ni1f3E" alt="" data-size="line"> <code>https://api.aimlapi.com/assistants/{assistantId}</code></td></tr></tbody></table>

After each API schema, you'll find a short example demonstrating how to correctly call the described method in code using the OpenAI SDK.

{% hint style="warning" %}
Note that the method names in the API schema and the SDK often differ.\
Accordingly, when calling these methods via the REST API, you should use the names from the API schema, while for calls through the OpenAI SDK, use the names from the examples.
{% endhint %}

## API Schemas

### Create an Assistant

Create an Assistant with a model and instructions.

#### Python + OpenAI SDK Example:

{% code overflow="wrap" %}

```python
from openai import OpenAI
client = OpenAI()

assistant = client.beta.assistants.create(
  name="Math Tutor",
  instructions="You are a personal math tutor. Write and run code to answer math questions.",
  tools=[{"type": "code_interpreter"}],
  model="gpt-4o",
)
```

{% endcode %}

***

### Retrieve a list of Assistants along with their parameters

#### Python + OpenAI SDK Example:

{% code overflow="wrap" %}

```python
from openai import OpenAI
client = OpenAI()

my_assistants = client.beta.assistants.list(
    order="desc",
    limit="20",
)
print(my_assistants.data)
```

{% endcode %}

***

### Retrieve information about a specific Assistant by its ID

#### Python + OpenAI SDK Example:

{% code overflow="wrap" %}

```python
from openai import OpenAI
client = OpenAI()

my_assistant = client.beta.assistants.retrieve("asst_abc123")
print(my_assistant)

```

{% endcode %}

***

### Modify a specific Assistant by its ID

#### Python + OpenAI SDK Example:

{% code overflow="wrap" %}

```python
from openai import OpenAI
client = OpenAI()

my_updated_assistant = client.beta.assistants.update(
  "asst_abc123",
  instructions="You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.",
  name="HR Helper",
  tools=[{"type": "file_search"}],
  model="gpt-4o"
)

print(my_updated_assistant)
```

{% endcode %}

***

### Delete a specific Assistant by its ID

#### Python + OpenAI SDK Example:

{% code overflow="wrap" %}

```python
from openai import OpenAI
client = OpenAI()

response = client.beta.assistants.delete("asst_abc123")
print(response)
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.aimlapi.com/solutions/openai/assistants/assistant-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
