File: README.md
What is E2B?
E2B is an open-source infrastructure that allows you to run AI-generated code in secure isolated sandboxes in the cloud. To start and control sandboxes, use our JavaScript SDK or Python SDK.
Run your first Sandbox
1. Install SDK
JavaScript / TypeScript
npm i e2bPython
pip install e2b2. Get your E2B API key
E2B_API_KEY=e2b_***3. Start a sandbox and run commands
JavaScript / TypeScript
import Sandbox from 'e2b'
const sandbox = await Sandbox.create()
const result = await sandbox.commands.run('echo "Hello from E2B!"')
console.log(result.stdout) // Hello from E2B!Python
from e2b import Sandbox
with Sandbox.create() as sandbox:
result = sandbox.commands.run('echo "Hello from E2B!"')
print(result.stdout) # Hello from E2B!4. Code execution with Code Interpreter
If you need to execute code with runCode()/run_code(), install the Code Interpreter SDK (JavaScript / Python):
npm i @e2b/code-interpreter # JavaScript/TypeScript
pip install e2b-code-interpreter # Pythonimport { Sandbox } from '@e2b/code-interpreter'
const sandbox = await Sandbox.create()
const execution = await sandbox.runCode('x = 1; x += 1; x')
console.log(execution.text) // outputs 25. Computer use with Desktop
For mouse, keyboard, screenshot, application, and desktop streaming APIs, install the Desktop SDK (JavaScript / Python):
npm i @e2b/desktop # JavaScript/TypeScript
pip install e2b-desktop # Pythonimport { Sandbox } from '@e2b/desktop'
const desktop = await Sandbox.create()
await desktop.launch('google-chrome')
const screenshot = await desktop.screenshot()6. Check docs
Visit E2B documentation.
7. E2B cookbook
Visit our Cookbook to get inspired by examples with different LLMs and AI frameworks.
Self-hosting
Read the self-hosting guide to learn how to set up the E2B infrastructure on your own. The infrastructure is deployed using Terraform.
Supported cloud providers:
- ๐ข AWS
- ๐ข Google Cloud (GCP)
- Azure
- General Linux machine
File: packages/python-sdk/README.md
What is E2B?
E2B is an open-source infrastructure that allows you to run AI-generated code in secure isolated sandboxes in the cloud. To start and control sandboxes, use our JavaScript SDK or Python SDK.
Run your first Sandbox
1. Install SDK
pip install e2b2. Get your E2B API key
E2B_API_KEY=e2b_***3. Start a sandbox and run commands
from e2b import Sandbox
with Sandbox.create() as sandbox:
result = sandbox.commands.run('echo "Hello from E2B!"')
print(result.stdout) # Hello from E2B!4. Bind the configuration to a client
The top-level Sandbox, AsyncSandbox, Volume, AsyncVolume, Template, AsyncTemplate and Secret exports read their configuration from the environment variables. To use an explicit configuration โ e.g. several API keys or domains in one process โ create an E2B client and use the resource classes it exposes:
from e2b import E2B
client = E2B(api_key="e2b_***", domain="e2b.dev")
sandbox = client.Sandbox.create()
volume = client.Volume.create("my-volume")
exists = client.Template.exists("my-template")
secret = client.Secret.create("openai-api-key", "sk-***")
# The async variants are exposed as well.
async_sandbox = await client.AsyncSandbox.create()
# The classes can be assigned and used like the top-level ones.
Sandbox = client.Sandbox
paginator = Sandbox.list()Per-call params still take precedence over the client's params, and clients are isolated from each other and from the env-configured top-level exports.
High-concurrency sandbox streams
The Python SDK spreads sandbox commands and files traffic across four HTTP/2 connection pools by default. This prevents long-running streams in one process from all contending for a single connection's concurrent-stream limit.
If one process needs more capacity, set E2B_ENVD_POOL_SHARDS before importing e2b. Each additional shard can open another connection to the sandbox host, so increase it only as needed:
E2B_ENVD_POOL_SHARDS=8 python eval.py5. Code execution with Code Interpreter
If you need run_code(), install the Code Interpreter SDK:
pip install e2b-code-interpreterfrom e2b_code_interpreter import Sandbox
with Sandbox.create() as sandbox:
execution = sandbox.run_code("x = 1; x += 1; x")
print(execution.text) # outputs 26. Check docs
Visit E2B documentation.
7. E2B cookbook
Visit our Cookbook to get inspired by examples with different LLMs and AI frameworks.
File: packages/js-sdk/README.md
What is E2B?
E2B is an open-source infrastructure that allows you to run AI-generated code in secure isolated sandboxes in the cloud. To start and control sandboxes, use our JavaScript SDK or Python SDK.
Run your first Sandbox
1. Install SDK
npm i e2b2. Get your E2B API key
E2B_API_KEY=e2b_***3. Start a sandbox and run commands
import { Sandbox } from 'e2b'
const sandbox = await Sandbox.create()
const result = await sandbox.commands.run('echo "Hello from E2B!"')
console.log(result.stdout) // Hello from E2B!4. Bind the configuration to a client
The top-level Sandbox, Volume, Template and Secret exports read their configuration from the environment variables. To use an explicit configuration โ e.g. several API keys or domains in one process โ create an E2B client and use the resources it exposes:
import { E2B } from 'e2b'
const client = new E2B({ apiKey: 'e2b_***', domain: 'e2b.dev' })
const sandbox = await client.Sandbox.create()
const volume = await client.Volume.create('my-volume')
const exists = await client.Template.exists('my-template')
await client.Secret.create('openai-api-key', 'sk-***')
// The classes can be destructured and used like the top-level ones.
const { Sandbox } = client
const paginator = Sandbox.list()Per-call options still take precedence over the client's options, and clients are isolated from each other and from the env-configured top-level exports.
5. Code execution with Code Interpreter
If you need runCode(), install the Code Interpreter SDK:
npm i @e2b/code-interpreterimport { Sandbox } from '@e2b/code-interpreter'
const sandbox = await Sandbox.create()
const execution = await sandbox.runCode('x = 1; x += 1; x')
console.log(execution.text) // outputs 26. Check docs
Visit E2B documentation.
7. E2B cookbook
Visit our Cookbook to get inspired by examples with different LLMs and AI frameworks.
File: packages/cli/README.md
E2B CLI
This CLI tool allows you to build manager your running E2B sandbox and sandbox templates. Learn more in our documentation.
1. Install the CLI
Using Homebrew (on macOS)
brew install e2bUsing NPM
npm install @e2b/cli2. Authenticate
e2b auth login[!NOTE]
To authenticate without the ability to open the browser (e.g. in CI/CD),
provideE2B_API_KEYas an environment variable. You can find your API key
in the API Keys tab in the E2B dashboard.
Then use the CLI like this:E2B_API_KEY=e2b_... e2b template create.
3. Check out docs
Visit our CLI documentation to learn more.