# Prerequisites and certification

<subtitle>Preparatory work that needs to be completed before starting to use SDK/CLI: obtain API Key and configure environment variables. </subtitle>

This page provides a unified explanation of the authentication configuration of UCloud Sandbox. This content will not be repeated in subsequent documents.

---

## Get API Key

Go to the key management page to get your API key:

> [Key Management](https://astraflow.ucloud.cn/modelverse/api-keys)

---

## Native SDK configuration

When using UCloud Sandbox native Python SDK, please configure the `UCLOUD_SANDBOX_API_KEY` environment variable:

```bash
export UCLOUD_SANDBOX_API_KEY=your_api_key
```

By default, the SDK will use the `cn-wlcb` region. If you want to use a different region, please configure the `UCLOUD_SANDBOX_REGION` environment variable:

```bash
export UCLOUD_SANDBOX_REGION=region
```

For information on region selection update, please refer to: [Switch Region](/docs/agent-sandbox/product/region.md).

After the configuration is complete, you can use the SDK:

```python
from ucloud_sandbox import Sandbox

sandbox = Sandbox.create(timeout=60)
print(sandbox.sandbox_id)
```

---

## E2B compatibility mode configuration

If you use the E2B SDK to access UCloud Sandbox in compatibility mode, please configure the following environment variables:

```bash
# Set the UCloud Sandbox domain name. Note that domain name prefixes are different in different regions. Please select according to your needs.
export E2B_DOMAIN=cn-wlcb.sandbox.ucloudai.com

#Set your API Key
export E2B_API_KEY=your_api_key

# Turn off API key verification in e2b format. This is necessary, otherwise E2B SDK will not recognize UCloud’s API Key.
export E2B_VALIDATE_API_KEY="false"
```

> **Note**: E2B compatibility mode and native SDK use **different environment variables**, please do not mix them.

After the configuration is complete, you can use the E2B SDK directly:

```python
from e2b_code_interpreter import Sandbox

sbx = Sandbox.create()
```

---

## CLI configuration

The CLI gives priority to reading the API Key in the environment variable, and also supports interactive login:

```bash
# Method 1: Environment variables (recommended)
export UCLOUD_SANDBOX_API_KEY=your_api_key

#Method 2: Interactive login
ucloud-sandbox-cli login
```
