OpenSandbox README

The project's README from github.com/opensandbox-group/OpenSandbox. As one markdown file: README.md.

OpenSandbox logo

OpenSandbox

opensandbox-group%2FOpenSandbox | Trendshift

Stars OpenSSF Best Practices CNCF Landscape Discord DingTalk E2E Status Kubernetes nightly build status


OpenSandbox is a general-purpose sandbox platform for AI applications, offering multi-language SDKs, unified sandbox APIs, and Docker/Kubernetes runtimes for scenarios like Coding Agents, GUI Agents, Agent Evaluation, AI Code Execution, and RL Training.

Features

Official Container Images

OpenSandbox release images are published under the same component name in three official registries:

Tagged release images are signed keylessly with Cosign and include provenance attestations. Pin production images by digest and follow the release verification guide to verify the image against the OpenSandbox GitHub Actions identity before deployment.

SDKs

Python:

pip install opensandbox

Java/Kotlin (Gradle Kotlin DSL):

dependencies {
    implementation("com.alibaba.opensandbox:sandbox:{latest_version}")
}

Java/Kotlin (Maven):

<dependency>
    <groupId>com.alibaba.opensandbox</groupId>
    <artifactId>sandbox</artifactId>
    <version>{latest_version}</version>
</dependency>

JavaScript/TypeScript:

npm install @alibaba-group/opensandbox

C#/.NET:

dotnet add package Alibaba.OpenSandbox

Go:

go get github.com/alibaba/OpenSandbox/sdks/sandbox/go

CLI

OpenSandbox also provides osb, a terminal CLI for the common sandbox workflow: create sandboxes, run commands, move files, inspect diagnostics, and manage runtime egress policy.

Install:

pip install opensandbox-cli
# or
uv tool install opensandbox-cli

Quick start:

osb config init
osb config set connection.domain localhost:8080
osb config set connection.protocol http
osb config set connection.api_key <your-api-key>
osb sandbox create --image python:3.12 --timeout 30m -o json
osb command run <sandbox-id> -o raw -- python -c "print(1 + 1)"

See the CLI README for the full command reference.

MCP

The OpenSandbox MCP server exposes sandbox creation, command execution, and text file operations to MCP-capable clients such as Claude Code and Cursor.

Install and run:

pip install opensandbox-mcp
opensandbox-mcp --domain localhost:8080 --protocol http

Minimal stdio config:

{
  "mcpServers": {
    "opensandbox": {
      "command": "opensandbox-mcp",
      "args": ["--domain", "localhost:8080", "--protocol", "http"]
    }
  }
}

See the MCP README for client-specific setup.

Getting Started

Requirements:

Install and Configure the Sandbox Server

uvx opensandbox-server init-config ~/.sandbox.toml --example docker

uvx opensandbox-server

# Show help
# uvx opensandbox-server -h

Create a Code Interpreter and Execute Commands/Codes

Install the Code Interpreter SDK

uv pip install opensandbox-code-interpreter

Create a sandbox and execute commands and codes.

import asyncio
from datetime import timedelta

from code_interpreter import CodeInterpreter, SupportedLanguage
from opensandbox import Sandbox
from opensandbox.models import WriteEntry

async def main() -> None:
    # 1. Create a sandbox
    sandbox = await Sandbox.create(
        "opensandbox/code-interpreter:v1.1.0",
        entrypoint=["/opt/code-interpreter/code-interpreter.sh"],
        env={"PYTHON_VERSION": "3.11"},
        timeout=timedelta(minutes=10),
    )

    async with sandbox:

        # 2. Execute a shell command
        execution = await sandbox.commands.run("echo 'Hello OpenSandbox!'")
        print(execution.logs.stdout[0].text)

        # 3. Write a file
        await sandbox.files.write_files([
            WriteEntry(path="/tmp/hello.txt", data="Hello World", mode=644)
        ])

        # 4. Read a file
        content = await sandbox.files.read_file("/tmp/hello.txt")
        print(f"Content: {content}") # Content: Hello World

        # 5. Create a code interpreter
        interpreter = await CodeInterpreter.create(sandbox)

        # 6. Execute Python code (single-run, pass language directly)
        result = await interpreter.codes.run(
              """
                  import sys
                  print(sys.version)
                  result = 2 + 2
                  result
              """,
              language=SupportedLanguage.PYTHON,
        )

        print(result.result[0].text) # 4
        print(result.logs.stdout[0].text) # 3.11.14

        # 7. Cleanup the sandbox
        await sandbox.kill()

if __name__ == "__main__":
    asyncio.run(main())

More Examples

OpenSandbox provides examples covering SDK usage, agent integrations, browser automation, and training workloads. All example code is located in the examples/ directory.

🎯 Basic Examples

🤖 Coding Agent Integrations

🌐 Browser and Desktop Environments

🧠 Training and Evaluation

For more details, please refer to the examples documentation.

Project Structure

Directory Description
sdks/ Multi-language SDKs (Python, Java/Kotlin, TypeScript/JavaScript, C#/.NET)
specs/ OpenAPI specs and lifecycle specifications
server/ Python FastAPI sandbox lifecycle server
cli/ OpenSandbox command-line interface
kubernetes/ Kubernetes deployment and examples
components/execd/ Sandbox execution daemon (commands and file operations)
components/ingress/ Sandbox traffic ingress proxy
components/egress/ Sandbox network egress control
examples/ Runnable example code
docs/examples/ Example documentation and use cases
oseps/ OpenSandbox Enhancement Proposals
docs/ Architecture and design documentation
tests/ Cross-component E2E tests
scripts/ Development and maintenance scripts

For detailed architecture, see Architecture.

Documentation

License

This project is open source under the Apache 2.0 License.

Roadmap

See ROADMAP.md for the current project roadmap, planning scope, and how roadmap items are managed.

Contact and Discussion

Star History

Star History Chart

OpenSandbox (opensandbox-group/OpenSandbox)

Searching Database…

这是什么?OpenSandbox 是一个面向 AI 应用的通用沙箱平台,提供多语言 SDK、统一的沙箱 API,以及 Docker/Kubernetes 运行时,适用于编程智能体、GUI 智能体、智能体评测、AI 代码执行和强化学习训练等场景。
这是我可以导入的库,还是我需要运行的服务器?两者都是:一个基于 Python FastAPI 的沙箱生命周期服务器,你可以用 Docker 在本地部署,也可以在 Kubernetes 上大规模部署;另外还有 Python、Java/Kotlin、JS/TS、C#/.NET 和 Go 的 SDK、一个 'osb' 命令行工具,以及一个 MCP 服务器,它们都与该服务器通信。
我该如何让沙箱跑起来?安装 Docker 和 Python 3.10+,启动 OpenSandbox 服务器,然后使用 Code Interpreter SDK 创建沙箱并执行命令或代码;同样的流程也可以扩展到 Kubernetes 运行时,以实现分布式调度。
试用它需要 Kubernetes 吗?不需要,仅靠 Docker 就能在本地运行沙箱。只有高性能、大规模的分布式运行时才需要 Kubernetes。
沙箱与宿主机之间的隔离程度如何?在标准 Docker/Kubernetes 容器之上,OpenSandbox 还支持 gVisor、Kata Containers 和 Firecracker microVM 等安全运行时,以便在沙箱工作负载与宿主机之间提供更强的隔离。
沙箱内部如何保证 API 密钥和机密信息的安全?凭据保险库(Credential Vault)会把凭据注入到沙箱的出站请求中,而不会向工作负载内运行的代码暴露真实的密钥值。
哪些编程智能体可以通过 MCP 服务器连接?MCP 服务器向支持 MCP 的客户端开放沙箱创建、命令执行和文件操作功能,例如 Claude Code 和 Cursor。
我可以在沙箱内运行 GUI 或基于浏览器的智能体吗?可以,内置示例包括带 VNC 和 DevTools 访问的 Chromium 沙箱、Playwright 无头浏览器自动化,以及可通过 VNC 访问的完整桌面环境。
官方容器镜像发布在哪里?镜像发布在 Docker Hub、GitHub Container Registry 和 Alibaba Cloud Container Registry 上,通过 Cosign 进行无密钥签名,并附带来源证明(provenance attestations)。
osb 命令行工具是做什么的?osb 是 OpenSandbox 的终端命令行工具,用于常见的沙箱工作流:创建沙箱、运行命令、传输文件、查看诊断信息,以及管理运行时的出站流量策略。
Size
109.2 MB
Stars
15.9K
Age
10mo
Commits · 90 Days