Code interpreter

Sandboxed Python for the arithmetic a model should not do in its head — a deadline, an interest figure, a share of an estate.

code_interpreter runs Python the model wrote, inside a container built to hold nothing valuable and reach nothing else. It answers by executing, not by estimating — asked directly, the same model that runs this can misremember a deadline; the code it runs to compute one does not.

What this costs
Metered per run of the sandbox. Pricing is set by your platform operator and may not be published yet — check Pricing.

The sandbox

A fresh container per call, removed the moment it finishes. Nothing about one run is visible to the next — not a file, not a variable, not an installed package.

ConstraintValue
NetworkNone — no interface to reach anything through, not firewalled traffic. It cannot reach the model servers, your knowledge base, or the open internet.
FilesystemRead-only, plus two small tmpfs mounts (64 MB) that vanish with the container.
PrivilegeRuns as nobody, every Linux capability dropped, no-new-privileges set.
CPU / memory1 core, 512 MB, capped process count — a runaway allocation or a fork bomb kills the container, not the host.
Timeout20 seconds by default, up to whatever your operator has set as the hard ceiling — wall clock, enforced by killing the container.
Outputstdout and stderr only, each capped at 200,000 characters.

What's installed

Python 3.12, plus numpy, pandas, python-dateutil, sympy, matplotlib, openpyxl and tabulate. Neither pip nor requests/urllib3 are present — both were removed on purpose, since there is no network for either to use.

matplotlib is installed and runs, but nothing carries a saved image back out of the container — only stdout and stderr return from a call. Print your results instead of plotting to a file you expect to retrieve; tabulate is there for exactly that.

Declaring it

tools
[{ "type": "code_interpreter" }]
ParameterTypeDescription
code
Required
stringThe Python source to run. Write a self-contained script — the tool never sends input on stdin, even though the sandbox itself accepts it.
timeout
Optional
integerSeconds to allow, capped regardless of what you ask for by whatever ceiling your operator has set.
Default: 20
  • No network — no pip install, no request to any URL, no reading your knowledge base or the legal corpus.
  • No files handed back — only what the code prints.
  • No state between calls — the next run starts from nothing, every time.

Complete example

One request — the model writes the code, runs it, and answers from the result. The model is larsa-auto, the only one that runs code_interpreter server-side.

curl https://api.console.larsa.larsima.com/v1/chat/completions \
  -H "Authorization: Bearer $LARSA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "larsa-auto",
    "messages": [{"role": "user", "content":
      "A notice period of 45 days starts on 2026-08-26. Give the calendar date it ends on, and the day of the week."}],
    "tools": [{"type": "code_interpreter"}]
  }'
Navigate Open esc Close