E2B is the code execution layer for the AI app. The ability to execute the code as opposed to only generate it has many advantages:
- Better reasoning
- More complex tasks (e.g., advanced data analysis or mathematics)
- Producing tangible results such as charts
- Immediate testing (and correcting) of the produced output.
The open-source Code Interpreter SDK by E2B provides a long-running secure sandboxed environment where you can run the output generated by Together AI's LLMs. This SDK is tailor-made for AI data analysts, coding apps, and reasoning-heavy agents. The SDK quickly creates a secure cloud sandbox. Inside the sandbox is a running Jupyter server which the LLM can use.
-
Get your E2B API key here for free.
-
Install the SDK
JavaScript & TypeScript version:
npm i @e2b/code-interpreter
Python version:
pip install e2b_code_interpreter
- Execute code with code interpreter inside sandbox
JavaScript & TypeScript version:
import { CodeInterpreter } from '@e2b/code-interpreter'
const sandbox = await CodeInterpreter.create()
await sandbox.notebook.execCell('x = 1')
const execution = await sandbox.notebook.execCell('x+=1; x')
console.log(execution.text) // outputs 2
await sandbox.close()
Python version:
from e2b_code_interpreter import CodeInterpreter
with CodeInterpreter() as sandbox:
sandbox.notebook.exec_cell("x = 1")
execution = sandbox.notebook.exec_cell("x+=1; x")
print(execution.text) # outputs 2
E2B makes running AI-generated code in secure and isolated sandbox environments easy with the Code Interpreter SDK.
The SDK has a Python and JavaScript/TypeScript version. E2B works with any LLM and any AI frameworks (e.g., LangChain, LammaIndex, Vercel AI SDK, CrewAI, Autogen).
Check out the E2B docs and E2B Cookbook.