Quick Start

Updated at:

Create an agent, configure its environment, initiate a session, and make calls—all in four steps via the console.

Prerequisites

  • You have activated Alibaba Cloud Bailian.
  • Your current account has Managed Agents operation permissions in the target workspace.

Step 1: Configure the Agent

Navigate to Bailian Console > Managed Agents > Quick Start, and fill in the agent's basic information, model, and tools. The page is pre-filled with template values—you may modify them as needed.

FieldDescription
NameDefault: Agent_v1; customizable
ModelRequired. Select from the dropdown list (e.g., qwen3.7-plus)
System PromptDefines the agent's role and behavior. A generic template is pre-filled; customize it per your use case
ToolsSeven built-in tools are selected by default: bash, read, write, edit, glob, grep, mark_artifacts. Deselect as needed
Skill / MCPOptional. Skip during Quick Start; add later on the agent detail page

You can also complete this step programmatically using the API—specify name, model, and tools (see Create Agent):

curl -X POST "https://{workspace_id}.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio/agents" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "data-analyst",
    "model": {"id": "qwen3-max"},
    "system": "You are a data analysis expert who uses pandas to process CSV files.",
    "tools": [
      {
        "type": "builtin_toolkit",
        "default_config": {"enabled": true},
        "configs": [
          {"name": "bash", "enabled": true},
          {"name": "read", "enabled": true},
          {"name": "write", "enabled": true}
        ]
      }
    ]
  }'
agent = client.agents.create(
    name="data-analyst",
    model="qwen3.8-max",
    system_prompt="You are a data analysis expert who uses pandas to process CSV files.",
    tools=[
        {"type": "builtin_toolkit",
         "default_config": {"enabled": True},
         "configs": [
             {"name": "bash", "enabled": True},
             {"name": "read", "enabled": True},
             {"name": "write", "enabled": True},
          ]}
    ],
)
print(agent.id)       # "agent_xxx"
print(agent.version)  # 1
Agent agent = client.agents().create(AgentCreateParam.builder()
    .name("data-analyst")
    .model("qwen3-max")
    .instructions("You are a data analysis expert who uses pandas to process CSV files.")
    .build());
System.out.println(agent.getId());       // "agent_xxx"
System.out.println(agent.getVersion());  // 1

After completing the form, click Finish & Next. The system creates and saves the agent, then proceeds to environment configuration.

Step 2: Configure the Runtime Environment

The environment defines the execution sandbox for tool calls and is managed independently from the agent.

FieldDescription
NameDefault: Agent_v1_Env; customizable
Hosting TypeDefault: Cloud-hosted (sandbox container managed by Bailian)

You can also complete this step programmatically using the API—specify sandbox type and pre-installed packages (see Create an environment):

curl -X POST "https://{workspace_id}.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio/environments" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "data-sandbox",
    "description": "Data analysis sandbox",
    "config": {
      "type": "cloud",
      "packages": {
        "apt": ["ffmpeg"],
        "pip": ["pandas", "numpy", "matplotlib"]
      },
      "networking": {"type": "unrestricted"}
    }
  }'
env = client.environments.create(
    name="data-sandbox",
    config={
        "type": "cloud",
        "networking": {"type": "unrestricted"},
        "packages": {
            "apt": ["ffmpeg"],
            "pip": ["pandas", "numpy", "matplotlib"],
        },
    },
    description="Data analysis sandbox",
)
Environment env = client.environments().create(EnvironmentCreateParam.builder()
    .name("data-sandbox")
    .description("Data analysis sandbox")
    .build());

Click Finish & Next. The system creates and saves the environment, then proceeds to session configuration.

Step 3: Confirm Session Configuration

The page displays summaries of the created agent and environment and automatically initiates a session based on both.

  • Verify the Agent card: name and model information.
  • Verify the Environment card: name and hosting type.
  • To use local files inside the sandbox, click Upload Files to mount them; otherwise, skip.

You can also complete this step programmatically using the API—bind the agent and environment (see Create Session):

curl -X POST "https://{workspace_id}.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio/sessions" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent": "agent_xxx",
    "environment_id": "env_xxx",
    "title": "Q3 Sales Data Analysis"
  }'
session = client.sessions.create(
    agent="agent_xxx",
    environment_id="env_xxx",
    title="Q3 Sales Data Analysis",
)
print(session.id, session.status)
Session session = client.sessions().create(SessionCreateParam.builder()
    .agentId("agent_xxx")
    .environmentId("env_xxx")
    .title("Q3 Sales Data Analysis")
    .build());
System.out.println(session.getId() + " " + session.getStatus());

Click Finish & Next. The system binds the agent and environment, creates and saves the session, then proceeds to the invocation page.

Step 4: Begin Invocation

Configuration is complete. The page provides two tabs:

  • Callable API: Displays the curl command to create an event—copy and run it directly in your terminal.
  • Preview & Debug: Chat directly with the agent in-browser and view real-time events and tool invocations. Use the dropdown in the top-left corner to filter by event type (User, Agent, Tool, Tool_output, Error, Model, System).

Send a message to trigger agent processing (see Send Event):

curl -X POST "https://{workspace_id}.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio/sessions/sesn_xxx/events" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": [
      {
        "role": "user",
        "type": "message",
        "content": [
          {"type": "text", "text": "Analyze Q3 sales trends in /mnt/session/uploads/sales.csv"}
        ]
      }
    ]
  }'
client.sessions.events.send(
    "sesn_xxx",
    events=[user_message("Analyze Q3 sales trends in /mnt/session/uploads/sales.csv")],
)
client.sessions().events().send("sesn_xxx",
    Collections.singletonList(
        ClientEvents.userMessage("Analyze Q3 sales trends in /mnt/session/uploads/sales.csv")));

Receive processing progress and output in real time via SSE event stream (see Subscribe to Event SSE Stream):

curl -N "https://{workspace_id}.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio/sessions/sesn_xxx/events/stream" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Accept: text/event-stream"
with client.sessions.events.stream("sesn_xxx", timeout=120.0) as stream:
    for event in stream:
        if event.type == "message":
            for block in (event.content or []):
                if getattr(block, "type", None) == "text":
                    print(block.text, end="", flush=True)
        elif event.type == "session_status":
            if event.session_status in ("idle", "terminated"):
                break
try (AgentStudioEventStream stream = client.sessions().events().stream("sesn_xxx", 120_000L)) {
    for (Message event : stream) {
        if ("message".equals(event.getType()) && event.getContent() != null) {
            for (ContentBlock block : event.getContent()) {
                if (block instanceof ContentBlock.Text)
                    System.out.print(((ContentBlock.Text) block).getText());
            }
        } else if ("session_status".equals(event.getType())) {
            break;
        }
    }
}

After debugging, click Return to Agent List to enter the management page. The agent, environment, and session created in the first three steps are all saved—you can view and edit them anytime from their respective menus.

Next Steps