---
title: Overview
description: Install the SDK and create your first sandbox
icon: "play"
---

The SDK embeds the microsandbox runtime directly into whatever application uses it. `Sandbox.builder(name).create()` spawns the VM as a child process. Sandbox names must be non-empty and no longer than 128 UTF-8 bytes. No daemon to install, no server to connect to.

## Installation

<CodeGroup>
```bash Rust
cargo add microsandbox
```

```bash TypeScript
npm install microsandbox
```

```bash Python
pip install microsandbox
```

```bash Go
go get github.com/superradcompany/microsandbox/sdk/go
```
</CodeGroup>

## Quick start

Create a sandbox from a container image, run a command, print the output, and stop it.

<CodeGroup>
```rust Rust
use microsandbox::{Sandbox, NetworkPolicy};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let sb = Sandbox::builder("my-sandbox")
        .image("python")
        .memory(512)
        .cpus(2)
        .env("PYTHONDONTWRITEBYTECODE", "1")
        .volume("/app/src", |v| v.bind("./src").readonly())
        .network(|n| n.policy(NetworkPolicy::public_only()))
        .create()
        .await?;

    let output = sb.exec("python", ["-c", "print('Hello, World!')"]).await?;
    println!("{}", output.stdout()?);

    sb.stop().await?;
    Ok(())
}
```

```typescript TypeScript
import { NetworkPolicy, Sandbox } from "microsandbox";

await using sb = await Sandbox.builder("my-sandbox")
    .image("python")
    .memory(512)
    .cpus(2)
    .env("PYTHONDONTWRITEBYTECODE", "1")
    .volume("/app/src", (m) => m.bind("./src").readonly())
    .network((n) => n.policy(NetworkPolicy.publicOnly()))
    .create();

const output = await sb.exec("python", ["-c", "print('Hello, World!')"]);
console.log("Output:", output.stdout());
```

```python Python
import asyncio
from microsandbox import Network, Sandbox, Volume

async def main():
    sb = await Sandbox.create(
        "my-sandbox",
        image="python",
        memory=512,
        cpus=2,
        env={"PYTHONDONTWRITEBYTECODE": "1"},
        volumes={
            "/app/src": Volume.bind("./src", readonly=True),
        },
        network=Network.public_only(),
    )

    output = await sb.exec("python", ["-c", "print('Hello, World!')"])
    print("Output:", output.stdout_text)

    await sb.stop()

asyncio.run(main())
```

```go Go
package main

import (
    "context"
    "fmt"
    "log"

    m "github.com/superradcompany/microsandbox/sdk/go"
)

func main() {
    ctx := context.Background()
    if err := m.EnsureInstalled(ctx); err != nil {
        log.Fatal(err)
    }

    sb, err := m.CreateSandbox(ctx, "my-sandbox",
        m.WithImage("python"),
        m.WithMemory(512),
        m.WithCPUs(2),
        m.WithEnv(map[string]string{"PYTHONDONTWRITEBYTECODE": "1"}),
        m.WithMounts(map[string]m.MountConfig{
            "/app/src": m.Mount.Bind("./src", m.MountOptions{Readonly: true}),
        }),
        m.WithNetwork(m.NetworkPolicy.PublicOnly()),
    )
    if err != nil {
        log.Fatal(err)
    }
    defer func() {
        _, _ = sb.StopAndWait(context.Background())
        _ = sb.Close()
    }()

    out, err := sb.Exec(ctx, "python", []string{"-c", "print('Hello, World!')"})
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println("Output:", out.Stdout())
}
```

</CodeGroup>

The SDK reference is split by language - choose [Rust SDK](/sdk/rust/sandbox), [TypeScript SDK](/sdk/typescript/sandbox), [Python SDK](/sdk/python/sandbox), or [Go SDK](/sdk/go/sandbox) for the full API. For low-level protocol integrations, see the Agent Client references for [Rust](/sdk/rust/agent-client), [TypeScript](/sdk/typescript/agent-client), [Python](/sdk/python/agent-client), and [Go](/sdk/go/agent-client). See also [error handling](/sdk/errors).
