Skip to content

xosnrdev/microsandbox

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

microsandbox-banner-xl-dark microsandbox-banner-xl
———   secure self-hosted sandboxes for your ai agents   ———


floating-sandbox-bot

  WHY MICROSANDBOX?

Building AI agents that generate and execute code? — You'll need secure sandboxes!

To run your ai-generated code, you could try a few things:

  • Run directly on machine? — Risky for the machine [→]
  • Run in docker containers? — Limited isolation for untrusted code [→]
  • Run in traditional VMs? — Minutes to start up, heavy resource usage
  • Run in cloud sandboxes? — Less control over your infra and lose rapid dev cycles

microsandbox gives you the best of all the worlds, all on your own infrastructure:

  •   True VM-Level Security Isolation with Fast Startup Times
  •   Self-Hosted with Full Control
  •   Fast Local Development Iteration Cycles
  •   Seamless Transition from Local to Production
  •   Data Sovereignty and Privacy
  •   Compatible with Standard Container Images
  •   Wide SDK Ecosystem
  •   Integration with Any MCP Enabled AI
• • •

  QUICK START

Get started with the SDK in a few easy steps:

macos linux windows

1    Get API Key

  • Get your API key by [SELF HOSTING →]

  • Set key as an environment variable. For example, you could set it in your .env file

    MSB_API_KEY=msb_***

2    Install SDK

Python
pip install microsandbox
Rust
cargo add microsandbox

Note

There are SDKs for other languages as well! Join us in expanding support for your favorite language.

3    Execute Code in Sandbox

microsandbox offers a growing list of sandbox environment types optimized for different execution requirements. Choose the appropriate sandbox (e.g., PythonSandbox or NodeSandbox) to run your code in a secure tailored environment.

Python
import asyncio
from microsandbox import PythonSandbox

async def main():
    async with PythonSandbox.create(name="test") as sb:
        exec = await sb.run("name = 'Python'")
        exec = await sb.run("print(f'Hello {name}!')")

    print(await exec.output()) # prints Hello Python!

asyncio.run(main())
Rust
use microsandbox::{SandboxOptions, PythonSandbox};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut sb = PythonSandbox::create(SandboxOptions::builder().name("test").build()).await?;

    let exec = sb.run(r#"name = "Python""#).await?;
    let exec = sb.run(r#"print(f"Hello {name}!")"#).await?;

    println!("{}", exec.output().await?); // prints Hello Python!

    sb.stop().await?;

    Ok(())
}

Note

When you run the code for the first time, it will take a while to download the sandbox image unless you already have it downloaded. After that, it will run much faster.

For more information on how to use the SDK, check out the SDK README.


• • •

  USE CASES

coding-dark coding-light

Coding & Dev Environments

Let your AI agents build real apps with professional dev tools. When users ask their AI to create a web app, fix a bug, or build a prototype, it can handle everything from Git operations to dependency management to testing in a protected environment.

Your AI can create complete development environments in milliseconds and run programs with full system access. The fast startup means developers get instant feedback and can iterate quickly. This makes it perfect for AI pair programming, coding education platforms, and automated code generation where quick results matter.


data-dark data-light

Data Analysis

Transform raw numbers into meaningful insights with AI that works for you. Your AI can process spreadsheets, create charts, and generate reports safely. Whether it's analyzing customer feedback, sales trends, or research data, everything happens in a protected environment that respects data privacy.

Microsandbox lets your AI work with powerful libraries like NumPy, Pandas, and TensorFlow while creating visualizations that bring insights to life. Perfect for financial analysis tools, privacy-focused data processing, medical research, and any situation where you need serious computing power with appropriate safeguards.


web-dark web-light

Web Browsing Agent

Build AI assistants that can browse the web for your users. Need to compare prices across stores, gather info from multiple news sites, or automate form submissions? Your AI can handle it all while staying in a contained environment.

With microsandbox, your AI can navigate websites, extract data, fill out forms, and handle logins. It can visit any site and deliver only the useful information back to your application. This makes it ideal for price comparison tools, research assistants, content aggregators, automated testing, and web automation workflows that would otherwise require complex setup.


host-dark host-light

Instant App Hosting

Share working apps and demos in seconds without deployment headaches. When your AI creates a useful tool, calculator, visualization, or prototype, users can immediately access it through a simple link. No waiting for server setup or DNS configuration—just instant access to the application.

Zero-setup deployment means your AI-generated code can be immediately useful without complex configuration. Each app runs in its own protected space with appropriate resource limits, and everything cleans up automatically when no longer needed. Perfect for educational platforms hosting student projects, AI assistants creating live demos, and users needing immediate value.


• • •

  PROJECTS  B E T A

Beyond its SDK for secure execution of untrusted code, microsandbox supports project-based development with familiar package-manager workflows.

Think of it like npm or cargo, but for sandboxes! Create a Sandboxfile, define your environments, and manage your sandboxes with simple commands.


See projects for more information.

• • •

  DEVELOPMENT

Interested in contributing to microsandbox? Check out our Development Guide for instructions on setting up your development environment, building the project, running tests, and creating releases.

For contribution guidelines, please refer to CONTRIBUTING.md.

• • •

  LICENSE

This project is licensed under the Apache License 2.0.

About

open-source sandbox execution environment for AI agents

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 85.3%
  • Shell 6.4%
  • Python 4.5%
  • Makefile 0.7%
  • Ruby 0.3%
  • Dockerfile 0.3%
  • Other 2.5%