{"record":{"id":"65695a113b74d3f0","repo":"BerriAI/litellm","slug":"cannot-run-code-from-a-sandbox-id-alone-e2b-secur","errorCode":null,"errorMessage":"Cannot run code from a sandbox id alone. e2b secure sandboxes require the access token returned by acreate_sandbox; pass the ContainerHandle it returned instead of a bare sandbox id.","messagePattern":"Cannot run code from a sandbox id alone\\. e2b secure sandboxes require the access token returned by acreate_sandbox; pass the ContainerHandle it returned instead of a bare sandbox id\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/e2b/sandbox/transformation.py","lineNumber":108,"sourceCode":"            \"api_base\": base,\n        }\n        return handle\n\n    async def arun_code(\n        self,\n        *,\n        container: ContainerHandle | str,\n        code: str,\n        api_key: str | None = None,\n        env_vars: dict | None = None,\n        client: AsyncHTTPHandler | None = None,\n        **kwargs,\n    ) -> CodeExecutionResult:\n        handle: Final = self._as_handle(container)\n\n        token: Final = handle._hidden_params.get(\"envd_access_token\")\n        if not token:\n            raise ValueError(\n                \"Cannot run code from a sandbox id alone. e2b secure sandboxes \"\n                \"require the access token returned by acreate_sandbox; pass the \"\n                \"ContainerHandle it returned instead of a bare sandbox id.\"\n            )\n\n        headers: Final = {\"Content-Type\": \"application/json\", \"X-Access-Token\": token}\n        traffic_token: Final = handle._hidden_params.get(\"traffic_access_token\")\n        if traffic_token:\n            headers[\"E2B-Traffic-Access-Token\"] = traffic_token\n\n        url: Final = f\"https://{JUPYTER_PORT}-{handle.id}.{handle.domain}/execute\"\n        response: Final = cast(\n            httpx.Response,\n            await self._http(client).post(\n                url=url,\n                headers=headers,\n                json={\"code\": code, \"context_id\": None, \"env_vars\": env_vars},\n                stream=True,","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/e2b/sandbox/transformation.py#L90-L126","documentation":"Error \"Cannot run code from a sandbox id alone. e2b secure sandboxes require the access token returned by acreate_sandbox; pass the ContainerHandle it returned instead of a bare sandbox id.\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/e2b/sandbox/transformation.py:108 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the ContainerHandle returned by acreate_sandbox instead of a bare sandbox id."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}