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

# Quickstart: Give an Agent a Computer

> Create a sandbox, run code, serve a URL, and fork it from a snapshot

A sandbox is a computer for your agent: a machine in the cloud it drives from code. In about five minutes you'll create one, run code in it, serve a URL, fork it from a memory snapshot, and attach a GPU.

<Tip>
  Using Cursor, Claude Code, or Codex? Run `beam setup agent` to connect your coding agent to your workspace. See [agent setup](/v2/getting-started/add-to-cursor-claude).
</Tip>

## Install and Sign In

```bash theme={null}
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade beam-client
beam login
```

Finish signing in through your browser, then run `beam whoami` to check your workspace.

## Run Code, Serve a URL, and Fork

Save this as `sandbox.py` and run `python sandbox.py`:

```python sandbox.py theme={null}
from beam import Sandbox

# Create a sandbox and run code
sb = Sandbox(cpu=1, memory="1Gi", keep_warm_seconds=600).create()
print(sb.process.run_code("print(sum(range(10)))").stdout)  # 45

# Start a web server and get a URL
sb.fs.write_text("/workspace/index.html", "Hello from a Beam sandbox")
sb.process.exec(
    "python3", "-m", "http.server", "8000", "--bind", "0.0.0.0",
    cwd="/workspace",
)
print(sb.expose_port(8000))

# Snapshot memory, including the running server, then fork it
snapshot_id = sb.snapshot_memory()
sb.terminate()

forks = [Sandbox().create_from_memory_snapshot(snapshot_id) for _ in range(3)]
for fork in forks:
    print(fork.list_urls())  # each fork serves its own copy
    fork.terminate()
```

<Warning>
  Preview URLs are public. Add authentication in your app before serving anything sensitive.
</Warning>

## Add a GPU

Attach a GPU with one argument:

```python theme={null}
from beam import Sandbox

sb = Sandbox(gpu="RTX4090", memory="8Gi").create()
p = sb.process.exec("nvidia-smi")
p.wait()
print(p.logs.read())
sb.terminate()
```

Requesting a GPU doesn't install CUDA libraries. Add packages such as `torch` to the sandbox [image](/v2/environment/custom-images).

## Control Outbound Traffic

Each sandbox is isolated from your app and other workloads. To control what an agent's computer can reach, block outbound traffic or allow only specific CIDR ranges:

```python theme={null}
from beam import Sandbox

sb = Sandbox(block_network=True).create()                        # no outbound traffic
sb.update_network_permissions(block_network=False, allow_list=[])  # reopen it at runtime
sb.terminate()

sb = Sandbox(allow_list=["10.0.0.0/8"]).create()                 # or allow only these ranges
sb.terminate()
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Run Your First App" icon="rocket" href="/v2/getting-started/quickstart">
    Run a function and deploy a web endpoint.
  </Card>

  <Card title="Snapshots" icon="camera" href="/v2/sandbox/snapshots">
    Save filesystem or memory state and fork it.
  </Card>

  <Card title="Networking" icon="globe" href="/v2/sandbox/networking">
    Preview URLs and outbound rules.
  </Card>

  <Card title="TypeScript SDK" icon="code" href="/v2/reference/ts-sdk">
    Create and operate sandboxes from Node.js.
  </Card>
</CardGroup>


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