Overview and authentication

更新时间:
复制 MD 格式

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

  1. Activate Model Studio and create an API key: get one from the console, then Configure API key as an environment variable.

  2. 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 example ws_xxxxxxxxxxxx

  • region: region ID. Only cn-beijing is 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-id header. Include this ID when filing tickets to speed up triage.

  • List endpoints support pagination: limit (default 20, max 100) and page (omit on the first request; subsequent requests pass the next_page value returned by the previous response). When the response no longer contains next_page, you have reached the last page.

Available APIs

Resource

Endpoint

Purpose

Agent

POST /agents

Create an agent

GET /agents/{agent_id}

Get an agent

GET /agents

List agents

PATCH /agents/{agent_id}

Update an agent (auto-increments the version)

POST /agents/{agent_id}/archive

Archive an agent

Environment

POST /environments

Create an environment

GET /environments/{environment_id}

Get an environment

GET /environments

List environments

PATCH /environments/{environment_id}

Update an environment

DELETE /environments/{environment_id}

Delete an environment

POST /environments/{environment_id}/archive

Archive an environment

Session and Event

POST /sessions

Create a session

GET /sessions/{session_id}

Get a session

GET /sessions

List sessions

PATCH /sessions/{session_id}

Update a session (for example, rename)

DELETE /sessions/{session_id}

Delete a session

POST /sessions/{session_id}/archive

Archive a session

POST /sessions/{session_id}/events

Send an event (deliver a user message or tool receipt to the agent)

GET /sessions/{session_id}/events

List event history; subscribe to the SSE event stream (streaming output)

File

POST /files

Upload a file (multipart/form-data)

GET /files/{file_id}

Query file metadata

GET /files

List files

DELETE /files/{file_id}

Delete a file

Skill

POST /skills

Create a skill

GET /skills/{skill_id}

Get a skill

GET /skills

List skills

DELETE /skills/{skill_id}

Delete a skill

POST /skills/{skill_id}/versions

Upload a new skill version

GET /skills/{skill_id}/versions/{version}

Get a skill version

GET /skills/{skill_id}/versions

List skill versions

GET /skills/{skill_id}/versions/{version}/download

Download a skill package