Skip to content
Runtime

What is a code interpreter?

A code interpreter lets an AI model run code in a live session that keeps variables between runs and returns charts and tables.

On Runtime, every sandbox has one, in seven languages, inside its own Firecracker microVM. Python, JavaScript, TypeScript, R, Java, Bash and Go run as notebook-style sessions.

Why AI agents use one

A model is poor at arithmetic and data work done in its head. It is good at writing code that does that work. A code interpreter closes the loop. The model writes a cell, the interpreter runs it, and the model reads the output and writes the next cell. Because state persists, the model can load a file once and then ask ten questions about it, the way a person works in a notebook.

Running that code requires isolation. The model may receive a hostile file, or a prompt injection may tell it to read your secrets. An interpreter inside a sandbox limits the damage to a disposable machine.

Runtime's code interpreter

Fact Value
Languages Python, JavaScript, TypeScript, R, Java, Bash, Go
In the image Python, JavaScript, TypeScript and Bash; R, Java and Go install on first use
State Variables persist between runs; Go keeps functions, types and imports
Rich results matplotlib charts and R plots as PNG; pandas and R data frames as tables
Files display returns a .png, .svg, .html or .csv file as a result, in any language
Python data tools NumPy, pandas and matplotlib in the default image
Isolation A Firecracker microVM with its own kernel; network rules enforced on the host

On 23 September 2026, the first use of Java or Go took about 35 seconds. The first use of R took about 90 seconds. This happens once per sandbox. To skip the wait, install them in a custom image with apt (code interpreter).

Run a cell

TypeScriptimport { Sandbox } from "withruntime";await using sbx = await Sandbox.create({ network: { internet: false } });await sbx.interpreter.run("import math\nx = math.pi");const cell = await sbx.interpreter.run("round(x * 2, 3)");console.log(cell.results[0]?.data["text/plain"]); // 6.283
Pythonfrom withruntime import Runtimeruntime = Runtime()with runtime.sandboxes.create() as sbx:    sbx.interpreter.run("import math\nx = math.pi")    cell = sbx.interpreter.run("round(x * 2, 3)")    print(cell["results"][0]["data"]["text/plain"])

The second cell reads x from the first. To run another language, pass { language: "typescript" }, or language="r" in Python. An agent connected through MCP gets the same sessions through the runtime_sandboxes_interpreter_run tool (MCP).

What it costs

The interpreter adds no cost beyond its sandbox. Runtime charges $0.025 per vCPU-hour of measured CPU and $0.0075 per GiB-hour of memory. A 2 vCPU, 4 GiB sandbox costs $0.03125 an hour while the model thinks, and $0.08 an hour with both CPUs busy (pricing). A new account gets 100 free hours of a 1 GB machine in its first 30 days, without a card.

Facts on this page were checked on 25 October 2026.

100 free hoursin your first 30 days.

of a 1 GB machine

  • No credit card
  • Four sandboxes at once, 2 vCPU and 4 GiB each
  • Then prepaid credit from $10, no plan fee
Start free, no card
Start free, no card