Skip to main content
Assistant API (Deprecated)

Assistants (Deprecated)

The assistant API simplifies building assistants, which are a type of Large Language Model (LLM) application. This topic describes the methods provided by the assistant API to manage assistants, such as creating, listing, retrieving, updating, and deleting them.

The Assistant API is being deprecated. Migrate to the Responses API as an alternative. The Responses API includes multiple built-in tools and supports multi-turn context management.
Features: For more information about the features and basic usage of the assistant API, see Assistant API overview.
Persistence: All assistant instances are saved on the Alibaba Cloud Model Studio server and do not have an expiration date. You can retrieve an assistant using its assistant.id.
Agent Application (Agent 1.0) and assistants are two types of LLM applications with different features and usage.
  • Agent applications: You can create, view, update, and delete agent applications only in the console. You can call them using the application calling API.
  • Assistants: You can create, view, update, delete, and call assistants only using the assistant API.

Create an agent

Creates a new assistant.
  • HTTP
  • SDK
Code example
curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/assistants' \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
    "model": "qwen-max",
    "name": "Intelligent assistant",
    "description": "This is an intelligent assistant",
    "instructions": "You are an intelligent assistant that can call different tools based on user query and then give responses. Please use tools when needed.",
    "tools": [
        {
            "type": "code_interpreter"
        }
    ],
    "metadata": {}
}'
Request parameters
Parameter nameDescriptionTypeRequired
modelThe model that the agent uses.strYes
nameThe name of the agent.strNo
descriptionThe description of the agent.strNo
instructionsThe system prompt for the LLM in the agent.strNo
toolsA list of tools that the agent can call.Passes authentication information for a custom plugin.
{
 "type": "${plugin_id}",
     "auth": {  # This field is used only for user-level authentication.
         "type": "user_http",
         "user_token": "bearer-token",
         }
 }
Optional[List[Dict]]No (default: [])
metadataOther parameters related to the agent. This parameter is used to store other related parameters.DictNo
temperatureControls the degree of randomness and diversity.floatNo
top_pThe probability threshold for the nucleus sampling method during generation.floatNo
top_kThe size of the candidate set for sampling during generation.integerNo
Response
{
    "id": "asst_49079f4b-d1e8-4015-a12e-2dcdd1f18d84",
    "object": "assistant",
    "created_at": 1711713885724,
    "model": "qwen-max",
    "name": "Intelligent Assistant",
    "description": "This is an intelligent assistant.",
    "instructions": "You are an intelligent assistant. You can call different tools based on user needs to provide answers. Use tools as needed.",
    "tools": [
        {
            "type": "code_interpreter"
        }
    ],
    "metadata": {},
    "temperature": null,
    "top_p": null,
    "top_k": null,
    "max_tokens": null,
    "request_id": "b1778226-3865-9006-9e95-56329a710322"
}
Response parametersAn assistant object.

List agents

Returns a list of assistants.
  • HTTP
  • SDK
Code example
curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/assistants?limit=2&order=desc' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
Request parameters

Input Parameter Name

Input parameter descriptions

Type

Required

limit

Number of agents

int

No

order

The sort order by creation time.

str

No (default: desc)

Response
{
    "object": "list",
    "data": [
        {
            "id": "asst_0678aa33-43e2-4268-95e6-b0010f9f7937",
            "object": "assistant",
            "created_at": 1711435564909,
            "model": "qwen-max",
            "name": "Intelligent Assistant",
            "description": "This is an intelligent assistant.",
            "instructions": "You are an intelligent assistant. You can call different tools based on user needs to provide answers. Use tools as needed.",
            "tools": [
                {
                    "type": "search"
                },
                {
                    "type": "text_to_image"
                },
                {
                    "type": "code_interpreter"
                }
            ],
            "metadata": {}
        },
        {
            "id": "asst_7af23142-52bc-4218-aa98-dfdb1128f19c",
            "object": "assistant",
            "created_at": 1711422620443,
            "model": "qwen-max",
            "name": "helpful assistant",
            "description": "",
            "instructions": "You are a helpful assistant.",
            "tools": [
                {
                    "type": "text_to_image"
                }
            ],
            "file_ids": [],
            "metadata": {}
        }
    ],
    "first_id": "asst_0678aa33-43e2-4268-95e6-b0010f9f7937",
    "last_id": "asst_7af23142-52bc-4218-aa98-dfdb1128f19c",
    "has_more": true,
    "request_id": "bc257359-ce86-9547-98be-d804effba8d1"
}
Response parametersA list of assistant objects.

Retrieval Agent

  • HTTP
  • SDK
Code example
curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/assistants/asst_0678aa33-43e2-4268-95e6-b0010f9f7937' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
Request parameters

Input parameter name

Input parameter descriptions

Type

Required

assistant_id

The ID of the agent to retrieve.

str

Yes

Response
{
    "id": "asst_0678aa33-43e2-4268-95e6-b0010f9f7937",
    "object": "assistant",
    "created_at": 1711435564909,
    "model": "qwen-max",
    "name": "Intelligent Assistant",
    "description": "This is an intelligent assistant.",
    "instructions": "You are an intelligent assistant. You can call different tools based on user needs to provide answers. Use tools as needed.",
    "tools": [
        {
            "type": "search"
        },
        {
            "type": "text_to_image"
        },
        {
            "type": "code_interpreter"
        }
    ],
    "metadata": {},
    "request_id": "f0ec05b0-8813-984c-81b5-1166ae3478d1"
}
Response parametersThe retrieved assistant object.

Update an agent

  • HTTP
  • SDK
Code example
curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/assistants/asst_0678aa33-43e2-4268-95e6-b0010f9f7937' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
    "instructions": "You are a search assistant",
    "name": "New Application-assistantAPI",
    "description": "",
    "model": "qwen-max"
}'
Request parameters

Input Parameter Name

Input parameter descriptions

Type

Required

assistant_id

The ID of the agent to retrieve

str

Yes

*

Other optional input parameters.

str

No

model

The ID of the model that the agent uses.

str

Yes

name

The name of the agent.

str

No

description

The description of the agent.

str

No

instructions

The system prompt for the LLM in the agent.

str

No

tools

A list of tools that the agent can call. The tools must be registered in Alibaba Cloud Model Studio.

Optional[List[Dict]]

No (default: [])

metadata

Stores other related parameters for the agent.

Dict

No

Response
{
    "id": "asst_0678aa33-43e2-4268-95e6-b0010f9f7937",
    "object": "assistant",
    "created_at": 1711435564909,
    "model": "qwen-max",
    "name": "New-Application-assistantAPI",
    "description": "",
    "instructions": "You are a search assistant.",
    "tools": [
        {
            "type": "search"
        },
        {
            "type": "text_to_image"
        },
        {
            "type": "code_interpreter"
        }
    ],
    "metadata": {},
    "request_id": "b0993831-a98b-9e71-b235-75174df9046e"
}
Response parametersThe updated assistant object.

Delete an agent

  • HTTP
  • SDK
Code example
curl --location --request DELETE 'https://dashscope-intl.aliyuncs.com/api/v1/assistants/asst_0678aa33-43e2-4268-95e6-b0010f9f7937' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
Request parameters

Input Parameter Name

Description

Type

Required

assistant_id

The ID of the agent to retrieve.

str

Yes

Response
{
    "id": "asst_0678aa33-43e2-4268-95e6-b0010f9f7937",
    "object": "assistant.deleted",
    "deleted": true,
    "request_id": "6af9320f-0430-9d01-b92f-d1beb6424dc5"
}
Response parametersOutputs the status of the deleted agent.

Agent object

An Assistant object that can call models and use tools. Agent Object Example
{
    "id": "asst_49079f4b-d1e8-4015-a12e-2dcdd1f18d84",
    "object": "assistant",
    "created_at": 1711713885724,
    "model": "qwen-max",
    "name": "Intelligent Assistant",
    "description": "This is an intelligent assistant.",
    "instructions": "You are an intelligent assistant. You can call different tools based on user needs to provide answers. Use tools as needed.",
    "tools": [
        {
            "type": "code_interpreter"
        }
    ],
    "metadata": {},
    "temperature": null,
    "top_p": null,
    "top_k": null,
    "max_tokens": null,
    "request_id": "b1778226-3865-9006-9e95-56329a710322"
}

Parameter name

Data type

Description

id

string

The unique identifier of the agent, which is the assistant ID.

object

string

The object type. This is always assistant.

created_at

integer

The 13-digit Unix timestamp, in milliseconds, when the agent was created.

model

string

The name of the model that the agent uses. You can view all available models in Assistant API overview or see Model list for more details.

name

string

The name of the agent.

description

string

The description of the agent.

instructions

string

The system instructions that the agent uses.

tools

array

A list of tools enabled on the agent. The tool can be an official plugin (such as `code_interpreter`, `quark_search`, or `text_to_image`), retrieval-augmented generation (RAG), or function calling.

metadata

dict

Additional information about the agent object stored in a structured format.

temperature

float

The sampling temperature, which is between 0 and 2. A higher value, such as 1, makes the output more random. A lower value, such as 0.2, makes the output more focused and deterministic.

top_p

float

An alternative to temperature sampling, called nucleus sampling. In this sampling method, the LLM selects the token results that have a cumulative probability mass of `top_p`. A value of 0.1 means that only the tokens that make up the top 10% of the probability mass are considered.

Adjust this parameter or temperature, but not both.

top_k

integer

Similar to `top_p`, but the sample is selected from the k tokens with the highest probability, regardless of their cumulative probability mass.

Do not adjust this parameter and temperature or top_p at the same time.

max_tokens

integer

The maximum number of tokens that the agent can generate at one time.

request_id

string

The unique identifier of the call associated with the agent.

Error codes

If a model call fails and returns an error message, see Error codes for troubleshooting information.