Complete service authorization, create a template, generate an API Key, and make your first call via the console—launching your first sandbox within minutes.
Prerequisites
- You have activated Alibaba Cloud Bailian.
- Your current account has Sandbox operation permissions.
Step 1: Complete Service Authorization
When using Sandbox for the first time, complete the Service Linked Role (SLR) authorization so that Bailian can create and manage the sandbox runtime environment.
Navigate to Bailian Console > Sandbox. The "Alibaba Cloud Service Authorization" dialog appears the first time you create a template:
| Field | Value |
|---|---|
| Role name | AliyunServiceRoleForSFMSandbox |
| Role permission policy | AliyunServiceRolePolicyForSFMSandbox |
| Permission description | Allows Bailian to access sandbox compute and network resources to create, run, and release sandbox instances |
Step 2: Create a Template
A template defines the sandbox runtime environment. Go to Sandbox > My Templates, click Create Template, and configure the following fields:
| Field | Description |
|---|---|
| Image | Choose one of three: code-interpreter-v1 (code execution), browser (browser operations), all-in-one (combined capabilities) |
| Template name | Required, customizable |
| Resource specification | Required. Spec 1 (1 Core / 2 GB, recommended) or Spec 2 (4 Core / 8 GB) |
templateCode for later calls.
In lifecycle control, choose either idle timeout or maximum lifetime, up to 7 days.
Step 3: Get an API Key
Calls to the sandbox are authenticated with a Bailian API Key. Click API-KEY at the bottom left of the Sandbox page to create or copy an API Key (format sk-...).
Step 4: Make Your First Call
Sandbox is compatible with the E2B SDK. After installing the SDK, create an instance and execute code using the Bailian sandbox endpoint and API Key.
Install the SDK:
api_key is a required parameter of the E2B SDK. It only needs to match the format e2b_ followed by hexadecimal characters; e2b_${ALIYUN_UID} is recommended. Bailian's real authentication uses Authorization: Bearer <Bailian API Key> and does not use api_key.