---
title: "AzatAI Sandbox: Get started | AzatAI"
description: "Start a sandbox from Python, run a command in it, and read and write its files."
url: "https://azat.ai/docs/sandbox"
language: "en"
image: "https://azat.ai/og/en.png"
---

[All docs](https://azat.ai/docs)

AzatAI Sandbox

- [Get started](https://azat.ai/docs/sandbox)
- [Configuration](https://azat.ai/docs/sandbox/configuration)

[Product page](https://azat.ai/products/sandbox)

AzatAI Sandbox

# Get started

Start a sandbox from Python, run a command in it, and read and write its files.

A sandbox is a virtual machine of its own, with its own kernel. It starts in under a second. You create it, run commands in it, read and write its files, and delete it from code.

## Before you start

You need:

- Python 3.11 or later
- [uv](https://docs.astral.sh/uv/), to add the client to your project
- An AzatAI API key and a sandbox domain. To get them, [talk to us](https://azat.ai/contact).

## Install the client

```sh
uv add azatai
```

## Set your key

The client reads its settings from environment variables:

```sh
export AZATAI_API_KEY="your-api-key"
export AZATAI_SANDBOX_DOMAIN="your-sandbox-domain"
```

[Configuration](https://azat.ai/docs/sandbox/configuration) lists all the settings.

## Start a sandbox

```python
from azatai import Sandbox

with Sandbox.create() as sbx:
    run = sbx.commands.run("python3 --version")
    print(run.stdout)
    sbx.files.write("/home/user/hello.txt", "hello")
    print(sbx.files.read("/home/user/hello.txt"))
```

The sandbox stops when the `with` block ends. Without a `with` block, call `sbx.kill()`.

## Use asyncio

For asyncio code, use `AsyncSandbox`:

```python
from azatai import AsyncSandbox

sbx = await AsyncSandbox.create()
run = await sbx.commands.run("uname -a")
await sbx.kill()
```

## Start from a template

`Sandbox.create("my-template")` starts a sandbox from a template. A template holds the packages and files that your sandboxes need, so each sandbox starts ready. Use `Template` and `AsyncTemplate` to build templates.

## Limits

| Limit      | Value                      |
| ---------- | -------------------------- |
| Start time | Under 1 second             |
| CPU        | Up to 32 vCPU              |
| Memory     | Up to 128 GiB              |
| Run time   | Up to 24 hours for one run |
```json
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"AzatAI","item":"https://azat.ai"},{"@type":"ListItem","position":2,"name":"Get started","item":"https://azat.ai/docs/sandbox"}]}
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://azat.ai/#organization","name":"AzatAI","url":"https://azat.ai/","logo":{"@type":"ImageObject","url":"https://azat.ai/icon-512.png","width":512,"height":512},"description":"AzatAI is an AI company. AzatAI Stack, our trust layer for AI products, gives them sign-in for people and AI agents, data and encrypted file storage. Our own products and our client systems run on it.","slogan":"The trust layer for AI"},{"@type":"WebSite","@id":"https://azat.ai/#website","name":"AzatAI","url":"https://azat.ai","inLanguage":"en","publisher":{"@id":"https://azat.ai/#organization"}}]}
```
