Metadata-Version: 2.5
Name: azatai
Version: 0.0.1
Summary: Python client for AzatAI Sandbox
Project-URL: Homepage, https://azat.ai/products/sandbox
Author: Azat
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.11
Requires-Dist: e2b<2.67,>=2.66.0
Description-Content-Type: text/markdown

# azatai

The Python client for [AzatAI Sandbox](https://azat.ai/products/sandbox). A sandbox is an
isolated microVM with its own kernel. You start it, run commands in it, read and write its
files, and delete it from code.

## Install

```sh
pip install azatai
```

The package needs Python 3.11 or later.

## Use

```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()`.

For asyncio code, use `AsyncSandbox`:

```python
from azatai import AsyncSandbox

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

`Sandbox.create("my-template")` starts a sandbox from a template. Use `Template` and
`AsyncTemplate` to build templates.

## Configure

The client reads its settings from these environment variables. A keyword argument with the
same role, for example `Sandbox.create(api_key=...)`, overrides the variable.

| Variable | Argument | Role |
|---|---|---|
| `AZATAI_API_KEY` | `api_key` | Your API key |
| `AZATAI_SANDBOX_DOMAIN` | `domain` | The sandbox domain. The API is at `https://api.<domain>` and the sandboxes at `https://<domain>` |
| `AZATAI_SANDBOX_API_URL` | `api_url` | The API address, if it is not `https://api.<domain>` |
| `AZATAI_SANDBOX_URL` | `sandbox_url` | The sandbox proxy address, if it is not `https://<domain>` |

Set `AZATAI_API_KEY`. Then set `AZATAI_SANDBOX_DOMAIN`, or set both `AZATAI_SANDBOX_API_URL`
and `AZATAI_SANDBOX_URL`. If a setting is missing, the client raises `azatai.ConfigError`.

## Develop

```sh
uv sync
uv run pytest
```

The tests marked `live` call a real sandbox API. They run only when `AZATAI_API_KEY` is set:

```sh
AZATAI_API_KEY=... AZATAI_SANDBOX_API_URL=... AZATAI_SANDBOX_URL=... uv run pytest -m live
```

## Release

CI publishes the package to PyPI through trusted publishing. Set the new `version` in
`pyproject.toml`, merge the change, and push a tag `python-v<version>` on that commit:

```sh
git tag python-v0.0.1 && git push origin python-v0.0.1
```
