> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anonalabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python: anona

> anona.Sandbox, live view tokens and SSH certificates.

```text theme={null}
pip install anona              # or: pip install "anona[desktop]"
```

## `anona.configure`

```python Signature theme={null}
anona.configure(api_key=None, *, domain=None, api_url=None, debug=None) -> None
```

Sets the `E2B_*` variables of this process so the stock SDK, and the extras, talk to Anona. Missing values fall back to `ANONA_*` variables, then to `E2B_DOMAIN=compute.anonalabs.com`.

```python configure.py theme={null}
import os
import anona
from e2b import Sandbox  # the stock SDK picks up the configuration

anona.configure(api_key=os.environ["ANONA_API_KEY"])
with Sandbox.create() as sbx:
    print(sbx.commands.run("echo configured").stdout)
```

## `anona.Sandbox`

A subclass of `e2b.Sandbox`. Every E2B method works unchanged; `create`, `connect` and `list` default to the Anona domain. Two properties are added:

| Property | Type |
| - | - |
| `sandbox.live` | `anona.Live` |
| `sandbox.ssh` | `anona.Ssh` |

## `sandbox.live`

| Method | Returns | |
| - | - | - |
| `token(scope="view", channels=None, ttl=600)` | `ViewerToken` | `scope`: `"view"` or `"control"`. `channels`: any of `"dom"`, `"pty"`, `"desktop"`, `"thumb"` (default `["dom"]`). `ttl`: 30 to 600 seconds |
| `url(mode="dom", scope="view", ttl=600)` | `str` | Mints a token for one channel and returns its embed URL |
| `revoke_all()` | `None` | Closes every open viewer and invalidates issued tokens |

`ViewerToken` has `token`, `expires_at` (`datetime`), `embed_url`, and `claims()` (decodes the payload without verifying it). Its `repr` never shows the token.

```python live_tokens.py theme={null}
import os
from anona import Sandbox

sbx = Sandbox.connect(os.environ["SANDBOX_ID"])
tok = sbx.live.token(scope="control", channels=["pty"], ttl=120)
print(tok)                       # ViewerToken(expires_at=...)
print(tok.claims()["scp"], tok.claims()["sbx"] == sbx.sandbox_id)
print(sbx.live.url(mode="pty", scope="control").split("#")[0])
```

Invalid arguments raise `e2b.InvalidArgumentException` before any request. Gateway errors map to the E2B exceptions: 400 `InvalidArgumentException`, 401/403 `AuthenticationException`, 404 `NotFoundException`, 429 `RateLimitException`.

## `sandbox.ssh`

| Method | Returns | |
| - | - | - |
| `certificate(public_key)` | `SshCertificate` | `public_key`: an OpenSSH public key string, or the path of a `.pub` file (`ssh-ed25519`, `ecdsa-sha2-nistp256`, `ssh-rsa`). Refuses private keys |
| `config(identity_file="~/.ssh/anona_ed25519", certificate_file=None, alias=None, user="user", proxy_command="anona-compute ssh --proxy %h")` | `str` | An `ssh_config` block. Makes no request |

`SshCertificate` has `cert`, `user`, `host`, `proxy_command`, `expires_at`, and `write(path)` (writes with mode 0600). See [SSH](https://docs.anonalabs.com/compute/guides/ssh.md) for a full example.

## `anona.desktop.Sandbox`

A subclass of `e2b_desktop.Sandbox` (install `anona[desktop]`) with the same `live` and `ssh`, plus:

| Method | Returns | |
| - | - | - |
| `live_url(control=True, ttl=600)` | `str` | Embed URL of the desktop channel. Control scope by default, since the desktop channel carries input |

See [Desktop](https://docs.anonalabs.com/compute/guides/desktop.md).

## Constants

`anona.DEFAULT_DOMAIN` (`"compute.anonalabs.com"`), `anona.DEFAULT_API_URL`, `anona.ENV_MAP`, `anona.__version__`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.