Modal Sandboxes
by Modal Labs
Safe cloud boxes to run untrusted code.
1. Price
Free tier: Starter: $30/month of free compute, no monthly fee. As reported on the official pricing page, checked Nov 1, 2026.
modal.com/pricing2. Commercial use
“rent, resell or otherwise allow any third party direct access to or use of the Service”
You may run your users' or agents' code through your own product, but not rent, resell or give third parties direct access to Modal, and not process prohibited content. Data: Not stated as allowed; the terms give Modal a license to customer data only as needed to provide the service.
modal.com/legal/terms3. Key & sign-up
“Modal API tokens use MODAL_TOKEN_ID and MODAL_TOKEN_SECRET.”
A Modal API token pair (token ID and token secret), created with modal setup in a browser or in the workspace settings.
modal.com/docs/sdk/py/latest/config.mdChecked against the maker's official pages, pricing on Nov 1, 2026. Tap a verdict to see its source.How we checkedReport an error
What Modal Sandboxes does
Modal Sandboxes are short-lived, locked-down computers in the cloud where your app runs code it does not trust, such as code written by an AI assistant or uploaded by users. If that code breaks something, only the sandbox is affected. You pay per second for the processor and memory it actually uses.
- Modal Sandboxes is one of 12 APIs in the Code sandboxes category on AgentGid.
- Its cheapest paid plan ($250 a month) is the 7th cheapest of the 9 here with a monthly plan.
- It is one of 11 that can be started for free.
- 4 of them ship an official MCP server; Modal Sandboxes does not.
- Its official SDK is the 1st most downloaded in the category (12.7M a week).
What people build with it
Run code your AI assistant wrote
Let a chatbot or coding agent run the Python it just wrote and read the result, without risking your own server.
Run code your users submit
Run homework, coding-challenge answers or user plugins in a box with no internet and a time limit, so a bad script cannot leak data or run forever.
Hand files in and out
Upload a spreadsheet or a project into the sandbox, let the code work on it, and read the results back.
Live preview of an app an agent built
Start a small web server inside the sandbox and open it through a private link, so you can try what the agent made.
Save a ready setup and reuse it
Install the tools once, save the sandbox's state, and start every new session from that saved copy so it begins faster.
Grade many AI attempts at once Idea
Run hundreds of copies of the same task side by side to test or score an AI model's answers, each in its own clean box.
Modal Sandboxes popularity
SDK downloads from npm and PyPI, weekly. Numbers as of Nov 17, 2026.
Pricing
Starter: $30/month of free compute, no monthly fee
$250 a month
Sandbox CPU $0.00003942 per physical core (2 vCPU) per second; memory $0.00000667 per GiB per second
Minimum 0.125 cores per container. Team plan $250/month + compute includes $100/month credits. Since 2026-09-01, Shared Endpoint tokens are billed from the first request even on Starter. No vendor MCP server found; third-party ones exist.
What one action costs
| Action | Price |
|---|---|
| 1 physical CPU core (2 vCPU) for 1 second in a sandbox | $0.00003942 |
| 1 GiB of memory for 1 second in a sandbox | $0.00000667 |
| Team plan for a month (plus compute; includes $100 of credits) | $250 |
Price history
- A year of the pricing page in the Internet Archive (14 months): the lowest monthly figure went from $30 (2025-10) to $30 (2026-11).
As reported on the official pricing page, checked Nov 1, 2026. Prices change: confirm before you buy. modal.com/pricing
Limits
A sandbox lives 5 minutes by default and at most 24 hours
100 containers and 10 GPUs at the same time, 3 seats
5,000 containers and 50 GPUs at the same time
At least 0.125 CPU cores and 128 MiB of memory are billed per sandbox
Logs are kept 1 day on Starter and 30 days on Team
From the official docs. modal.com/docs/guide/sandboxes.md
Key and access
A Modal API token pair (token ID and token secret), created with modal setup in a browser or in the workspace settings.
MODAL_TOKEN_ID and MODAL_TOKEN_SECRET (or ~/.modal.toml written by modal token set)Not stated on the pages we read
Steps only a person can do
- Sign up for Modal and connect the machine with modal setup (opens a browser), or create a token in the workspace settings. Put MODAL_TOKEN_ID and MODAL_TOKEN_SECRET in the server environment (kept out of git) for the modal package to read.
- Set a workspace budget so runaway sandboxes cannot run up a large bill. No code change; also set timeout and resource limits on every Sandbox.create.
- Decide whether to install Modal's agent skill or the standalone command-line tool from its install script. If yes, the person runs it; the agent uses pip install modal at a pinned version inside the project's virtual environment.
Commercial use and your data
Modal is a paid online service with free monthly credits; its client libraries are open source under Apache-2.0. You may run your users' code through your product, but not resell or give others direct access to Modal.
You may run your users' or agents' code through your own product, but not rent, resell or give third parties direct access to Modal, and not process prohibited content.
“rent, resell or otherwise allow any third party direct access to or use of the Service” source
The modal client packages (Python and JavaScript) are Apache-2.0; keep the license notice when you ship them.
“"license":"Apache-2.0"” source
Not stated as allowed; the terms give Modal a license to customer data only as needed to provide the service.
Sandbox logs are kept 1 day on Starter and 30 days on Team; sandbox memory snapshots 7 days; filesystem snapshots 30 days by default.
Requests are routed through us-east (Virginia) by default; choosing a container region costs 1.15 to 1.75 times the base price.
Errors to handle
The token is missing or invalid.
Set MODAL_TOKEN_ID and MODAL_TOKEN_SECRET (or run modal token info to check the saved token).
The sandbox ran past its timeout (5 minutes unless you set one).
Pass a longer timeout to Sandbox.create (up to 24 hours) or split the work.
One command run with exec took longer than its own timeout.
Raise the timeout on sb.exec, or stop the command and report it to the user.
A quota or rate limit was hit, for example too many containers at once for your plan.
Retry later with backoff, run fewer sandboxes at once, or move to a plan with higher limits.
The sandbox or process was killed (terminated, or out of memory).
Check sb.returncode and the dashboard's exit reason; raise the memory request if it ran out of memory.
Use it from an agent
4 of 6: llms.txt yes, OpenAPI no, SDK yes, MCP no, status page yes, AI assistants allowed yes
Checked Nov 13, 2026.
Community servers only
npm install modalpip install modalInstructions in its docs to check first
“Read https://modal.com/docs/guide/getting-started.md and walk me through Modal setup.”
A ready prompt for coding agents; the setup needs a Modal account and a browser sign-in, which only the person can do.
“modal skills install # [--claude] [--global]”
Ask the person first; with --global it installs an agent skill for every project on the machine.
“curl -LsSf uvx.sh/modal/install.sh | sh”
Ask the person first; it runs a downloaded install script. Prefer pip install modal at a pinned version in the project's virtual environment.
Alternatives
Modal Sandboxes This page
Pick E2B for sandboxes built only for AI agents, on small virtual machines that start in under a second.
Pick Vercel Sandbox when your app already runs on Vercel and you want short-lived Linux machines next to it.
Pick Daytona when you need fast-starting sandboxes with Windows or GPU options, billed per second.
Get started
Tell your AI assistant
“Run AI-generated code in a Modal Sandbox with modal 1.6.3: read MODAL_TOKEN_ID and MODAL_TOKEN_SECRET from the server environment, create the sandbox with block_network=True, a timeout and a memory limit, and never pass my secrets into it.”
Create a Modal account (an account is required), then install the Python package.
pip install modalConnect your computer to your account; this opens a browser to sign in and saves a token.
modal setupCreate a sandbox, run a command in it and read the output.
sb_app = modal.App.lookup("my-app", create_if_missing=True) sb = modal.Sandbox.create(app=sb_app) p = sb.exec("python", "-c", "print('hello')", timeout=3) print(p.stdout.read())
First request
sb_app comes from modal.App.lookup("my-app", create_if_missing=True), as in the first example of the guide.
sb = modal.Sandbox.create(app=sb_app)
# Read returncode of individual process
p = sb.exec("sh", "-c", "exit 42")
p.wait()
print(p.returncode) # 42
# Read returncode of finished sandbox
# Terminate sends a SIGKILL, code 137
sb.terminate(wait=True)
print(sb.returncode) # 137
42
137
Mistakes to avoid
By default sandboxes can reach any public address, so bad code could send data out.
Modal's shared responsibility model puts keeping credentials out of untrusted workloads on you.
Requested resources are billed for the sandbox's whole life, even when idle.
The default lifetime is 5 minutes.
Modal raises its own error class, which a bare except TimeoutError does not catch.
Questions
Is there a free plan?
Yes, the Starter plan has no monthly fee and includes $30 of compute a month; you pay only above that.
Can code in the sandbox reach my other Modal resources or the internet?
It cannot reach your Modal resources or accept incoming connections by default, but it can reach the internet unless you block or limit it.
Can I use it from JavaScript?
Yes, the modal package on npm runs sandboxes from server-side Node.js 22+, Deno or Bun.
How do I keep costs down?
Do not set a resource request unless you need guaranteed capacity; you then pay only for what the sandbox uses, and you can set a workspace budget.
Do sandboxes get GPUs?
Yes, with the gVisor runtime; GPU sandboxes can be interrupted, unlike CPU ones.