About this project

Monty is a secure Python sandbox implemented in Rust, intended for executing code produced by AI models. Rather than spinning up a container per execution, it provides a lightweight interpreter that starts in under a millisecond from a running pool, aiming to reduce the latency, complexity, and cost associated with container-based sandboxing. The project ships in two forms: OSS Monty, an MIT-licensed Python 3.14 sandbox distributed as a package, and Full Monty, a commercial server that runs the same sandbox behind a WebSocket as a service. The README states that a new OSS sandbox takes under 1ms from a running pool, and Full Monty about 2ms, compared with roughly 1500ms for a sandbox service. By design, the sandbox contains no filesystem, environment variables, or network access. Code reaches the host only through functions and mounts explicitly passed in by the caller. The README illustrates this with an example where a model-written snippet calls a host-provided `nutrition` function; the sandbox receives only the function's return value. Installation is available for Python (`uv add pydantic-monty`), JavaScript/TypeScript (`npm install @pydantic/monty`), and Rust (`cargo add monty`). The commercial Full Monty runs the same workers as a container image. Documentation covers an introduction with latency measurements, a comparison to alternatives such as Docker, Pyodide, WASI, and sandboxing services, quickstarts for Python, JavaScript, and Rust, and concepts including the security model, resource limits, snapshots, and the supported Python subset. Monty is used to run Code Mode in Pydantic AI, and community bindings exist for Go (gomonty) and Dart/Flutter (dart_monty). It is part of the Pydantic Stack alongside Pydantic AI, Pydantic Logfire, and the Logfire AI Gateway.