The Managed Agents API is the agent runtime hosted by Model Studio: sessions, sandboxes, tool execution, and event streams are all managed by the platform.
Prerequisites
-
Activate Model Studio and create an API key: get one from the console, then Configure API key as an environment variable.
-
Get the workspace ID: open the dropdown in the upper-right corner of the Model Studio console. The ID looks like
ws_xxxxxxxxxxxx.
Endpoint
The API base URL is composed from the workspace and region:
https://{workspace_id}.{region}.maas.aliyuncs.com/api/v1/agentstudio
-
workspace_id: workspace ID, for examplews_xxxxxxxxxxxx -
region: region ID. Onlycn-beijingis supported.
Authentication
Every request carries the API key in an HTTP header. A single key grants access to all resources under its workspace.
Authorization: Bearer <your-api-key>
SDK
In addition to calling the REST API directly, you can integrate with the Python or Java SDK. The Managed Agents module requires Python SDK v1.26.2 or later, and Java SDK v2.22.24 or later. If you have an older version installed, run the install command again to upgrade.
pip install dashscope<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dashscope-sdk-java</artifactId>
</dependency>Requests and responses
-
Request bodies are JSON with
Content-Type: application/json. -
Every response carries an
x-request-idheader. Include this ID when filing tickets to speed up triage. -
List endpoints support pagination:
limit(default 20, max 100) andpage(omit on the first request; subsequent requests pass thenext_pagevalue returned by the previous response). When the response no longer containsnext_page, you have reached the last page.
Available APIs
|
Resource |
Endpoint |
Purpose |
|
|
Create an agent |
|
|
|
Get an agent |
|
|
|
List agents |
|
|
|
Update an agent (auto-increments the version) |
|
|
|
Archive an agent |
|
|
|
Create an environment |
|
|
|
Get an environment |
|
|
|
List environments |
|
|
|
Update an environment |
|
|
|
Delete an environment |
|
|
|
Archive an environment |
|
|
|
Create a session |
|
|
|
Get a session |
|
|
|
List sessions |
|
|
|
Update a session (for example, rename) |
|
|
|
Delete a session |
|
|
|
Archive a session |
|
|
|
Send an event (deliver a user message or tool receipt to the agent) |
|
|
|
List event history; subscribe to the SSE event stream (streaming output) |
|
|
|
Upload a file (multipart/form-data) |
|
|
|
Query file metadata |
|
|
|
List files |
|
|
|
Delete a file |
|
|
|
Create a skill |
|
|
|
Get a skill |
|
|
|
List skills |
|
|
|
Delete a skill |
|
|
|
Upload a new skill version |
|
|
|
Get a skill version |
|
|
|
List skill versions |
|
|
|
Download a skill package |