Home / Docs / Quickstart · also: Limits

Quickstart

The API is E2B-compatible: if your code already uses the E2B SDK, only the endpoint and key change for the supported calls. Some E2B features are not supported yet (see Unsupported E2B features).

1. Point the SDK at us

# shell env — or set the same vars in code. The SDK derives
# the API endpoint (https://api.<domain>) and the sandbox hosts
# (<port>-<id>.<domain>) from E2B_DOMAIN.
export E2B_DOMAIN="sbx.agent-next.com"
export E2B_API_KEY="e2b_your_key"   # collected in the console once you are approved

Approved on the waitlist? Open your claim link in the console to collect your key (shown once), then paste it there to see your credit, running sandboxes and usage.

2. Python

pip install e2b==2.40.0   # pinned — see "SDK versions" below
from e2b import Sandbox

sbx = Sandbox.create()                    # default template

# run commands — stdout / stderr / exit code, streaming supported
out = sbx.commands.run("uname -a")
print(out.stdout)

# read & write files (text or binary)
sbx.files.write("/tmp/hello.txt", "hi")
print(sbx.files.read("/tmp/hello.txt"))

# pause keeps memory and processes; any call auto-resumes (~160 ms)
sbx.pause()
sbx = Sandbox.connect(sbx.sandbox_id)

sbx.kill()

3. JavaScript / TypeScript

npm install e2b@2.26.0
import { Sandbox } from "e2b";

const sbx = await Sandbox.create();

const out = await sbx.commands.run("uname -a");
console.log(out.stdout);

await sbx.files.write("/tmp/hello.txt", "hi");
console.log(await sbx.files.read("/tmp/hello.txt"));

await sbx.pause();
const again = await Sandbox.connect(sbx.sandboxId);  // auto-resumes

await sbx.kill();

4. OpenAI Agents SDK — E2BSandboxClient

The Agents SDK's sandbox integration talks E2B, so it picks up the same env vars.

pip install "openai-agents[e2b]" e2b==2.40.0
import asyncio
from agents import Runner
from agents.run import RunConfig
from agents.sandbox import SandboxAgent, SandboxRunConfig
from agents.extensions.sandbox import (
    E2BSandboxClient, E2BSandboxClientOptions, E2BSandboxType,
)

async def main():
    client = E2BSandboxClient()
    session = await client.create(
        options=E2BSandboxClientOptions(
            sandbox_type=E2BSandboxType.E2B,
            timeout=900,
            pause_on_exit=True,     # keep the sandbox after the script exits
        )
    )
    try:
        agent = SandboxAgent(
            name="Workspace Inspector",
            model="gpt-5",
            instructions="Inspect the workspace and summarize the project.",
        )
        result = await Runner.run(
            agent,
            "List the files in the workspace and summarize.",
            run_config=RunConfig(sandbox=SandboxRunConfig(session=session)),
        )
        print(result.final_output)
    finally:
        await session.shutdown()

asyncio.run(main())

SDK versions

SDKVerified withNotes
Pythonpip install e2b==2.40.0verified end to end
JS / TSnpm install e2b@2.26.0conformance-tested against the backend; not yet run through the gateway
OpenAI Agents SDKpip install "openai-agents[e2b]"uses the e2b SDK underneath

/v2 is supported: e2b Python ≥ 2.51 speaks the /v2 API (POST/GET /v2/sandboxes, POST /v2/sandboxes/{id}/connect) and works without a pin. The Python version above is the one we verify end to end — pin it if you want exactly what we test.

Unsupported E2B features

The gateway does not implement these yet; calls that use them are rejected or have no route: snapshots, fork, update_network (and the network create option), template tags, mcp, volumes (volumeMounts) and iam.

Next: coding agents · personal agents (OpenClaw) · limits and network policy · measured performance