Favicon of LLM Sandbox

LLM Sandbox

A self-hosted code interpreter Python library that runs AI-generated code in Docker, Podman or Kubernetes containers. Open source under MIT.

Screenshot of LLM Sandbox website

LLM Sandbox is a Python library for developers building AI agents and applications that need to execute model-generated code. It runs that code in isolated containers on infrastructure you control, with Docker and Podman backends or Kubernetes for cluster deployments. The project is open source under the MIT license.

Container isolation separates generated code from the host system. You can limit CPU use, memory and execution time, control network access, and define custom security policies. Podman supports rootless containers. These controls address risks such as destructive file operations, unwanted network connections and code that consumes resources indefinitely.

The runtime supports Python, JavaScript, Java, C++ and Go, with dependency management for generated programs. It can capture plots and visualizations automatically and transfer files into and out of the sandbox. Custom container images let applications use their own execution environments. For notebook-style work, interactive Python sessions retain interpreter state between calls. Container pooling reuses prepared environments to reduce startup overhead when an application runs code frequently.

An MCP server gives assistants such as Claude Desktop access to sandboxed code execution and returns generated visualizations. LLM Sandbox also integrates with LangChain, LangGraph and LlamaIndex, and includes examples for the OpenAI Agents SDK and Claude Agent SDK.

Similar to LLM Sandbox