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/{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.

API Schemas

Create an Assistant

Create an Assistant with a model and instructions.

post
Authorizations
Body
modelstring · enumRequiredPossible values:
descriptionstring | nullableOptional

The description of the Assistant. The maximum length is 512 characters.

instructionsstring | nullableOptional

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.

namestring | nullableOptional

The name of the Assistant. The maximum length is 256 characters.

reasoning_effortstring · enum | nullableOptional

Constrains effort on reasoning for reasoning models.

Possible values:
response_formatany ofOptional

Specifies the format that the model must output.

string · enumOptionalPossible values:
or
one ofOptional
or
or
or
any | nullableOptional
temperaturenumber | nullableOptional

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.

top_pnumber | nullableOptional

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.

Responses
default
application/json
post
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
}
default
{
  "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

get
Authorizations
Query parameters
limitintegerOptional

A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

orderstringOptional

Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

beforestringOptional

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.

afterstringOptional

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.

Responses
default
application/json
get
GET /assistants HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer <YOUR_AIMLAPI_KEY>
Accept: */*
default
{
  "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
Authorizations
Path parameters
assistantIdstringRequired
Responses
default
application/json
get
GET /assistants/{assistantId} HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer <YOUR_AIMLAPI_KEY>
Accept: */*
default
{
  "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
Authorizations
Path parameters
assistantIdstringRequired
Body
all ofOptional
Responses
default
application/json
post
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
}
default
{
  "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
Authorizations
Path parameters
assistantIdstringRequired
Responses
default
application/json
delete
DELETE /assistants/{assistantId} HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer <YOUR_AIMLAPI_KEY>
Accept: */*
default
{
  "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?