# API key Source: https://docs.e2b.dev/api-key To use the API key, you can either: * **Set the API key as the `E2B_API_KEY` environment variable** to avoid passing it each time you create a sandbox. * Or pass it directly to `Sandbox.create` as shown below: ```js JavaScript & TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-default"}} import { Sandbox } from 'e2b' const sandbox = await Sandbox.create({ apiKey: 'YOUR_API_KEY' }) ``` ```python Python theme={"theme":{"light":"github-light","dark":"github-dark-default"}} from e2b import Sandbox sbx = Sandbox.create(api_key="YOUR_API_KEY") ``` ## Where to find API key You can get your API key at console. The same API key authenticates both the SDKs and the [CLI](/cli/auth). # Billing & limits Source: https://docs.e2b.dev/billing E2B plans, limits, and usage-based pricing. Covers the Hobby, Pro, and Enterprise plan table (max continuous runtime, concurrent sandboxes, vCPU, memory, disk), API rate limits, and how per-second compute billing works. E2B uses [usage-based pricing](#usage-based-pricing) - you pay only for what you use. New users receive \$100 in free credits to get started. [Manage billing in console](https://console.e2b.dev/?tab=billing) ## Plans | Feature | Hobby | Pro | Enterprise | | :- | - | - | - | | **Base price** | \$0/month | \$150/month | Custom | | **Free credits** | \$100 (one-time) | No additional credits | Custom | | **Max vCPUs** | 8 | 8+ | Custom | | **Max memory** | 8 GiB | 8+ GiB | Custom | | **Disk size** | 10 GiB | 20+ GiB | Custom | | **Max continuous runtime** | 1 hour | 24 hours | Custom | | **Concurrent sandboxes** | 20 | 100 - 1,100 | 1,100+ | | **Concurrent builds** | 20 | 20 | Custom | | **Sandbox creation rate** | 1 / sec | 5 / sec | Custom | | **Paused sandbox retention** | Unlimited | Unlimited | Unlimited | | **[Secrets](/secrets) per project** | 10 | 100 | 100 | Max continuous runtime is the time a sandbox can run **without being paused**, not a cap on how long a sandbox can exist. Pausing and resuming resets it, and a paused sandbox is kept indefinitely with no time-to-live. See [How long does a sandbox live?](/faq/sandbox-lifetime). To upgrade your plan or purchase add-ons, visit the [console billing tab](https://console.e2b.dev/?tab=billing). For Enterprise plans, [contact sales](mailto:enterprise@e2b.dev). *** ## API rate limits E2B applies rate limits to API requests. The following default limits are in **requests per second, per project, per endpoint**:
| Endpoint | Hobby | Pro | Enterprise | | :- | -: | -: | -: | | [`GET /sandboxes`](/api-reference/sandboxes/list-sandboxes) | 10 | 20 | Custom | | [`GET /v2/sandboxes`](/api-reference/sandboxes/list-sandboxes-v2) | 10 | 20 | Custom | | [`GET /sandboxes/metrics`](/api-reference/sandboxes/list-sandbox-metrics) | 10 | 20 | Custom | | [`GET /snapshots`](/api-reference/sandboxes/list-snapshots) | 10 | 20 | Custom | | [`GET /templates`](/api-reference/templates/list-templates) | 10 | 20 | Custom | | [`GET /v2/templates`](/api-reference/templates/list-templates-v2) | 10 | 20 | Custom | | [`GET /templates/{templateID}`](/api-reference/templates/get-template) | 10 | 20 | Custom | | [`GET /templates/{templateID}/tags`](/api-reference/tags/list-template-tags) | 10 | 20 | Custom | | [`GET /api-keys`](/api-key) | 10 | 20 | Custom | | [`GET /volumes`](/api-reference/volumes/list-team-volumes) | 10 | 20 | Custom | | [`GET /secrets`](/api-reference/secrets/list-secrets) | 10 | 20 | Custom |
Enterprise plans come with API rate limits sized to your workload. [Book a call](https://e2b.dev/contact) with our team or contact us at [enterprise@e2b.dev](mailto:enterprise@e2b.dev) to discuss your limits. You share each endpoint's limit across all API keys and clients in your [project](/projects). Requests to one endpoint do not consume another endpoint's allowance. For endpoints with a path parameter, such as `/templates/{templateID}`, requests for different template IDs share the same allowance. These limits include requests made through the SDKs and CLI. Each request for a page of results counts toward the limit. ### Exceeding a limit If you exceed a limit, you receive an HTTP `429 Too Many Requests` response with a `Retry-After` header. Starting with version **2.49.1**, the E2B JavaScript and Python SDKs automatically retry these requests using the `Retry-After` delay. If you handle retries yourself, wait the number of seconds in `Retry-After` before retrying the request. ### Requesting a higher limit To request a higher API rate limit, contact [support@e2b.dev](mailto:support@e2b.dev). For custom limits on the Enterprise plan, [contact sales](mailto:enterprise@e2b.dev). *** ## Usage-based pricing You pay per second for compute resources while your sandbox is running. Upgrading to the Pro tier does not grant additional credits. It only increases the limits available to your project (such as concurrent sandboxes, continuous runtime, and resource ceilings). ### Compute costs Use the [usage cost calculator](https://e2b.dev/pricing#:~:text=Usage%20Cost%20Calculator) on our pricing page to estimate costs for your specific configuration. ### Customizing compute resources You can customize allocated CPU and RAM when building custom templates by specifying `cpuCount` and `memoryMB` in the build configuration. ```js JavaScript & TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-default"}} import { Template, defaultBuildLogger } from 'e2b' await Template.build(template, 'my-template', { cpuCount: 8, memoryMB: 4096, onBuildLogs: defaultBuildLogger(), }) ``` ```python Python theme={"theme":{"light":"github-light","dark":"github-dark-default"}} from e2b import Template, default_build_logger Template.build( template, 'my-template', cpu_count=8, memory_mb=4096, on_build_logs=default_build_logger(), ) ``` See [template quickstart](/template/quickstart) for more details on building custom templates. Need higher CPU or RAM limits? Contact [support@e2b.dev](mailto:support@e2b.dev) for more information. *** ## Monitoring usage Check your usage and costs in the [console usage tab](https://console.e2b.dev/?tab=usage). *** ## FAQ Automatically at the start of the month for the previous month's usage. Your account will be blocked. Add a payment method to continue using E2B. Yes, you can set spending limits on the [budget page](https://console.e2b.dev/?tab=budget) in your dashboard. * **Enable auto-pause** - Automatically pause sandboxes after a period of inactivity to stop billing while preserving state * **Pause sandboxes when idle** - Use `sbx.pause()` to stop billing while keeping state available for later * **Kill sandboxes you no longer need** - Use `sbx.kill()` to stop billing and release resources permanently * **Allocate only what you need** - Start with default resources (2 vCPU, 512 MiB RAM) and increase only if necessary * **Monitor actively running sandboxes** - Use the [CLI](/cli/list-sandboxes) or [console](https://console.e2b.dev/?tab=usage) to track active sandboxes * **Use lifecycle events** - Set up [webhooks](/sandbox/lifecycle-events-webhooks) to get notified when sandboxes are created No. You only pay while a sandbox is actively running. Once a sandbox is paused, killed or times out, billing stops immediately. # E2B CLI Source: https://docs.e2b.dev/cli E2B CLI is a command line tool that allows you to manage and interact with sandboxes and [templates](/template/quickstart). ## Installation **Using Homebrew (on macOS)** ```bash Terminal theme={"theme":{"light":"github-light","dark":"github-dark-default"}} brew install e2b ``` **Using NPM** You can install E2B CLI using the following command: ```bash Terminal theme={"theme":{"light":"github-light","dark":"github-dark-default"}} npm i -g @e2b/cli ``` # Authentication in CLI Source: https://docs.e2b.dev/cli/auth There are two ways to authenticate with the E2B CLI: ## Option 1: browser authentication This option requires an interactive browser environment. Run the following command to sign in through your browser: ```bash theme={"theme":{"light":"github-light","dark":"github-dark-default"}} e2b auth login ``` This will open your default browser and prompt you to authenticate with your E2B account. ## Option 2: setup environment variables This is the recommended option for non-interactive environments like CI/CD pipelines, servers, and containers. Set a single environment variable with your API key: ```bash theme={"theme":{"light":"github-light","dark":"github-dark-default"}} export E2B_API_KEY=your_api_key_here ``` With the API key set, you can run CLI commands directly without `e2b auth login`. Use CLI version 2.12.1 or later. Learn more about obtaining and managing your API key on the [API Key page](/api-key). ## Switch the active project If your E2B account has access to more than one [project](/projects), you can choose which one the CLI uses: ```bash theme={"theme":{"light":"github-light","dark":"github-dark-default"}} e2b auth configure ``` Run this after signing in with `e2b auth login`. The CLI shows an interactive list of your projects and stores the one you select as the active project, so subsequent CLI commands use that project's API key. You need to be logged in first for this command to work. # Connect to sandbox Source: https://docs.e2b.dev/cli/connect-to-sandbox You can connect an interactive terminal to an already running sandbox. ```bash Terminal theme={"theme":{"light":"github-light","dark":"github-dark-default"}} e2b sandbox connect ``` Unlike the `create` command, `connect` does not kill the sandbox when you disconnect. When you exit the terminal, only your terminal session is closed—the sandbox continues running. Once connected, you can inspect the sandbox filesystem and processes to debug or experiment, or use it as a dedicated environment for running agents instead of your local computer. # Create sandbox Source: https://docs.e2b.dev/cli/create-sandbox You can create a sandbox and connect an interactive terminal to it. ```bash Terminal theme={"theme":{"light":"github-light","dark":"github-dark-default"}} e2b sandbox create