code-interpreter
Python & JS/TS SDK for running AI-generated code/code interpreting in your AI app
What is code-interpreter?
Python & JS/TS SDK for running AI-generated code/code interpreting in your AI app
Overview of code-interpreter
What it is
code-interpreter is an open-source SDK (Python and JavaScript/TypeScript) from E2B that enables you to run AI-generated code inside secure, isolated sandboxes in the cloud. It provides a simple interface to execute code, capture output, and manage sandbox lifecycles, making it suitable for building AI applications that need to interpret or run untrusted code safely. The SDK sources live in the E2B monorepo, and this repository contains the sandbox template that bundles chart data extraction capabilities. E2B itself is an open-source infrastructure for running AI-generated code in secure sandboxes.
Key features
- Run AI-generated code in secure, isolated cloud sandboxes - Supports both Python (
e2b-code-interpreter) and JavaScript/TypeScript (@e2b/code-interpreter) SDKs - Execute code and retrieve text output, results, and errors - Customizable sandbox templates: you can build your own template with extra packages or a different runtime - Bundled chart data extractor in the sandbox template (template/charts) - Simple API: create a sandbox, run code, and get execution results
Use cases
- Building AI assistants that need to execute generated code (e.g., data analysis, chart generation)
- Running untrusted code from users or AI models in a safe environment - Creating code interpretation features in AI applications - Prototyping and testing AI-generated scripts without risking the host system - Integrating with LLMs to provide code execution capabilities (see E2B cookbook for examples)
Getting started
- Install the SDK: JavaScript / TypeScript
npm i @e2b/code-interpreterPythonpip install e2b-code-interpreter2. Get your E2B API key: sign up at E2B, get your API key, and set the environment variable:E2B_API_KEY=e2b_***3. Execute code inside a sandbox: JavaScript / TypeScriptts import { Sandbox } from '@e2b/code-interpreter' const sbx = await Sandbox.create() await sbx.runCode('x = 1') const execution = await sbx.runCode('x+=1; x') console.log(execution.text) // outputs 2Pythonpy from e2b_code_interpreter import Sandbox with Sandbox.create() as sandbox: sandbox.run_code('x = 1') execution = sandbox.run_code('x+=1; x') print(execution.text) # outputs 2For more details, see the repository README.
License and pricing
The license is Apache-2.0. The project is open source; no pricing information is stated in the provided materials.
Based on the project's public README and repository metadata.