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.
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 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
| Parameter name | Description | Type | Required |
|---|---|---|---|
| model | 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.Passes authentication information for a custom plugin. | Optional[List[Dict]] | No (default: []) |
| metadata | Other parameters related to the agent. This parameter is used to store other related parameters. | Dict | No |
| temperature | Controls the degree of randomness and diversity. | float | No |
| top_p | The probability threshold for the nucleus sampling method during generation. | float | No |
| top_k | The size of the candidate set for sampling during generation. | integer | No |
List agents
Returns a list of assistants.
- HTTP
- SDK
Input Parameter Name | Input parameter descriptions | Type | Required |
|---|---|---|---|
limit | Number of agents | int | No |
order | The sort order by creation time. | str | No (default: |
Retrieval Agent
- HTTP
- SDK
Input parameter name | Input parameter descriptions | Type | Required |
|---|---|---|---|
assistant_id | The ID of the agent to retrieve. | str | Yes |
Update an agent
- HTTP
- SDK
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 |
Delete an agent
- HTTP
- SDK
Input Parameter Name | Description | Type | Required |
assistant_id | The ID of the agent to retrieve. | str | Yes |
Agent object
An Assistant object that can call models and use tools.
Agent Object Example
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 |
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 |
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 |
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. |