code interpreter
@e2b
E2B是一種開源基礎架構,可讓您在雲中的安全隔離沙箱中運行到AI生成的代碼。要啟動和控製沙箱,請使用我們的JavaScript SDK或Python SDK。
JavaScript /打字稿
npm i @e2b/code-interpreter
Python
pip install e2b-code-interpreter
E2B_API_KEY=e2b_***
JavaScript /打字稿
import { Sandbox } from '@e2b/code-interpreter'
const sandbox = await Sandbox . create ( )
await sbx . runCode ( 'x = 1' )
const execution = await sbx . runCode ( 'x+=1; x' )
console . log ( execution . text ) // outputs 2
Python
from e2b_code_interpreter import Sandbox
with Sandbox () as sandbox :
sandbox . run_code ( "x = 1" )
execution = sandbox . run_code ( "x+=1; x" )
print ( execution . text ) # outputs 2
訪問E2B文檔。
請訪問我們的食譜,以受到不同LLM和AI框架的示例的啟發。