# Customize the template (/docs/code-interpreting/customize-template)

<!-- agent-signals: reading_time_min: 3 · est_tokens: 1761 · updated: 2026-07-30 -->
Related: [Analyze data with AI](/docs/code-interpreting/analyze-data-with-ai.md), [Code contexts](/docs/code-interpreting/contexts.md), [Create charts & visualizations](/docs/code-interpreting/create-charts-visualizations.md), [Streaming](/docs/code-interpreting/streaming.md), [Supported languages](/docs/code-interpreting/supported-languages.md)

The Code Interpreter SDK runs on the public `code-interpreter-v1` sandbox template. You can customize it in two ways:

1. [Create a custom template](#create-a-custom-template) that extends `code-interpreter-v1` with extra packages or a different runtime — this is the recommended approach for most use cases.
2. [Build the production template](#build-the-production-template) directly from the [`code-interpreter` repository](https://github.com/e2b-dev/code-interpreter) — useful when contributing to the SDK or building the official `code-interpreter-v1` template yourself.

***

## Create a custom template [#create-a-custom-template]

Use this when you need extra preinstalled packages or a different runtime. Your template builds on top of `code-interpreter-v1`, so everything the Code Interpreter SDK relies on stays in place.

### 1. Install the E2B SDK [#1-install-the-e2b-sdk]

<CodeGroup>
  <CodeBlockTabs defaultValue="JavaScript & TypeScript" groupId="javascript-typescript+python">
    <CodeBlockTabsList>
      <CodeBlockTabsTrigger value="JavaScript & TypeScript">
        JavaScript & TypeScript
      </CodeBlockTabsTrigger>

      <CodeBlockTabsTrigger value="Python">
        Python
      </CodeBlockTabsTrigger>
    </CodeBlockTabsList>

    <CodeBlockTab value="JavaScript & TypeScript">
      ```bash  
      npm install e2b dotenv
      ```
    </CodeBlockTab>

    <CodeBlockTab value="Python">
      ```bash  
      pip install e2b python-dotenv
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>

### 2. Create a template file [#2-create-a-template-file]

<CodeGroup>
  <CodeBlockTabs defaultValue="JavaScript & TypeScript" groupId="javascript-typescript+python">
    <CodeBlockTabsList>
      <CodeBlockTabsTrigger value="JavaScript & TypeScript">
        JavaScript & TypeScript
      </CodeBlockTabsTrigger>

      <CodeBlockTabsTrigger value="Python">
        Python
      </CodeBlockTabsTrigger>
    </CodeBlockTabsList>

    <CodeBlockTab value="JavaScript & TypeScript">
      ```typescript  
      // template.ts
      import { Template } from 'e2b';

      export const template = Template().fromTemplate("code-interpreter-v1");
      ```
    </CodeBlockTab>

    <CodeBlockTab value="Python">
      ```python  
      # template.py
      from e2b import Template

      template = Template().from_template("code-interpreter-v1")
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>

### 3. Create a build script [#3-create-a-build-script]

<CodeGroup>
  <CodeBlockTabs defaultValue="JavaScript & TypeScript" groupId="javascript-typescript+python">
    <CodeBlockTabsList>
      <CodeBlockTabsTrigger value="JavaScript & TypeScript">
        JavaScript & TypeScript
      </CodeBlockTabsTrigger>

      <CodeBlockTabsTrigger value="Python">
        Python
      </CodeBlockTabsTrigger>
    </CodeBlockTabsList>

    <CodeBlockTab value="JavaScript & TypeScript">
      ```typescript  
      // build.ts
      import "dotenv/config";
      import { Template, defaultBuildLogger } from 'e2b';
      import { template } from './template';

      async function main() {
        await Template.build(template, 'code-interpreter-custom', {
          cpuCount: 2,
          memoryMB: 2048,
          onBuildLogs: defaultBuildLogger(),
        });
      }

      main().catch(console.error);
      ```
    </CodeBlockTab>

    <CodeBlockTab value="Python">
      ```python  
      # build.py
      from dotenv import load_dotenv
      from e2b import Template, default_build_logger
      from template import template

      load_dotenv()

      Template.build(
          template,
          alias="code-interpreter-custom",
          cpu_count=2,
          memory_mb=2048,
          on_build_logs=default_build_logger(),
      )
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>

### 4. Set your environment variables [#4-set-your-environment-variables]

Create a `.env` file with your API key (loaded by `dotenv` / `load_dotenv()`):

```bash
E2B_API_KEY=e2b_***
```

### 5. Build the template [#5-build-the-template]

<CodeGroup>
  <CodeBlockTabs defaultValue="JavaScript & TypeScript" groupId="javascript-typescript+python">
    <CodeBlockTabsList>
      <CodeBlockTabsTrigger value="JavaScript & TypeScript">
        JavaScript & TypeScript
      </CodeBlockTabsTrigger>

      <CodeBlockTabsTrigger value="Python">
        Python
      </CodeBlockTabsTrigger>
    </CodeBlockTabsList>

    <CodeBlockTab value="JavaScript & TypeScript">
      ```bash  
      npx tsx build.ts
      ```
    </CodeBlockTab>

    <CodeBlockTab value="Python">
      ```bash  
      python build.py
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>

### 6. Use the custom template [#6-use-the-custom-template]

<CodeGroup>
  <CodeBlockTabs defaultValue="JavaScript & TypeScript" groupId="javascript-typescript+python">
    <CodeBlockTabsList>
      <CodeBlockTabsTrigger value="JavaScript & TypeScript">
        JavaScript & TypeScript
      </CodeBlockTabsTrigger>

      <CodeBlockTabsTrigger value="Python">
        Python
      </CodeBlockTabsTrigger>
    </CodeBlockTabsList>

    <CodeBlockTab value="JavaScript & TypeScript">
      ```js  
      import { Sandbox } from '@e2b/code-interpreter'

      const sbx = await Sandbox.create("code-interpreter-custom")
      const execution = await sbx.runCode("print('Hello, World!')")
      console.log(execution.logs.stdout)
      ```
    </CodeBlockTab>

    <CodeBlockTab value="Python">
      ```python  
      from e2b_code_interpreter import Sandbox

      sbx = Sandbox.create("code-interpreter-custom")
      execution = sbx.run_code("print('Hello, World!')")
      print(execution.logs.stdout)
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>

<Note>
  See [Install custom packages](/docs/quickstart/install-custom-packages) for preinstalling specific Python and Node.js packages with `pip` / `npm`.
</Note>

***

## Build the production template [#build-the-production-template]

To build the official `code-interpreter-v1` template from the [`code-interpreter` repository](https://github.com/e2b-dev/code-interpreter), use `build_prod.py`. This is the script CI and releases run, and it's the path to take when you're contributing to the SDK or want to rebuild the production template yourself.

### 1. Clone the repository [#1-clone-the-repository]

The template lives in the `template/` directory — run the remaining steps from there.

```bash
git clone https://github.com/e2b-dev/code-interpreter.git
cd code-interpreter/template
```

### 2. Install the build dependencies [#2-install-the-build-dependencies]

```bash
pip install -r requirements-dev.txt
```

### 3. Provide your credentials [#3-provide-your-credentials]

Create a `.env` file with your API key:

```bash
E2B_API_KEY=e2b_***
```

### 4. Build the template [#4-build-the-template]

```bash
python build_prod.py
```

To force a clean rebuild that ignores the layer cache, set `SKIP_CACHE=true`:

```bash
SKIP_CACHE=true python build_prod.py
```
