> ## Documentation Index
> Fetch the complete documentation index at: https://e2b-mintlify-578de46b.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Template

### TemplateBase

Base class for building E2B sandbox templates.

#### Implements

* `TemplateFromImage`
* `TemplateBuilder`
* `TemplateFinal`

#### Constructors

```ts theme={null}
new TemplateBase(options?: TemplateOptions): TemplateBase
```

###### Parameters

| Parameter  | Type              |
| ---------- | ----------------- |
| `options`? | `TemplateOptions` |

###### Returns

`TemplateBase`

#### Methods

### addMcpServer()

```ts theme={null}
addMcpServer(servers: keyof McpServer | keyof McpServer[]): TemplateBuilder
```

Install MCP servers using mcp-gateway.
Note: Requires a base image with mcp-gateway pre-installed (e.g., mcp-gateway).

###### Parameters

| Parameter | Type                                  | Description        |
| --------- | ------------------------------------- | ------------------ |
| `servers` | keyof McpServer \| keyof McpServer\[] | MCP server name(s) |

###### Returns

`TemplateBuilder`

###### Throws

If the base template is not mcp-gateway

###### Example

```ts theme={null}
template.addMcpServer('exa')
template.addMcpServer(['brave', 'firecrawl', 'duckduckgo'])
```

###### Implementation of

`TemplateBuilder`.`addMcpServer`

### aptInstall()

```ts theme={null}
aptInstall(packages: string | string[], options?: object): TemplateBuilder
```

Install Debian/Ubuntu packages using apt-get.

###### Parameters

| Parameter                      | Type                                                            | Description     |
| ------------------------------ | --------------------------------------------------------------- | --------------- |
| `packages`                     | `string` \| `string`\[]                                         | Package name(s) |
| `options`?                     | \{ `fixMissing`: `boolean`; `noInstallRecommends`: `boolean`; } | -               |
| `options.fixMissing`?          | `boolean`                                                       | -               |
| `options.noInstallRecommends`? | `boolean`                                                       | -               |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.aptInstall('vim')
template.aptInstall(['git', 'curl', 'wget'])
template.aptInstall(['vim'], { noInstallRecommends: true })
template.aptInstall(['vim'], { fixMissing: true })
```

###### Implementation of

`TemplateBuilder`.`aptInstall`

### betaDevContainerPrebuild()

```ts theme={null}
betaDevContainerPrebuild(devcontainerDirectory: string): TemplateBuilder
```

Prebuild a devcontainer from the specified directory.

###### Parameters

| Parameter               | Type     | Description                        |
| ----------------------- | -------- | ---------------------------------- |
| `devcontainerDirectory` | `string` | Path to the devcontainer directory |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template
 .gitClone('https://myrepo.com/project.git', '/my-devcontainer')
 .betaDevContainerPrebuild('/my-devcontainer')
```

###### Implementation of

`TemplateBuilder`.`betaDevContainerPrebuild`

### betaSetDevContainerStart()

```ts theme={null}
betaSetDevContainerStart(devcontainerDirectory: string): TemplateFinal
```

Start a devcontainer from the specified directory.

###### Parameters

| Parameter               | Type     | Description                        |
| ----------------------- | -------- | ---------------------------------- |
| `devcontainerDirectory` | `string` | Path to the devcontainer directory |

###### Returns

`TemplateFinal`

###### Example

```ts theme={null}
template
 .gitClone('https://myrepo.com/project.git', '/my-devcontainer')
 .startDevcontainer('/my-devcontainer')

// Prebuild and start
template
 .gitClone('https://myrepo.com/project.git', '/my-devcontainer')
 .betaDevContainerPrebuild('/my-devcontainer')
 // Other instructions...
 .betaSetDevContainerStart('/my-devcontainer')
```

###### Implementation of

`TemplateBuilder`.`betaSetDevContainerStart`

### bunInstall()

```ts theme={null}
bunInstall(packages?: string | string[], options?: object): TemplateBuilder
```

Install Bun packages using bun.

###### Parameters

| Parameter      | Type                                   | Description                                   |
| -------------- | -------------------------------------- | --------------------------------------------- |
| `packages`?    | `string` \| `string`\[]                | Package name(s) or undefined for package.json |
| `options`?     | \{ `dev`: `boolean`; `g`: `boolean`; } | Install options                               |
| `options.dev`? | `boolean`                              | -                                             |
| `options.g`?   | `boolean`                              | -                                             |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.bunInstall('express')
template.bunInstall(['lodash', 'axios'])
template.bunInstall('tsx', { g: true })
template.bunInstall('typescript', { dev: true })
template.bunInstall()  // Installs from package.json
```

###### Implementation of

`TemplateBuilder`.`bunInstall`

### copy()

```ts theme={null}
copy(
   src: PathLike | PathLike[], 
   dest: PathLike, 
   options?: object): TemplateBuilder
```

Copy files or directories into the template.

###### Parameters

| Parameter                  | Type                                                                                          | Description      |
| -------------------------- | --------------------------------------------------------------------------------------------- | ---------------- |
| `src`                      | `PathLike` \| `PathLike`\[]                                                                   | Source path(s)   |
| `dest`                     | `PathLike`                                                                                    | Destination path |
| `options`?                 | \{ `forceUpload`: `true`; `mode`: `number`; `resolveSymlinks`: `boolean`; `user`: `string`; } | Copy options     |
| `options.forceUpload`?     | `true`                                                                                        | -                |
| `options.mode`?            | `number`                                                                                      | -                |
| `options.resolveSymlinks`? | `boolean`                                                                                     | -                |
| `options.user`?            | `string`                                                                                      | -                |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.copy('requirements.txt', '/home/user/')
template.copy(['app.ts', 'config.ts'], '/app/', { mode: 0o755 })
```

###### Implementation of

`TemplateBuilder`.`copy`

### copyItems()

```ts theme={null}
copyItems(items: CopyItem[]): TemplateBuilder
```

Copy multiple items with individual options.

###### Parameters

| Parameter | Type          | Description         |
| --------- | ------------- | ------------------- |
| `items`   | `CopyItem`\[] | Array of copy items |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.copyItems([
  { src: 'app.ts', dest: '/app/' },
  { src: 'config.ts', dest: '/app/', mode: 0o644 }
])
```

###### Implementation of

`TemplateBuilder`.`copyItems`

### fromAWSRegistry()

```ts theme={null}
fromAWSRegistry(image: string, credentials: object): TemplateBuilder
```

Start from a Docker image in AWS ECR.

###### Parameters

| Parameter                     | Type                                                                           | Description         |
| ----------------------------- | ------------------------------------------------------------------------------ | ------------------- |
| `image`                       | `string`                                                                       | Full ECR image path |
| `credentials`                 | \{ `accessKeyId`: `string`; `region`: `string`; `secretAccessKey`: `string`; } | AWS credentials     |
| `credentials.accessKeyId`     | `string`                                                                       | -                   |
| `credentials.region`          | `string`                                                                       | -                   |
| `credentials.secretAccessKey` | `string`                                                                       | -                   |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
Template().fromAWSRegistry(
  '123456789.dkr.ecr.us-west-2.amazonaws.com/myimage:latest',
  {
    accessKeyId: 'AKIA...',
    secretAccessKey: '...',
    region: 'us-west-2'
  }
)
```

###### Implementation of

```ts theme={null}
TemplateFromImage.fromAWSRegistry
```

### fromBaseImage()

```ts theme={null}
fromBaseImage(): TemplateBuilder
```

Start from E2B's default base image (e2bdev/base:latest).

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
Template().fromBaseImage()
```

###### Implementation of

```ts theme={null}
TemplateFromImage.fromBaseImage
```

### fromBunImage()

```ts theme={null}
fromBunImage(variant: string): TemplateBuilder
```

Start from a Bun-based Docker image.

###### Parameters

| Parameter | Type     | Default value | Description                     |
| --------- | -------- | ------------- | ------------------------------- |
| `variant` | `string` | `'latest'`    | Bun variant (default: 'latest') |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
Template().fromBunImage('1.3')
```

###### Implementation of

```ts theme={null}
TemplateFromImage.fromBunImage
```

### fromDebianImage()

```ts theme={null}
fromDebianImage(variant: string): TemplateBuilder
```

Start from a Debian-based Docker image.

###### Parameters

| Parameter | Type     | Default value | Description                        |
| --------- | -------- | ------------- | ---------------------------------- |
| `variant` | `string` | `'stable'`    | Debian variant (default: 'stable') |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
Template().fromDebianImage('bookworm')
```

###### Implementation of

```ts theme={null}
TemplateFromImage.fromDebianImage
```

### fromDockerfile()

```ts theme={null}
fromDockerfile(dockerfileContentOrPath: string): TemplateBuilder
```

Parse a Dockerfile and convert it to Template SDK format.

###### Parameters

| Parameter                 | Type     | Description                |
| ------------------------- | -------- | -------------------------- |
| `dockerfileContentOrPath` | `string` | Dockerfile content or path |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
Template().fromDockerfile('Dockerfile')
Template().fromDockerfile('FROM python:3\nRUN pip install numpy')
```

###### Implementation of

```ts theme={null}
TemplateFromImage.fromDockerfile
```

### fromGCPRegistry()

```ts theme={null}
fromGCPRegistry(image: string, credentials: object): TemplateBuilder
```

Start from a Docker image in Google Container Registry.

###### Parameters

| Parameter                        | Type                                             | Description                     |
| -------------------------------- | ------------------------------------------------ | ------------------------------- |
| `image`                          | `string`                                         | Full GCR/GAR image path         |
| `credentials`                    | \{ `serviceAccountJSON`: `string` \| `object`; } | GCP service account credentials |
| `credentials.serviceAccountJSON` | `string` \| `object`                             | -                               |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
Template().fromGCPRegistry(
  'gcr.io/myproject/myimage:latest',
  { serviceAccountJSON: 'path/to/service-account.json' }
)
```

###### Implementation of

```ts theme={null}
TemplateFromImage.fromGCPRegistry
```

### fromImage()

```ts theme={null}
fromImage(baseImage: string, credentials?: object): TemplateBuilder
```

Start from a custom Docker image.

###### Parameters

| Parameter               | Type                                             | Description                                 |
| ----------------------- | ------------------------------------------------ | ------------------------------------------- |
| `baseImage`             | `string`                                         | Docker image name                           |
| `credentials`?          | \{ `password`: `string`; `username`: `string`; } | Optional credentials for private registries |
| `credentials.password`? | `string`                                         | -                                           |
| `credentials.username`? | `string`                                         | -                                           |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
Template().fromImage('python:3')

// With credentials (optional)
Template().fromImage('myregistry.com/myimage:latest', {
  username: 'user',
  password: 'pass'
})
```

###### Implementation of

```ts theme={null}
TemplateFromImage.fromImage
```

### fromNodeImage()

```ts theme={null}
fromNodeImage(variant: string): TemplateBuilder
```

Start from a Node.js-based Docker image.

###### Parameters

| Parameter | Type     | Default value | Description                      |
| --------- | -------- | ------------- | -------------------------------- |
| `variant` | `string` | `'lts'`       | Node.js variant (default: 'lts') |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
Template().fromNodeImage('24')
```

###### Implementation of

```ts theme={null}
TemplateFromImage.fromNodeImage
```

### fromPythonImage()

```ts theme={null}
fromPythonImage(version: string): TemplateBuilder
```

Start from a Python-based Docker image.

###### Parameters

| Parameter | Type     | Default value | Description                   |
| --------- | -------- | ------------- | ----------------------------- |
| `version` | `string` | `'3'`         | Python version (default: '3') |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
Template().fromPythonImage('3')
```

###### Implementation of

```ts theme={null}
TemplateFromImage.fromPythonImage
```

### fromTemplate()

```ts theme={null}
fromTemplate(template: string): TemplateBuilder
```

Start from an existing E2B template.

###### Parameters

| Parameter  | Type     | Description              |
| ---------- | -------- | ------------------------ |
| `template` | `string` | E2B template ID or alias |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
Template().fromTemplate('my-base-template')
```

###### Implementation of

```ts theme={null}
TemplateFromImage.fromTemplate
```

### fromUbuntuImage()

```ts theme={null}
fromUbuntuImage(variant: string): TemplateBuilder
```

Start from an Ubuntu-based Docker image.

###### Parameters

| Parameter | Type     | Default value | Description                        |
| --------- | -------- | ------------- | ---------------------------------- |
| `variant` | `string` | `'latest'`    | Ubuntu variant (default: 'latest') |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
Template().fromUbuntuImage('24.04')
```

###### Implementation of

```ts theme={null}
TemplateFromImage.fromUbuntuImage
```

### gitClone()

```ts theme={null}
gitClone(
   url: string, 
   path?: PathLike, 
   options?: object): TemplateBuilder
```

Clone a Git repository.

###### Parameters

| Parameter         | Type                                                          | Description               |
| ----------------- | ------------------------------------------------------------- | ------------------------- |
| `url`             | `string`                                                      | Repository URL            |
| `path`?           | `PathLike`                                                    | Optional destination path |
| `options`?        | \{ `branch`: `string`; `depth`: `number`; `user`: `string`; } | Clone options             |
| `options.branch`? | `string`                                                      | -                         |
| `options.depth`?  | `number`                                                      | -                         |
| `options.user`?   | `string`                                                      | -                         |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.gitClone('https://github.com/user/repo.git', '/app/repo')
template.gitClone('https://github.com/user/repo.git', undefined, {
  branch: 'main',
  depth: 1
})
template.gitClone('https://github.com/user/repo.git', '/app/repo', {
  user: 'root'
})
```

###### Implementation of

`TemplateBuilder`.`gitClone`

### makeDir()

```ts theme={null}
makeDir(path: PathLike | PathLike[], options?: object): TemplateBuilder
```

Create directories.

###### Parameters

| Parameter       | Type                                     | Description       |
| --------------- | ---------------------------------------- | ----------------- |
| `path`          | `PathLike` \| `PathLike`\[]              | Directory path(s) |
| `options`?      | \{ `mode`: `number`; `user`: `string`; } | Directory options |
| `options.mode`? | `number`                                 | -                 |
| `options.user`? | `string`                                 | -                 |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.makeDir('/app/data', { mode: 0o755 })
template.makeDir(['/app/logs', '/app/cache'])
template.makeDir('/app/data', { mode: 0o755, user: 'root' })
```

###### Implementation of

`TemplateBuilder`.`makeDir`

### makeSymlink()

```ts theme={null}
makeSymlink(
   src: PathLike, 
   dest: PathLike, 
   options?: object): TemplateBuilder
```

Create a symbolic link.

###### Parameters

| Parameter        | Type                                       | Description                         |
| ---------------- | ------------------------------------------ | ----------------------------------- |
| `src`            | `PathLike`                                 | Source path (target)                |
| `dest`           | `PathLike`                                 | Destination path (symlink location) |
| `options`?       | \{ `force`: `boolean`; `user`: `string`; } | Symlink options                     |
| `options.force`? | `boolean`                                  | -                                   |
| `options.user`?  | `string`                                   | -                                   |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.makeSymlink('/usr/bin/python3', '/usr/bin/python')
template.makeSymlink('/usr/bin/python3', '/usr/bin/python', { user: 'root' })
template.makeSymlink('/usr/bin/python3', '/usr/bin/python', { force: true })
```

###### Implementation of

`TemplateBuilder`.`makeSymlink`

### npmInstall()

```ts theme={null}
npmInstall(packages?: string | string[], options?: object): TemplateBuilder
```

Install Node.js packages using npm.

###### Parameters

| Parameter      | Type                                   | Description                                   |
| -------------- | -------------------------------------- | --------------------------------------------- |
| `packages`?    | `string` \| `string`\[]                | Package name(s) or undefined for package.json |
| `options`?     | \{ `dev`: `boolean`; `g`: `boolean`; } | Install options                               |
| `options.dev`? | `boolean`                              | -                                             |
| `options.g`?   | `boolean`                              | -                                             |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.npmInstall('express')
template.npmInstall(['lodash', 'axios'])
template.npmInstall('tsx', { g: true })
template.npmInstall('typescript', { dev: true })
template.npmInstall()  // Installs from package.json
```

###### Implementation of

`TemplateBuilder`.`npmInstall`

### pipInstall()

```ts theme={null}
pipInstall(packages?: string | string[], options?: object): TemplateBuilder
```

Install Python packages using pip.

###### Parameters

| Parameter    | Type                    | Description                                                                                        |
| ------------ | ----------------------- | -------------------------------------------------------------------------------------------------- |
| `packages`?  | `string` \| `string`\[] | Package name(s) or undefined for current directory                                                 |
| `options`?   | \{ `g`: `boolean`; }    | Install options                                                                                    |
| `options.g`? | `boolean`               | Install globally as root (default: true). Set to false for user-only installation with --user flag |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.pipInstall('numpy')  // Installs globally (default)
template.pipInstall(['pandas', 'scikit-learn'])
template.pipInstall('numpy', { g: false })  // Install for user only
template.pipInstall()  // Installs from current directory
```

###### Implementation of

`TemplateBuilder`.`pipInstall`

### remove()

```ts theme={null}
remove(path: PathLike | PathLike[], options?: object): TemplateBuilder
```

Remove files or directories.

###### Parameters

| Parameter            | Type                                                               | Description       |
| -------------------- | ------------------------------------------------------------------ | ----------------- |
| `path`               | `PathLike` \| `PathLike`\[]                                        | Path(s) to remove |
| `options`?           | \{ `force`: `boolean`; `recursive`: `boolean`; `user`: `string`; } | Remove options    |
| `options.force`?     | `boolean`                                                          | -                 |
| `options.recursive`? | `boolean`                                                          | -                 |
| `options.user`?      | `string`                                                           | -                 |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.remove('/tmp/cache', { recursive: true, force: true })
template.remove('/tmp/cache', { recursive: true, force: true, user: 'root' })
```

###### Implementation of

`TemplateBuilder`.`remove`

### rename()

```ts theme={null}
rename(
   src: PathLike, 
   dest: PathLike, 
   options?: object): TemplateBuilder
```

Rename or move a file or directory.

###### Parameters

| Parameter        | Type                                       | Description      |
| ---------------- | ------------------------------------------ | ---------------- |
| `src`            | `PathLike`                                 | Source path      |
| `dest`           | `PathLike`                                 | Destination path |
| `options`?       | \{ `force`: `boolean`; `user`: `string`; } | Rename options   |
| `options.force`? | `boolean`                                  | -                |
| `options.user`?  | `string`                                   | -                |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.rename('/tmp/old.txt', '/tmp/new.txt')
template.rename('/tmp/old.txt', '/tmp/new.txt', { user: 'root' })
```

###### Implementation of

`TemplateBuilder`.`rename`

### runCmd()

###### Call Signature

```ts theme={null}
runCmd(command: string, options?: object): TemplateBuilder
```

Run a shell command.

###### Parameters

| Parameter       | Type                   | Description     |
| --------------- | ---------------------- | --------------- |
| `command`       | `string`               | Command string  |
| `options`?      | \{ `user`: `string`; } | Command options |
| `options.user`? | `string`               | -               |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.runCmd('apt-get update')
template.runCmd(['pip install numpy', 'pip install pandas'])
template.runCmd('apt-get install vim', { user: 'root' })
```

###### Implementation of

`TemplateBuilder`.`runCmd`

###### Call Signature

```ts theme={null}
runCmd(commands: string[], options?: object): TemplateBuilder
```

Run multiple shell commands.

###### Parameters

| Parameter       | Type                   | Description              |
| --------------- | ---------------------- | ------------------------ |
| `commands`      | `string`\[]            | Array of command strings |
| `options`?      | \{ `user`: `string`; } | Command options          |
| `options.user`? | `string`               | -                        |

###### Returns

`TemplateBuilder`

###### Implementation of

`TemplateBuilder`.`runCmd`

### setEnvs()

```ts theme={null}
setEnvs(envs: Record<string, string>): TemplateBuilder
```

Set environment variables.
Note: Environment variables defined here are available only during template build.

###### Parameters

| Parameter | Type                          | Description           |
| --------- | ----------------------------- | --------------------- |
| `envs`    | `Record`\<`string`, `string`> | Environment variables |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.setEnvs({ NODE_ENV: 'production', PORT: '8080' })
```

###### Implementation of

`TemplateBuilder`.`setEnvs`

### setReadyCmd()

```ts theme={null}
setReadyCmd(readyCommand: string | ReadyCmd): TemplateFinal
```

Set or update the ready check command.

###### Parameters

| Parameter      | Type                   | Description                |
| -------------- | ---------------------- | -------------------------- |
| `readyCommand` | `string` \| `ReadyCmd` | Command to check readiness |

###### Returns

`TemplateFinal`

###### Example

```ts theme={null}
// Using a string command
template.setReadyCmd('curl http://localhost:8000/health')

// Using ReadyCmd helpers
import { waitForPort, waitForFile, waitForProcess } from 'e2b'

template.setReadyCmd(waitForPort(3000))

template.setReadyCmd(waitForFile('/tmp/ready'))

template.setReadyCmd(waitForProcess('nginx'))
```

###### Implementation of

`TemplateBuilder`.`setReadyCmd`

### setStartCmd()

```ts theme={null}
setStartCmd(startCommand: string, readyCommand: string | ReadyCmd): TemplateFinal
```

Set the start command and ready check.

###### Parameters

| Parameter      | Type                   | Description                |
| -------------- | ---------------------- | -------------------------- |
| `startCommand` | `string`               | Command to run on startup  |
| `readyCommand` | `string` \| `ReadyCmd` | Command to check readiness |

###### Returns

`TemplateFinal`

###### Example

```ts theme={null}
// Using a string command
template.setStartCmd(
  'node app.js',
  'curl http://localhost:8000/health'
)

// Using ReadyCmd helpers
import { waitForPort, waitForURL } from 'e2b'

template.setStartCmd(
  'python -m http.server 8000',
  waitForPort(8000)
)

template.setStartCmd(
  'npm start',
  waitForURL('http://localhost:3000/health', 200)
)
```

###### Implementation of

`TemplateBuilder`.`setStartCmd`

### setUser()

```ts theme={null}
setUser(user: string): TemplateBuilder
```

Set the user for subsequent commands.

###### Parameters

| Parameter | Type     | Description |
| --------- | -------- | ----------- |
| `user`    | `string` | Username    |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.setUser('root')
```

###### Implementation of

`TemplateBuilder`.`setUser`

### setWorkdir()

```ts theme={null}
setWorkdir(workdir: PathLike): TemplateBuilder
```

Set the working directory.

###### Parameters

| Parameter | Type       | Description            |
| --------- | ---------- | ---------------------- |
| `workdir` | `PathLike` | Working directory path |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.setWorkdir('/app')
```

###### Implementation of

`TemplateBuilder`.`setWorkdir`

### skipCache()

```ts theme={null}
skipCache(): this
```

Skip cache for all subsequent build instructions from this point.

###### Returns

`this`

###### Example

```ts theme={null}
Template().skipCache().fromPythonImage('3')
```

###### Implementation of

`TemplateBuilder`.`skipCache`

### ~~aliasExists()~~

```ts theme={null}
static aliasExists(alias: string, options?: ConnectionOpts): Promise<boolean>
```

Check if a template with the given alias exists.

###### Parameters

| Parameter  | Type             | Description             |
| ---------- | ---------------- | ----------------------- |
| `alias`    | `string`         | Template alias to check |
| `options`? | `ConnectionOpts` | Authentication options  |

###### Returns

`Promise`\<`boolean`>

True if the alias exists, false otherwise

###### Deprecated

Use `exists` instead.

###### Example

```ts theme={null}
const exists = await Template.aliasExists('my-python-env')
if (exists) {
  console.log('Template exists!')
}
```

### assignTags()

```ts theme={null}
static assignTags(
   targetName: string, 
   tags: string | string[], 
options?: ConnectionOpts): Promise<TemplateTagInfo>
```

Assign tag(s) to an existing template build.

###### Parameters

| Parameter    | Type                    | Description                                                       |
| ------------ | ----------------------- | ----------------------------------------------------------------- |
| `targetName` | `string`                | Template name in 'name:tag' format (the source build to tag from) |
| `tags`       | `string` \| `string`\[] | Tag or tags to assign                                             |
| `options`?   | `ConnectionOpts`        | Authentication options                                            |

###### Returns

`Promise`\<`TemplateTagInfo`>

Tag info with buildId and assigned tags

###### Example

```ts theme={null}
// Assign a single tag
await Template.assignTags('my-template:v1.0', 'production')

// Assign multiple tags
await Template.assignTags('my-template:v1.0', ['production', 'stable'])
```

### build()

###### Call Signature

```ts theme={null}
static build(
   template: TemplateClass, 
   name: string, 
options?: Omit<BuildOptions, "alias">): Promise<BuildInfo>
```

Build and deploy a template to E2B infrastructure.

###### Parameters

| Parameter  | Type                               | Description                                  |
| ---------- | ---------------------------------- | -------------------------------------------- |
| `template` | `TemplateClass`                    | The template to build                        |
| `name`     | `string`                           | Template name in 'name' or 'name:tag' format |
| `options`? | `Omit`\<`BuildOptions`, `"alias"`> | Optional build configuration options         |

###### Returns

`Promise`\<`BuildInfo`>

###### Example

```ts theme={null}
const template = Template().fromPythonImage('3')

// Build with single tag in name
await Template.build(template, 'my-python-env:v1.0')

// Build with multiple tags
await Template.build(template, 'my-python-env', { tags: ['v1.0', 'stable'] })
```

###### Call Signature

```ts theme={null}
static build(template: TemplateClass, options: BuildOptions): Promise<BuildInfo>
```

Build and deploy a template to E2B infrastructure.

###### Parameters

| Parameter  | Type            | Description                                         |
| ---------- | --------------- | --------------------------------------------------- |
| `template` | `TemplateClass` | The template to build                               |
| `options`  | `BuildOptions`  | Build configuration options with alias (deprecated) |

###### Returns

`Promise`\<`BuildInfo`>

###### Deprecated

Use the overload with `name` parameter instead.

###### Example

```ts theme={null}
// Deprecated:
await Template.build(template, { alias: 'my-python-env' })

// Use instead:
await Template.build(template, 'my-python-env:v1.0')
```

### buildInBackground()

###### Call Signature

```ts theme={null}
static buildInBackground(
   template: TemplateClass, 
   name: string, 
options?: Omit<BuildOptions, "alias">): Promise<BuildInfo>
```

Build and deploy a template to E2B infrastructure without waiting for completion.

###### Parameters

| Parameter  | Type                               | Description                                  |
| ---------- | ---------------------------------- | -------------------------------------------- |
| `template` | `TemplateClass`                    | The template to build                        |
| `name`     | `string`                           | Template name in 'name' or 'name:tag' format |
| `options`? | `Omit`\<`BuildOptions`, `"alias"`> | Optional build configuration options         |

###### Returns

`Promise`\<`BuildInfo`>

###### Example

```ts theme={null}
const template = Template().fromPythonImage('3')

// Build with single tag in name
const data = await Template.buildInBackground(template, 'my-python-env:v1.0')

// Build with multiple tags
const data = await Template.buildInBackground(template, 'my-python-env', { tags: ['v1.0', 'stable'] })
```

###### Call Signature

```ts theme={null}
static buildInBackground(template: TemplateClass, options: BuildOptions): Promise<BuildInfo>
```

Build and deploy a template to E2B infrastructure without waiting for completion.

###### Parameters

| Parameter  | Type            | Description                                         |
| ---------- | --------------- | --------------------------------------------------- |
| `template` | `TemplateClass` | The template to build                               |
| `options`  | `BuildOptions`  | Build configuration options with alias (deprecated) |

###### Returns

`Promise`\<`BuildInfo`>

###### Deprecated

Use the overload with `name` parameter instead.

###### Example

```ts theme={null}
// Deprecated:
await Template.buildInBackground(template, { alias: 'my-python-env' })

// Use instead:
await Template.buildInBackground(template, 'my-python-env:v1.0')
```

### exists()

```ts theme={null}
static exists(name: string, options?: ConnectionOpts): Promise<boolean>
```

Check if a template with the given name exists.

###### Parameters

| Parameter  | Type             | Description            |
| ---------- | ---------------- | ---------------------- |
| `name`     | `string`         | Template name to check |
| `options`? | `ConnectionOpts` | Authentication options |

###### Returns

`Promise`\<`boolean`>

True if the name exists, false otherwise

###### Example

```ts theme={null}
const exists = await Template.exists('my-python-env')
if (exists) {
  console.log('Template exists!')
}
```

### getBuildStatus()

```ts theme={null}
static getBuildStatus(data: Pick<BuildInfo, "buildId" | "templateId">, options?: GetBuildStatusOptions): Promise<TemplateBuildStatusResponse>
```

Get the status of a build.

###### Parameters

| Parameter  | Type                                                | Description            |
| ---------- | --------------------------------------------------- | ---------------------- |
| `data`     | `Pick`\<`BuildInfo`, `"buildId"` \| `"templateId"`> | Build identifiers      |
| `options`? | `GetBuildStatusOptions`                             | Authentication options |

###### Returns

`Promise`\<`TemplateBuildStatusResponse`>

###### Example

```ts theme={null}
const status = await Template.getBuildStatus(data, { logsOffset: 0 })
```

### getTags()

```ts theme={null}
static getTags(templateId: string, options?: ConnectionOpts): Promise<TemplateTag[]>
```

Get all tags for a template.

###### Parameters

| Parameter    | Type             | Description            |
| ------------ | ---------------- | ---------------------- |
| `templateId` | `string`         | Template ID or name    |
| `options`?   | `ConnectionOpts` | Authentication options |

###### Returns

`Promise`\<`TemplateTag`\[]>

Array of tag details including tag name, buildId, and creation date

###### Example

```ts theme={null}
const tags = await Template.getTags('my-template')
for (const tag of tags) {
  console.log(`Tag: ${tag.tag}, Build: ${tag.buildId}, Created: ${tag.createdAt}`)
}
```

### removeTags()

```ts theme={null}
static removeTags(
   name: string, 
   tags: string | string[], 
options?: ConnectionOpts): Promise<void>
```

Remove tag(s) from a template.

###### Parameters

| Parameter  | Type                    | Description            |
| ---------- | ----------------------- | ---------------------- |
| `name`     | `string`                | Template name          |
| `tags`     | `string` \| `string`\[] | Tag or tags to remove  |
| `options`? | `ConnectionOpts`        | Authentication options |

###### Returns

`Promise`\<`void`>

###### Example

```ts theme={null}
// Remove a single tag
await Template.removeTags('my-template', 'production')

// Remove multiple tags from a template
await Template.removeTags('my-template', ['production', 'staging'])
```

### toDockerfile()

```ts theme={null}
static toDockerfile(template: TemplateClass): string
```

Convert a template to Dockerfile format.
Note: Templates based on other E2B templates cannot be converted to Dockerfile.

###### Parameters

| Parameter  | Type            | Description             |
| ---------- | --------------- | ----------------------- |
| `template` | `TemplateClass` | The template to convert |

###### Returns

`string`

Dockerfile string representation

###### Throws

Error if the template is based on another E2B template

### toJSON()

```ts theme={null}
static toJSON(template: TemplateClass, computeHashes: boolean): Promise<string>
```

Convert a template to JSON representation.

###### Parameters

| Parameter       | Type            | Default value | Description                                           |
| --------------- | --------------- | ------------- | ----------------------------------------------------- |
| `template`      | `TemplateClass` | `undefined`   | The template to convert                               |
| `computeHashes` | `boolean`       | `true`        | Whether to compute file hashes for cache invalidation |

###### Returns

`Promise`\<`string`>

JSON string representation of the template

## Interfaces

### TemplateBuilder

Main builder state for constructing templates.
Provides methods for customizing the template environment.

#### Methods

### addMcpServer()

```ts theme={null}
addMcpServer(servers: keyof McpServer | keyof McpServer[]): TemplateBuilder
```

Install MCP servers using mcp-gateway.
Note: Requires a base image with mcp-gateway pre-installed (e.g., mcp-gateway).

###### Parameters

| Parameter | Type                                  | Description        |
| --------- | ------------------------------------- | ------------------ |
| `servers` | keyof McpServer \| keyof McpServer\[] | MCP server name(s) |

###### Returns

`TemplateBuilder`

###### Throws

If the base template is not mcp-gateway

###### Example

```ts theme={null}
template.addMcpServer('exa')
template.addMcpServer(['brave', 'firecrawl', 'duckduckgo'])
```

### aptInstall()

```ts theme={null}
aptInstall(packages: string | string[], options?: object): TemplateBuilder
```

Install Debian/Ubuntu packages using apt-get.

###### Parameters

| Parameter                      | Type                                                            | Description     |
| ------------------------------ | --------------------------------------------------------------- | --------------- |
| `packages`                     | `string` \| `string`\[]                                         | Package name(s) |
| `options`?                     | \{ `fixMissing`: `boolean`; `noInstallRecommends`: `boolean`; } | -               |
| `options.fixMissing`?          | `boolean`                                                       | -               |
| `options.noInstallRecommends`? | `boolean`                                                       | -               |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.aptInstall('vim')
template.aptInstall(['git', 'curl', 'wget'])
template.aptInstall(['vim'], { noInstallRecommends: true })
template.aptInstall(['vim'], { fixMissing: true })
```

### betaDevContainerPrebuild()

```ts theme={null}
betaDevContainerPrebuild(devcontainerDirectory: string): TemplateBuilder
```

Prebuild a devcontainer from the specified directory.

###### Parameters

| Parameter               | Type     | Description                        |
| ----------------------- | -------- | ---------------------------------- |
| `devcontainerDirectory` | `string` | Path to the devcontainer directory |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template
 .gitClone('https://myrepo.com/project.git', '/my-devcontainer')
 .betaDevContainerPrebuild('/my-devcontainer')
```

### betaSetDevContainerStart()

```ts theme={null}
betaSetDevContainerStart(devcontainerDirectory: string): TemplateFinal
```

Start a devcontainer from the specified directory.

###### Parameters

| Parameter               | Type     | Description                        |
| ----------------------- | -------- | ---------------------------------- |
| `devcontainerDirectory` | `string` | Path to the devcontainer directory |

###### Returns

`TemplateFinal`

###### Example

```ts theme={null}
template
 .gitClone('https://myrepo.com/project.git', '/my-devcontainer')
 .startDevcontainer('/my-devcontainer')

// Prebuild and start
template
 .gitClone('https://myrepo.com/project.git', '/my-devcontainer')
 .betaDevContainerPrebuild('/my-devcontainer')
 // Other instructions...
 .betaSetDevContainerStart('/my-devcontainer')
```

### bunInstall()

```ts theme={null}
bunInstall(packages?: string | string[], options?: object): TemplateBuilder
```

Install Bun packages using bun.

###### Parameters

| Parameter      | Type                                   | Description                                   |
| -------------- | -------------------------------------- | --------------------------------------------- |
| `packages`?    | `string` \| `string`\[]                | Package name(s) or undefined for package.json |
| `options`?     | \{ `dev`: `boolean`; `g`: `boolean`; } | Install options                               |
| `options.dev`? | `boolean`                              | -                                             |
| `options.g`?   | `boolean`                              | -                                             |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.bunInstall('express')
template.bunInstall(['lodash', 'axios'])
template.bunInstall('tsx', { g: true })
template.bunInstall('typescript', { dev: true })
template.bunInstall()  // Installs from package.json
```

### copy()

```ts theme={null}
copy(
   src: PathLike | PathLike[], 
   dest: PathLike, 
   options?: object): TemplateBuilder
```

Copy files or directories into the template.

###### Parameters

| Parameter                  | Type                                                                                          | Description      |
| -------------------------- | --------------------------------------------------------------------------------------------- | ---------------- |
| `src`                      | `PathLike` \| `PathLike`\[]                                                                   | Source path(s)   |
| `dest`                     | `PathLike`                                                                                    | Destination path |
| `options`?                 | \{ `forceUpload`: `true`; `mode`: `number`; `resolveSymlinks`: `boolean`; `user`: `string`; } | Copy options     |
| `options.forceUpload`?     | `true`                                                                                        | -                |
| `options.mode`?            | `number`                                                                                      | -                |
| `options.resolveSymlinks`? | `boolean`                                                                                     | -                |
| `options.user`?            | `string`                                                                                      | -                |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.copy('requirements.txt', '/home/user/')
template.copy(['app.ts', 'config.ts'], '/app/', { mode: 0o755 })
```

### copyItems()

```ts theme={null}
copyItems(items: CopyItem[]): TemplateBuilder
```

Copy multiple items with individual options.

###### Parameters

| Parameter | Type          | Description         |
| --------- | ------------- | ------------------- |
| `items`   | `CopyItem`\[] | Array of copy items |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.copyItems([
  { src: 'app.ts', dest: '/app/' },
  { src: 'config.ts', dest: '/app/', mode: 0o644 }
])
```

### gitClone()

```ts theme={null}
gitClone(
   url: string, 
   path?: PathLike, 
   options?: object): TemplateBuilder
```

Clone a Git repository.

###### Parameters

| Parameter         | Type                                                          | Description               |
| ----------------- | ------------------------------------------------------------- | ------------------------- |
| `url`             | `string`                                                      | Repository URL            |
| `path`?           | `PathLike`                                                    | Optional destination path |
| `options`?        | \{ `branch`: `string`; `depth`: `number`; `user`: `string`; } | Clone options             |
| `options.branch`? | `string`                                                      | -                         |
| `options.depth`?  | `number`                                                      | -                         |
| `options.user`?   | `string`                                                      | -                         |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.gitClone('https://github.com/user/repo.git', '/app/repo')
template.gitClone('https://github.com/user/repo.git', undefined, {
  branch: 'main',
  depth: 1
})
template.gitClone('https://github.com/user/repo.git', '/app/repo', {
  user: 'root'
})
```

### makeDir()

```ts theme={null}
makeDir(path: PathLike | PathLike[], options?: object): TemplateBuilder
```

Create directories.

###### Parameters

| Parameter       | Type                                     | Description       |
| --------------- | ---------------------------------------- | ----------------- |
| `path`          | `PathLike` \| `PathLike`\[]              | Directory path(s) |
| `options`?      | \{ `mode`: `number`; `user`: `string`; } | Directory options |
| `options.mode`? | `number`                                 | -                 |
| `options.user`? | `string`                                 | -                 |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.makeDir('/app/data', { mode: 0o755 })
template.makeDir(['/app/logs', '/app/cache'])
template.makeDir('/app/data', { mode: 0o755, user: 'root' })
```

### makeSymlink()

```ts theme={null}
makeSymlink(
   src: PathLike, 
   dest: PathLike, 
   options?: object): TemplateBuilder
```

Create a symbolic link.

###### Parameters

| Parameter        | Type                                       | Description                         |
| ---------------- | ------------------------------------------ | ----------------------------------- |
| `src`            | `PathLike`                                 | Source path (target)                |
| `dest`           | `PathLike`                                 | Destination path (symlink location) |
| `options`?       | \{ `force`: `boolean`; `user`: `string`; } | Symlink options                     |
| `options.force`? | `boolean`                                  | -                                   |
| `options.user`?  | `string`                                   | -                                   |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.makeSymlink('/usr/bin/python3', '/usr/bin/python')
template.makeSymlink('/usr/bin/python3', '/usr/bin/python', { user: 'root' })
template.makeSymlink('/usr/bin/python3', '/usr/bin/python', { force: true })
```

### npmInstall()

```ts theme={null}
npmInstall(packages?: string | string[], options?: object): TemplateBuilder
```

Install Node.js packages using npm.

###### Parameters

| Parameter      | Type                                   | Description                                   |
| -------------- | -------------------------------------- | --------------------------------------------- |
| `packages`?    | `string` \| `string`\[]                | Package name(s) or undefined for package.json |
| `options`?     | \{ `dev`: `boolean`; `g`: `boolean`; } | Install options                               |
| `options.dev`? | `boolean`                              | -                                             |
| `options.g`?   | `boolean`                              | -                                             |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.npmInstall('express')
template.npmInstall(['lodash', 'axios'])
template.npmInstall('tsx', { g: true })
template.npmInstall('typescript', { dev: true })
template.npmInstall()  // Installs from package.json
```

### pipInstall()

```ts theme={null}
pipInstall(packages?: string | string[], options?: object): TemplateBuilder
```

Install Python packages using pip.

###### Parameters

| Parameter    | Type                    | Description                                                                                        |
| ------------ | ----------------------- | -------------------------------------------------------------------------------------------------- |
| `packages`?  | `string` \| `string`\[] | Package name(s) or undefined for current directory                                                 |
| `options`?   | \{ `g`: `boolean`; }    | Install options                                                                                    |
| `options.g`? | `boolean`               | Install globally as root (default: true). Set to false for user-only installation with --user flag |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.pipInstall('numpy')  // Installs globally (default)
template.pipInstall(['pandas', 'scikit-learn'])
template.pipInstall('numpy', { g: false })  // Install for user only
template.pipInstall()  // Installs from current directory
```

### remove()

```ts theme={null}
remove(path: PathLike | PathLike[], options?: object): TemplateBuilder
```

Remove files or directories.

###### Parameters

| Parameter            | Type                                                               | Description       |
| -------------------- | ------------------------------------------------------------------ | ----------------- |
| `path`               | `PathLike` \| `PathLike`\[]                                        | Path(s) to remove |
| `options`?           | \{ `force`: `boolean`; `recursive`: `boolean`; `user`: `string`; } | Remove options    |
| `options.force`?     | `boolean`                                                          | -                 |
| `options.recursive`? | `boolean`                                                          | -                 |
| `options.user`?      | `string`                                                           | -                 |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.remove('/tmp/cache', { recursive: true, force: true })
template.remove('/tmp/cache', { recursive: true, force: true, user: 'root' })
```

### rename()

```ts theme={null}
rename(
   src: PathLike, 
   dest: PathLike, 
   options?: object): TemplateBuilder
```

Rename or move a file or directory.

###### Parameters

| Parameter        | Type                                       | Description      |
| ---------------- | ------------------------------------------ | ---------------- |
| `src`            | `PathLike`                                 | Source path      |
| `dest`           | `PathLike`                                 | Destination path |
| `options`?       | \{ `force`: `boolean`; `user`: `string`; } | Rename options   |
| `options.force`? | `boolean`                                  | -                |
| `options.user`?  | `string`                                   | -                |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.rename('/tmp/old.txt', '/tmp/new.txt')
template.rename('/tmp/old.txt', '/tmp/new.txt', { user: 'root' })
```

### runCmd()

###### Call Signature

```ts theme={null}
runCmd(command: string, options?: object): TemplateBuilder
```

Run a shell command.

###### Parameters

| Parameter       | Type                   | Description     |
| --------------- | ---------------------- | --------------- |
| `command`       | `string`               | Command string  |
| `options`?      | \{ `user`: `string`; } | Command options |
| `options.user`? | `string`               | -               |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.runCmd('apt-get update')
template.runCmd(['pip install numpy', 'pip install pandas'])
template.runCmd('apt-get install vim', { user: 'root' })
```

###### Call Signature

```ts theme={null}
runCmd(commands: string[], options?: object): TemplateBuilder
```

Run multiple shell commands.

###### Parameters

| Parameter       | Type                   | Description              |
| --------------- | ---------------------- | ------------------------ |
| `commands`      | `string`\[]            | Array of command strings |
| `options`?      | \{ `user`: `string`; } | Command options          |
| `options.user`? | `string`               | -                        |

###### Returns

`TemplateBuilder`

###### Call Signature

```ts theme={null}
runCmd(commandOrCommands: string | string[], options?: object): TemplateBuilder
```

Run command(s).

###### Parameters

| Parameter           | Type                    | Description         |
| ------------------- | ----------------------- | ------------------- |
| `commandOrCommands` | `string` \| `string`\[] | Command or commands |
| `options`?          | \{ `user`: `string`; }  | Command options     |
| `options.user`?     | `string`                | -                   |

###### Returns

`TemplateBuilder`

### setEnvs()

```ts theme={null}
setEnvs(envs: Record<string, string>): TemplateBuilder
```

Set environment variables.
Note: Environment variables defined here are available only during template build.

###### Parameters

| Parameter | Type                          | Description           |
| --------- | ----------------------------- | --------------------- |
| `envs`    | `Record`\<`string`, `string`> | Environment variables |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.setEnvs({ NODE_ENV: 'production', PORT: '8080' })
```

### setReadyCmd()

```ts theme={null}
setReadyCmd(readyCommand: string | ReadyCmd): TemplateFinal
```

Set or update the ready check command.

###### Parameters

| Parameter      | Type                   | Description                |
| -------------- | ---------------------- | -------------------------- |
| `readyCommand` | `string` \| `ReadyCmd` | Command to check readiness |

###### Returns

`TemplateFinal`

###### Example

```ts theme={null}
// Using a string command
template.setReadyCmd('curl http://localhost:8000/health')

// Using ReadyCmd helpers
import { waitForPort, waitForFile, waitForProcess } from 'e2b'

template.setReadyCmd(waitForPort(3000))

template.setReadyCmd(waitForFile('/tmp/ready'))

template.setReadyCmd(waitForProcess('nginx'))
```

### setStartCmd()

```ts theme={null}
setStartCmd(startCommand: string, readyCommand: string | ReadyCmd): TemplateFinal
```

Set the start command and ready check.

###### Parameters

| Parameter      | Type                   | Description                |
| -------------- | ---------------------- | -------------------------- |
| `startCommand` | `string`               | Command to run on startup  |
| `readyCommand` | `string` \| `ReadyCmd` | Command to check readiness |

###### Returns

`TemplateFinal`

###### Example

```ts theme={null}
// Using a string command
template.setStartCmd(
  'node app.js',
  'curl http://localhost:8000/health'
)

// Using ReadyCmd helpers
import { waitForPort, waitForURL } from 'e2b'

template.setStartCmd(
  'python -m http.server 8000',
  waitForPort(8000)
)

template.setStartCmd(
  'npm start',
  waitForURL('http://localhost:3000/health', 200)
)
```

### setUser()

```ts theme={null}
setUser(user: string): TemplateBuilder
```

Set the user for subsequent commands.

###### Parameters

| Parameter | Type     | Description |
| --------- | -------- | ----------- |
| `user`    | `string` | Username    |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.setUser('root')
```

### setWorkdir()

```ts theme={null}
setWorkdir(workdir: PathLike): TemplateBuilder
```

Set the working directory.

###### Parameters

| Parameter | Type       | Description            |
| --------- | ---------- | ---------------------- |
| `workdir` | `PathLike` | Working directory path |

###### Returns

`TemplateBuilder`

###### Example

```ts theme={null}
template.setWorkdir('/app')
```

### skipCache()

```ts theme={null}
skipCache(): this
```

Skip cache for all subsequent build instructions from this point.

###### Returns

`this`

###### Example

```ts theme={null}
template.skipCache().runCmd('apt-get update')
```

## Type Aliases

### BuildInfo

```ts theme={null}
type BuildInfo = object;
```

Information about a built template.

#### Type declaration

| Name                               | Type        | Description                                                                                 |
| ---------------------------------- | ----------- | ------------------------------------------------------------------------------------------- |
| <a id="alias" /> `alias`           | `string`    | First alias from the build (for backward compatibility). **Deprecated** Use `name` instead. |
| <a id="buildid" /> `buildId`       | `string`    | Build identifier.                                                                           |
| <a id="name" /> `name`             | `string`    | Name of the template.                                                                       |
| <a id="tags" /> `tags`             | `string`\[] | Tags assigned to this build.                                                                |
| <a id="templateid" /> `templateId` | `string`    | Template identifier.                                                                        |

***

### BuildOptions

```ts theme={null}
type BuildOptions = ConnectionOpts & BasicBuildOptions;
```

Options for building a template with authentication.

***

### BuildStatusReason

```ts theme={null}
type BuildStatusReason = object;
```

Reason for the current build status (typically for errors).

#### Type declaration

| Name                               | Type          | Description                               |
| ---------------------------------- | ------------- | ----------------------------------------- |
| <a id="logentries" /> `logEntries` | `LogEntry`\[] | Log entries related to the status reason. |
| <a id="message" /> `message`       | `string`      | Message with the status reason.           |
| <a id="step" /> `step`?            | `string`      | Step that failed.                         |

***

### CopyItem

```ts theme={null}
type CopyItem = object;
```

Configuration for a single file/directory copy operation.

#### Type declaration

| Name                                          | Type                        |
| --------------------------------------------- | --------------------------- |
| <a id="dest" /> `dest`                        | `PathLike`                  |
| <a id="forceupload" /> `forceUpload`?         | `true`                      |
| <a id="mode" /> `mode`?                       | `number`                    |
| <a id="resolvesymlinks" /> `resolveSymlinks`? | `boolean`                   |
| <a id="src" /> `src`                          | `PathLike` \| `PathLike`\[] |
| <a id="user" /> `user`?                       | `string`                    |

***

### GetBuildStatusOptions

```ts theme={null}
type GetBuildStatusOptions = ConnectionOpts & object;
```

Options for getting build status.

#### Type declaration

| Name          | Type     |
| ------------- | -------- |
| `logsOffset`? | `number` |

***

### McpServerName

```ts theme={null}
type McpServerName = keyof McpServer;
```

MCP server names that can be installed.

***

### TemplateBuildStatus

```ts theme={null}
type TemplateBuildStatus = "building" | "waiting" | "ready" | "error";
```

Status of a template build.

***

### TemplateBuildStatusResponse

```ts theme={null}
type TemplateBuildStatusResponse = object;
```

Response from getting build status.

#### Type declaration

| Name                                 | Type                  | Description                                                        |
| ------------------------------------ | --------------------- | ------------------------------------------------------------------ |
| <a id="buildid-1" /> `buildID`       | `string`              | Build identifier.                                                  |
| <a id="logentries-1" /> `logEntries` | `LogEntry`\[]         | Build log entries.                                                 |
| <a id="logs" /> `logs`               | `string`\[]           | Build logs (raw strings). **Deprecated** Use `logEntries` instead. |
| <a id="reason" /> `reason`?          | `BuildStatusReason`   | Reason for the current status (typically for errors).              |
| <a id="status" /> `status`           | `TemplateBuildStatus` | Current status of the build.                                       |
| <a id="templateid-1" /> `templateID` | `string`              | Template identifier.                                               |

***

### TemplateClass

```ts theme={null}
type TemplateClass = TemplateBuilder | TemplateFinal;
```

Type representing a template in any state (builder or final).

***

### TemplateTag

```ts theme={null}
type TemplateTag = object;
```

Detailed information about a single template tag.

#### Type declaration

| Name                             | Type     | Description                                |
| -------------------------------- | -------- | ------------------------------------------ |
| <a id="buildid-2" /> `buildId`   | `string` | Build identifier associated with this tag. |
| <a id="createdat" /> `createdAt` | `Date`   | When this tag was assigned.                |
| <a id="tag" /> `tag`             | `string` | Name of the tag.                           |

***

### TemplateTagInfo

```ts theme={null}
type TemplateTagInfo = object;
```

Information about assigned template tags.

#### Type declaration

| Name                           | Type        | Description                                |
| ------------------------------ | ----------- | ------------------------------------------ |
| <a id="buildid-3" /> `buildId` | `string`    | Build identifier associated with this tag. |
| <a id="tags-1" /> `tags`       | `string`\[] | Assigned tags of the template.             |

## Functions

### Template()

```ts theme={null}
function Template(options?: TemplateOptions): TemplateFromImage
```

Create a new E2B template builder instance.

#### Parameters

| Parameter  | Type              | Description                                     |
| ---------- | ----------------- | ----------------------------------------------- |
| `options`? | `TemplateOptions` | Optional configuration for the template builder |

#### Returns

`TemplateFromImage`

A new template builder instance

#### Example

```ts theme={null}
import { Template } from 'e2b'

const template = Template()
  .fromPythonImage('3')
  .copy('requirements.txt', '/app/')
  .pipInstall()

await Template.build(template, 'my-python-app:v1.0')
```
