# Beam Sandboxes

Make the image and the API token that let Sandcovery run Beam sandboxes in your own Beam workspace.

Sandcovery runs each sandbox as a Beam sandbox in your Beam workspace, through the gateway HTTP API in [Beam's API reference](https://docs.beam.cloud/v2/reference/api). Sandcovery built this support from Beam's documentation alone, with no Beam account of its own, so your first sandbox on Beam is also the first run of this support against Beam itself.

## What runs

| Option                | Support                                     |
| --------------------- | ------------------------------------------- |
| Size                  | 1 to 30 vCPU                                |
| Egress                | `allow_all`                                 |
| Lifetime              | Until the sandbox's TTL                     |
| Pause and resume      | No                                          |
| Region                | `us`                                        |
| Environment variables | Set at create                               |
| Port previews         | Public URLs that anyone with the link opens |

Snapshots, a custom image per create, idle timeouts, disk sizes, GPUs, and output streamed while a command runs are not available on this provider. A streamed command answers its output when it ends. A create that asks for any of them, or for `deny_all` egress or an allowlist, routes to another provider. Sizes stop at 30 vCPU, the concurrent vCPU limit of Beam's Developer plan on [Beam's pricing page](https://www.beam.cloud/pricing).

## Make the image

Every sandbox starts from one Beam image that you name with the credential. Make it with Beam's SDK: start a sandbox from the image you want, install what your commands need, and save its filesystem as an image, as [Beam's snapshots page](https://docs.beam.cloud/v2/sandbox/snapshots) describes:

```python
from beam import Image, Sandbox

sandbox = Sandbox(image=Image(python_version="python3.11")).create()
sandbox.process.exec("sh", "-c", "pip install requests").wait()
print(sandbox.create_image_from_filesystem())
sandbox.terminate()
```

The printed value is the image ID. Sandcovery runs every command, listing, and cleanup through the image's `sh`, `timeout`, `mkdir`, GNU `find`, and `rm`, so keep them in it.

## Make the API token

Beam's API tokens carry no scopes, so a token manages everything in its workspace, and section 2.2 of Beam's [Terms of Service](https://docs.beam.cloud/v2/security/terms-and-conditions) makes you responsible for all activity under it. Use a workspace that holds only your Sandcovery sandboxes, and make an [API token](https://platform.beam.cloud/settings/api-keys) there. To find a sandbox whose create did not finish, Sandcovery runs a short `test` command in each running container of that workspace, which is another reason to keep other work out of it.

## Add the credential

Add the API token and the image ID as the Beam credential in **Provider Credentials** in the [dashboard](/app/credentials). Delete the token in Beam when you remove the credential.
