Skip to content

Latest commit

 

History

History
57 lines (39 loc) · 1.03 KB

File metadata and controls

57 lines (39 loc) · 1.03 KB

Using custom sandbox with Code Interpreter SDK

If you want to customize the Code Interpreter sandbox (e.g.: add a preinstalled package) you can do that by creating a custom sandbox template.

Step-by-step guide

  1. Install E2B SDK
pip install e2b dotenv
  1. Create a custom sandbox template:

template.py

from e2b import Template

template = Template().from_template("code-interpreter-v1")
  1. Create a build script:

build.py

from dotenv import load_dotenv
from .template import template
from e2b import Template, default_build_logger

load_dotenv()

Template.build(
    template,
    alias="code-interpreter-custom",
    cpu_count=2,
    memory_mb=2048,
    on_build_logs=default_build_logger(),
)
  1. Build the template:
python build.py
  1. Use the custom template:
from e2b import Sandbox

sbx = Sandbox.create(template="code-interpreter-custom")
execution = sbx.run_code("print('Hello, World!')")
print(execution.logs.stdout)