pydantic/monty

▲ 48 stars today★ 8,333⑂ 423

A minimal, secure Python interpreter written in Rust for use by AI

About pydantic/monty

pydantic/monty is an open-source project on GitHub, mainly written in Rust. A minimal, secure Python interpreter written in Rust for use by AI It currently holds 8,333 stars and 423 forks with 122 open issues, and was last pushed on 2026-09-26 (repository created 2023-05-28).

Project Overview

Git Homed tracks it on the Today's Trending board, currently at rank #60 with 48 new stars today.

GitHub Repository Details

Repository pydantic/monty · default branch main · size 17205 KB · watchers 40 · source: GitHub REST API and repository README

README

Monty

A secure Python sandbox, written in Rust, for code written by AI.

https://github.com/pydantic/monty/blob/HEAD/CI https://github.com/pydantic/monty/blob/HEAD/Codspeed https://github.com/pydantic/monty/blob/HEAD/Coverage https://github.com/pydantic/monty/blob/HEAD/PyPI https://github.com/pydantic/monty/blob/HEAD/NPM https://github.com/pydantic/monty/blob/HEAD/crates.io https://github.com/pydantic/monty/blob/HEAD/license https://github.com/pydantic/monty/blob/HEAD/Join Slack

______________________________________________________________________

Monty avoids the latency, complexity and cost of a container based sandbox for running LLM generated code. It comes in two forms: OSS Monty, the MIT licensed Python 3.14 sandbox you install as a package, and Full Monty, the commercial server that runs the same sandbox behind a WebSocket as a service.

A new OSS Monty sandbox takes under 1ms from a running pool (Full Monty: about 2ms) compared to around 1500ms for a sandbox service.

Filesystem, environment variables and network do not exist inside the sandbox: it reaches the host only through the functions and mounts you pass in.

Documentation: pydantic.dev/docs/monty

Install

uv add pydantic-monty        # Python
npm install @pydantic/monty  # JavaScript / TypeScript
cargo add monty              # Rust

The commercial Full Monty runs the same workers as a container image.

Example

The code string is what a model writes when asked how long a bar of chocolate could power a lightbulb:

from pydantic_monty import Monty

code = """ kcal = nutrition('chocolate bar')['kcal'] hours = kcal 4184 / (bulb_watts 3600) print(f'a chocolate bar powers a {bulb_watts} W bulb for {hours:.1f} hours') """

with Monty() as pool: with pool.checkout() as session: session.feed_run( code, inputs={'bulb_watts': 10}, external_lookup={'nutrition': lambda food: {'kcal': 230}}, ) #> a chocolate bar powers a 10 W bulb for 26.7 hours

nutrition ran on the host and the sandbox saw only its return value.

Documentation

sandboxing services JavaScript or Rust limits, snapshots, the Python subset Monty runs Code Mode in Pydantic AI. Community bindings: gomonty (Go) and dart_monty (Dart / Flutter).

Part of the Pydantic Stack

The Pydantic Stack is everything you need to ship production-grade AI agents:

agent framework full-stack observability LLM proxy

GitHub Stars & Activity

8,333Stars
423Forks
122Open issues
RustLanguage

GitHub Popularity

GitHub stars8,333
Forks423
Open issues122
Primary languageRust
LicenseMIT
Stars gained today48
Created2023-05-28
Last pushed2026-09-26

Trending History

Daily boardrank #60 · ▲ 48 stars

Related GitHub Projects

1

rust-lang / rust

Rust★ 119,207⑂ 16,839▲ 54 stars
→
2

zed-industries / zed

Rust★ 90,932⑂ 10,786▲ 64 stars
→
3

juspay / hyperswitch

Rust★ 44,230⑂ 5,617▲ 130 stars
→
4

block / buzz

Rust★ 34,792⑂ 4,594▲ 367 stars
→
5

jdx / mise

Rust★ 34,315⑂ 1,448▲ 33 stars
→
6

bootandy / dust

Rust★ 12,387⑂ 294▲ 34 stars
→
7

hydra-db / hydradb

Rust★ 7,968⑂ 3,122▲ 892 stars
→
8

tokio-rs / topcoat

Rust★ 5,406⑂ 183▲ 160 stars
→

More Trending Repositories