Safe and persistent environment for running AI generated code.
Project description
⚡ 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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file litsandbox-0.0.1a0.tar.gz.
File metadata
- Download URL: litsandbox-0.0.1a0.tar.gz
- Upload date:
- Size: 97.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc8692f61b784e1c564e0fb7478d7187d8ad158d7f98a3ac345b54d222046f0b
|
|
| MD5 |
91cb1240997e2cb1fea0a70ae00bbb8f
|
|
| BLAKE2b-256 |
5bfdd83af3486ac137b751120eecf92d18a4486262d6f8003a3cb84461dc6e38
|
File details
Details for the file litsandbox-0.0.1a0-py3-none-any.whl.
File metadata
- Download URL: litsandbox-0.0.1a0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc5cf9c586c4b588d0bac6ac9eb098b6d130ea30726a440313b57a5d80ca39f6
|
|
| MD5 |
45ae8ddb2bf2fee003b8fb7df2b67958
|
|
| BLAKE2b-256 |
34c61e35427255458e9a2ff81b8c61784238f3073e40623a68a222b265ce0c70
|