# Prerequisites and Authentication

<subtitle>Preparation work required before using SDK/CLI: Get API Key and configure environment variables.</subtitle>

This page provides a unified explanation of UCloud Sandbox authentication configuration. Subsequent documentation will not repeat this content.

---

## Get API Key

Go to the console to get your API key:

>
> [Console API Keys page](https://console.ucloud.cn/modelverse/experience/api-keys)

---

## Native SDK Configuration

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

```bash
export AGENTBOX_API_KEY=your_api_key
```

After configuration, 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 UCloud Sandbox domain
export E2B_DOMAIN=sandbox.ucloudai.com

# Set your API Key
export E2B_API_KEY=your_api_key
```

>
> **Note**: E2B compatibility mode uses **different environment variables** from the native SDK. Do not mix them.

After configuration, you can directly use the E2B SDK:

```python
from e2b_code_interpreter import Sandbox

sbx = Sandbox.create()
```

---

## CLI Configuration

The CLI prioritizes reading the API Key from environment variables and also supports interactive login:

```bash
# Method 1: Environment variable (recommended)
export AGENTBOX_API_KEY=your_api_key

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

---

## Next Steps

- [SDK Quick Start](/docs/agent-sandbox/product/00-quick-start) - Create your first sandbox
- [CLI Guide](/docs/agent-sandbox/product/cli) - Command-line tool usage
- [E2B Compatibility Mode](/docs/agent-sandbox/product/e2b-compatibility) - Migrate existing E2B code
