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

# ASG Sandbox

> Isolated code execution environment

# ASG Sandbox

Execute untrusted code safely in isolated environments.

## Overview

ASG Sandbox provides:

* **Python & JavaScript** — Popular languages
* **Full isolation** — Secure execution
* **Package support** — pip/npm packages
* **File access** — Read/write temporary files

## Quick Example

<CodeGroup>
  ```bash REST (recommended) theme={null}
  curl -X POST https://agent.asgcompute.com/v1/mcp/tools/call \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $ASG_API_KEY" \
    -d '{
      "tool": "sandbox_execute",
      "arguments": {
        "language": "python",
        "code": "import math\nprint(math.sqrt(144))"
      }
    }'
  ```

  ```bash JSON-RPC (MCP-native) theme={null}
  curl -X POST https://agent.asgcompute.com/mcp \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $ASG_API_KEY" \
    -d '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "tools/call",
      "params": {
        "name": "sandbox_execute",
        "arguments": {
          "language": "python",
          "code": "import math\nprint(math.sqrt(144))"
        }
      }
    }'
  ```

  ```typescript TypeScript theme={null}
  const result = await client.callTool('sandbox_execute', {
    language: 'python',
    code: `
  import math
  print(math.sqrt(144))
    `
  });

  console.log(result.stdout); // "12.0"
  ```
</CodeGroup>

## Parameters

| Parameter          | Type    | Required | Description                                         |
| :----------------- | :------ | :------- | :-------------------------------------------------- |
| `language`         | string  | Yes      | `python` or `javascript`                            |
| `code`             | string  | Yes      | Code to execute                                     |
| `timeout_ms`       | integer | No       | Max execution time in milliseconds (default: 30000) |
| `max_output_bytes` | integer | No       | Maximum output size in bytes                        |
| `packages`         | array   | No       | Packages to install                                 |

## Languages

| Language     | Version | Pre-installed                   |
| :----------- | :------ | :------------------------------ |
| `python`     | 3.11    | numpy, pandas, requests, pillow |
| `javascript` | Node 18 | axios, lodash, dayjs            |

## Response

```json theme={null}
{
  "result": {
    "stdout": "12.0\n",
    "stderr": "",
    "exit_code": 0,
    "duration_ms": 156,
    "_meta": {
      "receipt_id": "rcpt_sbox789",
      "debited_usdc_microusd": 2500
    }
  }
}
```

## Installing Packages

```typescript theme={null}
const result = await client.callTool('sandbox_execute', {
  language: 'python',
  packages: ['beautifulsoup4', 'lxml'],
  code: `
from bs4 import BeautifulSoup
html = "<h1>Hello</h1>"
soup = BeautifulSoup(html, 'lxml')
print(soup.h1.text)
  `
});
```

## Security

<Warning>
  **Isolation:** All sandbox executions run in isolated environments with:

  * No network access (except allowlisted domains)
  * No persistent storage
  * Memory and CPU limits
  * Automatic termination on timeout
</Warning>

## Use Cases

* **Code execution** — Run user-submitted code safely
* **Data analysis** — Process data with Python libraries
* **Prototyping** — Test code snippets quickly
* **Agent tools** — Give agents code execution capability

## Pricing

See [Pricing](/billing/pricing) for execution rates.
