Skip to main content
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 in a single process — create an E2B client and use the resources it exposes.
Per-call options take precedence over the client’s options, which take precedence over the environment variables.
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.

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.

Multiple regions

Regions do not share state. A project and its API key belong to exactly one region, and the sandboxes, templates, and volumes it owns exist only there. Two things to plan for:
  • Build your own templates once per region. There is no way to copy a template between regions, so run Template.build through each region’s client. The same template name in every region is fine.
  • A sandbox ID only resolves in its own region. Connect to a sandbox, list it, or kill it through the client for the region that created it.
If a single process only ever talks to one region, you do not need a client at all. Set E2B_API_KEY and E2B_DOMAIN to that region’s values and keep using the top-level exports. E2B’s managed cloud runs in three regions: US, EU, and APAC. US is the default on every plan. EU and APAC are available on the Pro plan and above, and are enabled for your account by support. See EU region and Egress IP ranges for more on where sandboxes run. There is no region option. Each region is a separate deployment with its own API endpoint, so you select one by pointing a client at that region’s domain. When support enables a region, they give you its domain and help you create a project there. That project has its own API key, so a multiregion setup is one client per region, each with its own key and domain.