4a4bb36839
## Summary - Both JS and Python SDKs now validate that the configured E2B API key matches `e2b_` followed by 40 hex characters (mirroring the server-side check in [`infra/.../keys/key.go`](https://github.com/e2b-dev/infra/blob/main/packages/shared/pkg/keys/key.go#L66)) and throw `AuthenticationError` / `AuthenticationException` with an example token (`e2b_0000…`) and a link to the API Keys dashboard tab. - Validation runs inside `ApiClient` / `ApiClient.__init__` whenever an API key is present, so callers get immediate, actionable feedback instead of a generic 401 from the server. - Added unit tests (`validateApiKey.test.ts`, `test_validate_api_key.py`) and updated existing fixtures that used placeholder keys like `'test-key'` / `'base-api-key'` to use the valid format. ## Test plan - [x] `pnpm run format`, `pnpm run lint`, `pnpm run typecheck` - [x] `pnpm exec vitest run tests/api/validateApiKey.test.ts tests/api/handleApiError.test.ts tests/sandbox/abortSignal.test.ts tests/template/abortSignal.test.ts tests/sandbox/configPropagation.test.ts tests/connectionConfig.test.ts` - [x] `poetry run pytest tests/test_validate_api_key.py tests/test_api_client_transport.py tests/sync/sandbox_sync/test_config_propagation.py tests/async/sandbox_async/test_config_propagation.py tests/test_connection_config.py` 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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 e2b
2. 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. Code execution with Code Interpreter
If you need runCode(), install the Code Interpreter SDK:
npm i @e2b/code-interpreter
import { 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 2
5. Check docs
Visit E2B documentation.
6. E2B cookbook
Visit our Cookbook to get inspired by examples with different LLMs and AI frameworks.
