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:
https://api.aimlapi.com/assistants
https://api.aimlapi.com/assistants
https://api.aimlapi.com/assistants/{assistantId}
https://api.aimlapi.com/assistants/{assistantId}
https://api.aimlapi.com/assistants/{assistantId}
After each API schema, you'll find a short example demonstrating how to correctly call the described method in code using the OpenAI SDK.
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.
API Schemas
Create an Assistant
Create an Assistant with a model and instructions.
The description of the Assistant. The maximum length is 512 characters.
The system instructions that the Assistant uses. The maximum length is 256,000 characters. Instructions can indeed be very large and complex, including full action frameworks, example messages, response formatting guidelines, topic restrictions, and stylistic rules.
The name of the Assistant. The maximum length is 256 characters.
Constrains effort on reasoning for reasoning models.
Specifies the format that the model must output.
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or temperature but not both.
POST /assistants HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer <YOUR_AIMLAPI_KEY>
Content-Type: application/json
Accept: */*
Content-Length: 462
{
"model": "openai/gpt-4o",
"description": "text",
"instructions": "text",
"metadata": {
"ANY_ADDITIONAL_PROPERTY": "text"
},
"name": "text",
"reasoning_effort": "low",
"response_format": "auto",
"temperature": 1,
"tool_resources": {
"code_interpreter": {
"file_ids": []
},
"file_search": {
"vector_store_ids": [
"text"
],
"vector_stores": [
{
"chunking_strategy": {
"type": "auto"
},
"file_ids": [
"text"
],
"metadata": {
"ANY_ADDITIONAL_PROPERTY": "text"
}
}
]
}
},
"tools": [
{
"type": "code_interpreter"
}
],
"top_p": 1
}
{
"model": "text",
"description": "text",
"instructions": "text",
"metadata": null,
"name": "text",
"reasoning_effort": "low",
"response_format": "auto",
"temperature": 1,
"tool_resources": {
"code_interpreter": {
"file_ids": []
},
"file_search": {
"vector_store_ids": [
"text"
],
"vector_stores": [
{
"chunking_strategy": {
"type": "auto"
},
"file_ids": [
"text"
],
"metadata": {
"ANY_ADDITIONAL_PROPERTY": "text"
}
}
]
}
},
"tools": [
{
"type": "code_interpreter"
}
],
"top_p": 1,
"id": "text",
"created_at": 1,
"object": "assistant"
}
Python + OpenAI SDK Example:
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",
)
Retrieve a list of Assistants along with their parameters
A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
GET /assistants HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer <YOUR_AIMLAPI_KEY>
Accept: */*
{
"object": "list",
"data": [
{
"model": "text",
"description": "text",
"instructions": "text",
"metadata": null,
"name": "text",
"id": "text",
"created_at": 1,
"object": "assistant"
}
]
}
Python + OpenAI SDK Example:
from openai import OpenAI
client = OpenAI()
my_assistants = client.beta.assistants.list(
order="desc",
limit="20",
)
print(my_assistants.data)
Retrieve information about a specific Assistant by its ID
GET /assistants/{assistantId} HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer <YOUR_AIMLAPI_KEY>
Accept: */*
{
"model": "text",
"description": "text",
"instructions": "text",
"metadata": null,
"name": "text",
"reasoning_effort": "low",
"response_format": "auto",
"temperature": 1,
"tool_resources": {
"code_interpreter": {
"file_ids": []
},
"file_search": {
"vector_store_ids": [
"text"
],
"vector_stores": [
{
"chunking_strategy": {
"type": "auto"
},
"file_ids": [
"text"
],
"metadata": {
"ANY_ADDITIONAL_PROPERTY": "text"
}
}
]
}
},
"tools": [
{
"type": "code_interpreter"
}
],
"top_p": 1,
"id": "text",
"created_at": 1,
"object": "assistant"
}
Python + OpenAI SDK Example:
from openai import OpenAI
client = OpenAI()
my_assistant = client.beta.assistants.retrieve("asst_abc123")
print(my_assistant)
Modify a specific Assistant by its ID
POST /assistants/{assistantId} HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer <YOUR_AIMLAPI_KEY>
Content-Type: application/json
Accept: */*
Content-Length: 462
{
"model": "openai/gpt-4o",
"description": "text",
"instructions": "text",
"metadata": {
"ANY_ADDITIONAL_PROPERTY": "text"
},
"name": "text",
"reasoning_effort": "low",
"response_format": "auto",
"temperature": 1,
"tool_resources": {
"code_interpreter": {
"file_ids": []
},
"file_search": {
"vector_store_ids": [
"text"
],
"vector_stores": [
{
"chunking_strategy": {
"type": "auto"
},
"file_ids": [
"text"
],
"metadata": {
"ANY_ADDITIONAL_PROPERTY": "text"
}
}
]
}
},
"tools": [
{
"type": "code_interpreter"
}
],
"top_p": 1
}
{
"model": "text",
"description": "text",
"instructions": "text",
"metadata": null,
"name": "text",
"reasoning_effort": "low",
"response_format": "auto",
"temperature": 1,
"tool_resources": {
"code_interpreter": {
"file_ids": []
},
"file_search": {
"vector_store_ids": [
"text"
],
"vector_stores": [
{
"chunking_strategy": {
"type": "auto"
},
"file_ids": [
"text"
],
"metadata": {
"ANY_ADDITIONAL_PROPERTY": "text"
}
}
]
}
},
"tools": [
{
"type": "code_interpreter"
}
],
"top_p": 1,
"id": "text",
"created_at": 1,
"object": "assistant"
}
Python + OpenAI SDK Example:
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)
Delete a specific Assistant by its ID
DELETE /assistants/{assistantId} HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer <YOUR_AIMLAPI_KEY>
Accept: */*
{
"id": "text",
"object": "assistant.deleted",
"deleted": true
}
Python + OpenAI SDK Example:
from openai import OpenAI
client = OpenAI()
response = client.beta.assistants.delete("asst_abc123")
print(response)
Last updated
Was this helpful?