Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

⚡ LitSandbox

Run AI generated code in a safe isolated environment for agents and prototypes.

 

Running untrusted or AI-generated code can compromise local environments or lead to unintended side effects. LitSandbox provides a secure, disposable, and isolated environment specifically designed for executing AI generated code safely.

Experiment safely and build prototypes without compromising security.

✅ Run code in a sandbox     ✅ Integrate with MCP Server  ✅ Support GPU machine
✅ No MLOps glue code        ✅ Easy setup in Python       ✅ Install any package

Lightning AI • Docs • Quick start

Quick start

Install LitSandbox via pip:

pip install litsandbox

Example

from litsandbox import Sandbox

s = Sandbox()
output = s.run('git clone https://github.com/octocat/Hello-World.git')
s.run_python_code("f = open('file.txt', 'w'); f.write('hello world')")
s.stop()

Key benefits

  • Run code in a safe, isolated environment
  • Data persists across restarts
  • Supports GPU machines
  • Integrate with MCP Server
  • Easy setup in Python
  • Install any package

Build agentic system

Safely prototype with LLM-generated code using a sandboxed execution environment.

from openai import OpenAI
from litsandbox import Sandbox


# Prompt the model to generate Python code
client = OpenAI()
response = client.chat.completions.create(
    model="gpt-4.1",
    messages=[
        {"role": "system", "content": "You are a helpful Python coding assistant. Only return clean, executable Python code with no explanations. Your response will be executed directly."},
        {"role": "user", "content": "Write a Python program that prints the first 5 square numbers."}
])
generated_code = response.choices[0].message.content.strip()
print("Generated Code:\n", generated_code)


# Execute the code securely in a sandbox
sandbox = Sandbox(machine="CPU")
output = sandbox.run_python_code(generated_code)
print("\nExecution Output:\n", output.text)
# Stop the sandbox
sandbox.stop()

Metadata

Release files for litsandbox 0.0.1a0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for litsandbox 0.0.1a0
File Size Uploaded
litsandbox-0.0.1a0.tar.gz 97.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for litsandbox 0.0.1a0
File Interpreter ABI Platform
litsandbox-0.0.1a0-py3-none-any.whl Python 3 none any Details

Total release size: 108.6 kB

Release files / litsandbox-0.0.1a0.tar.gz

Download URL litsandbox-0.0.1a0.tar.gz
Size 97.5 kB
Tags Source
SHA-256 checksum
How to use checksums
dc8692f61b784e1c564e0fb7478d7187d8ad158d7f98a3ac345b54d222046f0b
BLAKE2b-256 checksum
How to use checksums
5bfdd83af3486ac137b751120eecf92d18a4486262d6f8003a3cb84461dc6e38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / litsandbox-0.0.1a0-py3-none-any.whl

Download URL litsandbox-0.0.1a0-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dc5cf9c586c4b588d0bac6ac9eb098b6d130ea30726a440313b57a5d80ca39f6
BLAKE2b-256 checksum
How to use checksums
34c61e35427255458e9a2ff81b8c61784238f3073e40623a68a222b265ce0c70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release history Release notifications | RSS feed

This release

0.0.1a0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page