BerriAI/litellm · error · ValueError
Cannot run code from a sandbox id alone. e2b secure sandboxe
Error message
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.
What it means
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.
Source
Thrown at litellm/llms/e2b/sandbox/transformation.py:108
"api_base": base,
}
return handle
async def arun_code(
self,
*,
container: ContainerHandle | str,
code: str,
api_key: str | None = None,
env_vars: dict | None = None,
client: AsyncHTTPHandler | None = None,
**kwargs,
) -> CodeExecutionResult:
handle: Final = self._as_handle(container)
token: Final = handle._hidden_params.get("envd_access_token")
if not token:
raise ValueError(
"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."
)
headers: Final = {"Content-Type": "application/json", "X-Access-Token": token}
traffic_token: Final = handle._hidden_params.get("traffic_access_token")
if traffic_token:
headers["E2B-Traffic-Access-Token"] = traffic_token
url: Final = f"https://{JUPYTER_PORT}-{handle.id}.{handle.domain}/execute"
response: Final = cast(
httpx.Response,
await self._http(client).post(
url=url,
headers=headers,
json={"code": code, "context_id": None, "env_vars": env_vars},
stream=True,View on GitHub (pinned to 6c2dcb801b)
Solutions
- Pass the ContainerHandle returned by acreate_sandbox instead of a bare sandbox id.
When it happens
Trigger: Thrown at litellm/llms/e2b/sandbox/transformation.py:108 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/65695a113b74d3f0.
Report an issue: GitHub.