docs(sandbox): document e2b code execution primitive#385
Conversation
Documents the SDK surface added in BerriAI/litellm#30898: acode_interpreter_tool for ephemeral runs and the acreate_sandbox / arun_code / adelete_sandbox lifecycle. Covers the e2b backend setup, parameters, the CodeExecutionResult passthrough shape, and what is intentionally out of scope for this phase (proxy endpoints, OpenAI container interceptor, gpt-5 routing, container reuse, file IO, OpenSandbox, Daytona). Adds a sidebar entry under LiteLLM Python SDK > SDK Functions.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6146acbb61
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| asyncio.run(main()) | ||
| ``` | ||
|
|
||
| `arun_code` and `adelete_sandbox` accept either the `ContainerHandle` returned by `acreate_sandbox` or a bare sandbox id string, so you can persist the id between processes and pick the sandbox back up later. |
There was a problem hiding this comment.
Remove the unsupported bare-ID reuse guidance
For the only supported provider (e2b), following this guidance and persisting just the sandbox id between processes makes arun_code fail before it reaches the network: the e2b implementation requires the access token stored on the ContainerHandle returned by acreate_sandbox and raises ValueError when a bare string has no envd_access_token. This line therefore documents a reuse workflow that users cannot actually execute.
Useful? React with 👍 / 👎.
Documents BerriAI/litellm#30905: how a client can call OpenAI's code interpreter through /v1/responses and have the code run in the configured sandbox (e2b) instead of OpenAI's container, with no client-side change. Covers the sandbox_tools registry and code_interpreter_interception callback, the curl shape, response-shape parity with native code_interpreter_call (id/type/status/code/container_id/outputs as an OpenAI-shaped logs array), streaming via the synthetic SSE wrapper, forced tool_choice rewrite, sandbox lifecycle and per-request isolation on a server-minted token, the stripped control fields that prevent client forgery, hot-reload behaviour, and the v0 limitation that file upload and download are not yet supported. Also notes the new api_base passthrough on the SDK entrypoints.
…uide A proxy user looking for code interpreter lands on guides/code_interpreter, not the SDK sandbox page, so the interceptor was effectively undiscoverable from the proxy side. Adds a tip in the Code Interpreter guide pointing at the new interceptor section, and a second sidebar entry under Tool Calling labelled 'Code Interpreter Sandbox Interception' next to the existing Web Search Interception entry, mirroring how websearch_interception is exposed.
The interceptor section had the config and curl but no narrative walking a proxy user from a clean checkout to a working call. Restructures into five numbered steps (get the e2b key, write config.yaml with a model_list plus sandbox_tools registry, start the proxy, call /v1/responses via curl or the OpenAI SDK, verify the code ran in e2b via the cntr_-wrapped container_id and the e2b dashboard sandbox count). Calls out enabled_providers as the safety gate so flipping the callback on does not silently change behaviour for other providers.
Summary
New page at
/docs/sandboxcovering both phases of the sandbox work.BerriAI/litellm#30898, SDK primitive:
acode_interpreter_toolfor ephemeral runs,acreate_sandbox/arun_code/adelete_sandboxfor manual lifecycle, theCodeExecutionResultpassthrough shape, e2b setup (E2B_API_KEY, default templatecode-interpreter-v1, 300s timeout).api_baseparam from phase 2 is included on each entrypoint.BerriAI/litellm#30905, Responses API code interpreter interceptor: a 4-step setup (set keys, write
config.yamlwithsandbox_tools+code_interpreter_interceptioncallback, start the proxy, curl/v1/responses) and a one-paragraph notes block covering response-shape parity, streaming, forcedtool_choice, lifecycle and isolation, hot reload, and the v0 no-file-IO limit.Discovery: sidebar entry
acode_interpreter_tool()under LiteLLM Python SDK > SDK Functions, plus a second entry "Code Interpreter Sandbox Interception" under Tool Calling next to "Web Search Interception". The existing/docs/guides/code_interpreterpage has a tip linking through.Test plan
npm startand verify the page renders athttp://localhost:3002/docs/sandbox/docs/guides/code_interpreterlinks to the interceptor section