|
1 |
| -# Code Interpreter SDK |
2 |
| -E2B's [Code Interpreter SDK](https://github.com/e2b-dev/code-interpreter) allows you to add code interpreting capabilities to your AI apps. |
3 |
| - |
4 |
| -The code interpreter runs inside the [E2B Sandbox](https://github.com/e2b-dev/e2b) - an open-source secure sandbox made for running untrusted AI-generated code and AI agents. |
5 |
| -- ✅ Works with any LLM and AI framework |
6 |
| -- ✅ Supports streaming content like charts and stdout, stderr |
7 |
| -- ✅ Python & JS SDK |
8 |
| -- ✅ Runs on serverless and edge functions |
9 |
| -- ✅ Runs AI-generated code in secure sandboxed environments |
10 |
| -- ✅ 100% open source (including [infrastructure](https://github.com/e2b-dev/infra)) |
11 |
| - |
12 |
| -Follow E2B on [X (Twitter)](https://twitter.com/e2b_dev). |
13 |
| - |
14 |
| -## 💻 Supported language runtimes |
15 |
| -- ✅ Python |
16 |
| -- [(Beta)](https://e2b.dev/docs/guide/beta-code-interpreter-language-runtimes) JavaScript, R, Java |
17 |
| - |
18 |
| -## 📖 Documentation |
19 |
| -- [e2b.dev/docs/code-interpreter](https://e2b.dev/docs/code-interpreter/installation) |
20 |
| - |
21 |
| -## 🚀 Quickstart |
| 1 | +<p align="center"> |
| 2 | + <img width="100" src="/readme-assets/logo-circle.png" alt="e2b logo"> |
| 3 | +</p> |
| 4 | + |
| 5 | +<h4 align="center"> |
| 6 | + <a href="https://pypi.org/project/e2b/"> |
| 7 | + <img alt="Last 1 month downloads for the Python SDK" loading="lazy" width="200" height="20" decoding="async" data-nimg="1" |
| 8 | + style="color:transparent;width:auto;height:100%" src="https://img.shields.io/pypi/dm/e2b?label=PyPI%20Downloads"> |
| 9 | + </a> |
| 10 | + <a href="https://www.npmjs.com/package/e2b"> |
| 11 | + <img alt="Last 1 month downloads for the JavaScript SDK" loading="lazy" width="200" height="20" decoding="async" data-nimg="1" |
| 12 | + style="color:transparent;width:auto;height:100%" src="https://img.shields.io/npm/dm/e2b?label=NPM%20Downloads"> |
| 13 | + </a> |
| 14 | +</h4> |
| 15 | + |
| 16 | +<!--- |
| 17 | +<img width="100%" src="/readme-assets/preview.png" alt="Cover image"> |
| 18 | +---> |
| 19 | +## What is E2B? |
| 20 | +[E2B](https://www.e2b.dev/) is an open-source infrastructure that allows you run to AI-generated code in secure isolated sandboxes in the cloud. To start and control sandboxes, use our [JavaScript SDK](https://www.npmjs.com/package/@e2b/code-interpreter) or [Python SDK](https://pypi.org/project/e2b_code_interpreter). |
| 21 | + |
| 22 | +## Run your first Sandbox |
22 | 23 |
|
23 | 24 | ### 1. Install SDK
|
24 | 25 |
|
25 |
| -JavaScript/TypeScript |
| 26 | +JavaScript / TypeScript |
26 | 27 | ```
|
27 | 28 | npm i @e2b/code-interpreter
|
28 | 29 | ```
|
29 | 30 |
|
30 | 31 | Python
|
31 | 32 | ```
|
32 |
| -pip install e2b_code_interpreter |
| 33 | +pip install e2b-code-interpreter |
| 34 | +``` |
| 35 | + |
| 36 | +### 2. Get your E2B API key |
| 37 | +1. Sign up to E2B [here](https://e2b.dev). |
| 38 | +2. Get your API key [here](https://e2b.dev/dashboard?tab=keys). |
| 39 | +3. Set environment variable with your API key |
33 | 40 | ```
|
| 41 | +E2B_API_KEY=e2b_*** |
| 42 | +``` |
34 | 43 |
|
35 |
| -### 2. Execute code with code interpreter inside sandbox |
| 44 | +### 3. Execute code with code interpreter inside Sandbox |
36 | 45 |
|
37 |
| -**JavaScript** |
| 46 | +JavaScript / TypeScript |
38 | 47 | ```ts
|
39 |
| -import { CodeInterpreter } from '@e2b/code-interpreter' |
| 48 | +import { Sandbox } from '@e2b/code-interpreter' |
40 | 49 |
|
41 |
| -const sandbox = await CodeInterpreter.create() |
42 |
| -await sandbox.notebook.execCell('x = 1') |
| 50 | +const sandbox = await Sandbox.create() |
| 51 | +await sbx.runCode()('x = 1') |
43 | 52 |
|
44 |
| -const execution = await sandbox.notebook.execCell('x+=1; x') |
| 53 | +const execution = await sbx.runCode()('x+=1; x') |
45 | 54 | console.log(execution.text) // outputs 2
|
46 |
| - |
47 |
| -await sandbox.close() |
48 | 55 | ```
|
49 | 56 |
|
50 |
| -**Python** |
| 57 | +Python |
51 | 58 | ```py
|
52 |
| -from e2b_code_interpreter import CodeInterpreter |
| 59 | +from e2b_code_interpreter import Sandbox |
53 | 60 |
|
54 |
| -with CodeInterpreter() as sandbox: |
55 |
| - sandbox.notebook.exec_cell("x = 1") |
56 |
| - |
57 |
| - execution = sandbox.notebook.exec_cell("x+=1; x") |
| 61 | +with Sandbox() as sandbox: |
| 62 | + sandbox.run_code()("x = 1") |
| 63 | + execution = sandbox.run_code()("x+=1; x") |
58 | 64 | print(execution.text) # outputs 2
|
59 | 65 | ```
|
60 | 66 |
|
61 |
| -### 3. Hello World guide |
62 |
| -Dive depeer and check out the [JavaScript/TypeScript](https://e2b.dev/docs/hello-world/js) and [Python](https://e2b.dev/docs/hello-world/py) "Hello World" guides to learn how to connect code interpreter LLMs. |
63 |
| - |
64 |
| -## 📖 Cookbook examples |
65 |
| - |
66 |
| -**Hello World** |
67 |
| -- [JavaScript/TypeScript](https://e2b.dev/docs/hello-world/js) |
68 |
| -- [Python](https://e2b.dev/docs/hello-world/py) |
69 |
| - |
70 |
| -**LLM Providers** |
71 |
| -- 🪸 [Claude with code intepreter](https://github.com/e2b-dev/e2b-cookbook/blob/main/examples/claude-code-interpreter-python/claude_code_interpreter.ipynb) |
72 |
| -- 🦙 [Llama 3 with code interpreter](https://github.com/e2b-dev/e2b-cookbook/tree/main/examples/llama-3-code-interpreter-python) |
73 |
| -- [Mixtral with code interpreter and chat UI](https://github.com/e2b-dev/e2b-cookbook/tree/main/templates/mixtral-8x7b-code-interpreter-nextjs) |
74 |
| - |
75 |
| -**AI Frameworks** |
76 |
| -- 🦜⛓️ [LangChain with code interpreter](https://github.com/e2b-dev/e2b-cookbook/tree/main/examples/langchain-python) |
77 |
| -- 🦜🕸️ [LangGraph with code interpreter](https://github.com/e2b-dev/e2b-cookbook/tree/main/examples/langgraph-python) |
78 |
| -- [Autogen with secure sandboxed code interpreter](https://github.com/e2b-dev/e2b-cookbook/tree/main/examples/e2b_autogen) |
| 67 | +### 4. Check docs |
| 68 | +Visit [E2B documentation](https://e2b.dev/docs). |
79 | 69 |
|
| 70 | +### 5. E2B cookbook |
| 71 | +Visit our [Cookbook](https://github.com/e2b-dev/e2b-cookbook/tree/main) to get inspired by examples with different LLMs and AI frameworks. |
0 commit comments