Skip to main content

Why use a Sandbox?

Using a sandbox provides a safe, self-contained space for running code or programs without affecting your main system. This can be especially helpful for a coding agent that needs a controlled environment to work in. Here’s an easy Python example that shows how to create a Modal sandbox with a Relace repo. In this code, we create a Modal sandbox, configure Git, and clone the Relace repo using the repo ID and Relace API key.
Make sure you run pip install modal to install the Modal package and modal setup to authenticate Modal before running the Python example:
To run this example use: python sandbox.py Once your sandbox is created you run commands inside the sandbox using sandbox.exec(...) to test or experiment with the code in the cloned Relace repo.

E2B Example

Heres another example that shows how to create a sandbox with Relace repos using E2B with TypeScript.
Make sure you run npm install @e2b/code-interpreter to install E2B and set environment variable with your E2B API key before running the TypeScript example:
To run this example use npx ts-node sandbox.ts Once your sandbox is created you run commands inside the sandbox using sandbox.commands.run(...)to test or experiment with the code in the cloned Relace repo. For more details, see Modal docs or E2B docs.