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

# SDK client

> Create a custom client with options

The top-level `Sandbox`, `Volume`, and `Template` exports read their configuration from the environment variables (`E2B_API_KEY`, `E2B_DOMAIN`, …). If you need an explicit configuration — for example several API keys, teams, or [self-hosted deployments](/byoc) in a single process — create an `E2B` client and use the resources it exposes.

<Note>
  Per-call options take precedence over the client's options, which take precedence over the environment variables.
</Note>

<CodeGroup>
  ```js JavaScript & TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
  import { E2B } from 'e2b'

  const client = new E2B({ apiKey: 'YOUR_API_KEY', domain: 'e2b.app' })

  const sandbox = await client.Sandbox.create()
  const result = await sandbox.commands.run('echo "Hello from E2B!"')
  console.log(result.stdout) // Hello from E2B!
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
  from e2b import E2B

  client = E2B(api_key="YOUR_API_KEY", domain="e2b.app")

  sandbox = client.Sandbox.create()
  result = sandbox.commands.run('echo "Hello from E2B!"')
  print(result.stdout)  # Hello from E2B!
  ```

  ```python Python (async) theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
  from e2b import E2B

  client = E2B(api_key="YOUR_API_KEY", domain="e2b.app")

  sandbox = await client.AsyncSandbox.create()
  result = await sandbox.commands.run('echo "Hello from E2B!"')
  print(result.stdout)  # Hello from E2B!
  ```
</CodeGroup>

The classes exposed by the client behave exactly like the top-level exports of the same name — only the defaults change. You can also destructure them and use them as usual.

<CodeGroup>
  ```js JavaScript & TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
  const { Sandbox, Volume, Template } = new E2B({ apiKey: 'YOUR_API_KEY' })

  const sandbox = await Sandbox.create()
  const volume = await Volume.create('my-volume')
  const exists = await Template.exists('my-template')
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
  client = E2B(api_key="YOUR_API_KEY")
  Sandbox, Volume, Template = (
      client.Sandbox,
      client.Volume,
      client.Template,
  )

  sandbox = Sandbox.create()
  volume = Volume.create("my-volume")
  exists = Template.exists("my-template")
  ```

  ```python Python (async) theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
  client = E2B(api_key="YOUR_API_KEY")
  Sandbox, Volume, Template = (
      client.AsyncSandbox,
      client.AsyncVolume,
      client.AsyncTemplate,
  )

  sandbox = await Sandbox.create()
  volume = await Volume.create("my-volume")
  exists = await Template.exists("my-template")
  ```
</CodeGroup>

## Client options

The client accepts the same options as the individual SDK calls, for example `apiKey`/`api_key`, `domain`, `requestTimeoutMs`/`request_timeout`, `proxy`, `apiHeaders`/`api_headers`, and `logger`.

In JavaScript, the only exception is `signal`: it cancels a single in-flight request, so it can only be passed per call.

## Multiple clients

Clients are isolated from each other and from the env-configured top-level exports, so you can use as many of them side by side as you need.

<CodeGroup>
  ```js JavaScript & TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
  import { E2B, Sandbox } from 'e2b'

  const production = new E2B({ apiKey: 'PRODUCTION_API_KEY' })
  const staging = new E2B({ apiKey: 'STAGING_API_KEY', domain: 'e2b-staging.dev' })

  await production.Sandbox.create()
  await staging.Sandbox.create()

  // Still uses the E2B_API_KEY environment variable.
  await Sandbox.create()
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
  from e2b import E2B, Sandbox

  production = E2B(api_key="PRODUCTION_API_KEY")
  staging = E2B(api_key="STAGING_API_KEY", domain="e2b-staging.dev")

  production.Sandbox.create()
  staging.Sandbox.create()

  # Still uses the E2B_API_KEY environment variable.
  Sandbox.create()
  ```

  ```python Python (async) theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
  from e2b import E2B, AsyncSandbox

  production = E2B(api_key="PRODUCTION_API_KEY")
  staging = E2B(api_key="STAGING_API_KEY", domain="e2b-staging.dev")

  await production.AsyncSandbox.create()
  await staging.AsyncSandbox.create()

  # Still uses the E2B_API_KEY environment variable.
  await AsyncSandbox.create()
  ```
</CodeGroup>
