Why E2B
- Secure execution — AI-generated code runs in isolated sandboxes, not on your servers
- Live preview URLs — each sandbox exposes a public URL you can embed in an iframe
- Custom templates — pre-install frameworks like Next.js, Streamlit, or Gradio so sandboxes start instantly via templates
- Multi-framework support — same API whether the generated app is React, Vue, Python, or anything else
Install the SDK
Fragments uses the E2B Code Interpreter SDK.Core Implementation
Your app orchestrates the flow from its own server — the sandbox is used purely to prepare and serve the generated code.Create a sandbox from a template
Each sandbox starts from a template with the target framework pre-installed and a dev server already running. See the Next.js template example.Install dependencies and write code
Install any extra packages the LLM requested, then write the generated code to the sandbox filesystem.Get the preview URL
The dev server picks up changes automatically. Retrieve the sandbox’s public URL and embed it in your frontend.Full example
A complete flow: LLM generates code, sandbox prepares and serves it. Simplified from Fragments.Related Guides
Custom Templates
Pre-install frameworks and tools so sandboxes start instantly
Connect LLMs
Integrate AI models with sandboxes using tool calling
Internet Access
Access sandbox apps via public URLs and control network policies