Templates

A template is the image a sandbox starts from. Use a public one, or build your own.

Public templates

Public templates are the same for every account, are never charged for storage, and are used by name. The console's templates page lists the ones the platform offers now, with their sizes; these are always there.

TemplateSizeContents
base2 vCPU, 1 GiBE2B's base image (e2bdev/base); the default
code-interpreter-v12 vCPU, 1 GiBThe template of E2B's code interpreter SDK
browser2 vCPU, 1 GiBHeadless Chromium, already running, with its DevTools (CDP) on port 9222
browser-2g2 vCPU, 2 GiBThe same with more memory, for many tabs or heavy pages
desktop2 vCPU, 1 GiBA Linux desktop for E2B's desktop SDK: screenshots, mouse, keyboard, a live view, and Chromium
desktop-2g2 vCPU, 2 GiBThe same with more memory

A template's size is the size of its sandboxes, so a template bigger than the plan's size of a sandbox cannot be used on that plan (Base: 4 vCPU and 8 GiB).

pythonsandbox = Sandbox.create("base")

A browser for agents

The browser template starts with Chromium running. Connect to it over CDP at https://9222-<sandbox id>.lumicloud.dev with Playwright, Puppeteer or any CDP client; nothing is installed on your machine but the client. The User-Agent says HeadlessChrome; set your own if a site refuses it.

pythonfrom e2b import Sandbox
from playwright.sync_api import sync_playwright

with Sandbox.create("browser", timeout=300) as sandbox, sync_playwright() as p:
    browser = p.chromium.connect_over_cdp("https://" + sandbox.get_host(9222))
    page = browser.contexts[0].new_page()
    page.goto("https://example.com")
    print(page.title())

A desktop for computer use

E2B's desktop SDK uses the desktop template by default: set the domain and the key, and leave the template out.

shpip install e2b-desktop
# or: npm install @e2b/desktop
pythonfrom e2b_desktop import Sandbox

desktop = Sandbox.create()
desktop.stream.start()
print(desktop.stream.get_url())  # watch it in your browser
desktop.launch("google-chrome")
png = desktop.screenshot()
desktop.left_click(500, 300)
desktop.write("hello")
desktop.kill()

Your own templates

Templates of your own are built with the SDK's template builder, from a container image or a Dockerfile, and used by name. A template belongs to the account that built it and is visible to that account only; its name is unique within the account. Building comes with Pro (2 builds at a time); Base uses the public templates.

Build from a base image

pythonfrom e2b import Template, Sandbox

template = (
    Template()
    .from_python_image("3.12")
    .pip_install(["requests", "pandas"])
)
Template.build(template, "my-template", cpu_count=2, memory_mb=2048)

sandbox = Sandbox.create("my-template")

Build from a Dockerfile

pythontemplate = Template().from_dockerfile("Dockerfile")
Template.build(template, "my-app", cpu_count=2, memory_mb=2048)

The same builder is in the JavaScript SDK; the build runs on LumiCloud and its output is streamed back to the SDK.

Size

A template's cpu_count and memory_mb are the size of the sandboxes made from it, within the plan's size of a sandbox (Base: up to 4 vCPU and 8 GiB; Pro: up to 8 vCPU and 16 GiB). Creating a sandbox from a bigger template is refused with the reason (400).

Storage and cost

A template of your own is stored once, whatever the number of sandboxes made from it, and is charged by the hour at $0.080 per GiB per month beyond the plan's free storage (5 GiB on Base, 20 GiB on Pro), together with the snapshots of paused sandboxes. Data that a sandbox shares with its template counts once. Running a sandbox from a template is charged as any sandbox: by vCPU and memory, for the running time.

The console's templates page

  • Lists the public templates and your own, as the cluster has them. For each: its name and ID, the size of a sandbox made from it (vCPU and memory), the disk (its whole size, and the free space of it that the build asked for), the status of its latest build (ready, building, failed), when a sandbox was last started from it and how many have been, and, for your own, the size stored and the storage cost per month.
  • Deletes a template of your own. It is refused while a sandbox, running or paused, is made from it: delete those first. A deleted template is no longer stored or charged. The public templates cannot be deleted.
  • On a plan without builds, shows the plan that has them and its upgrade.
  • Does not build templates: that is done with the SDK.

Errors

  • A template bigger than the plan's size of a sandbox: 400, with the reason.
  • Deleting a template that a sandbox, running or paused, is made from: 400, with the reason.
NextNetwork →