简体中文
E2B_SANDBOX
true
import { Sandbox } from '@e2b/code-interpreter' const sandbox = await Sandbox.create() const result = await sandbox.commands.run('echo $E2B_SANDBOX') console.log(result) // 输出示例: // { exitCode: 0, error: undefined, stdout: 'true\n', stderr: '' }
import { Sandbox } from '@e2b/code-interpreter' const sandbox = await Sandbox.create({ envs: { MY_VAR: 'my_value', }, }) const result = await sandbox.commands.run("echo $MY_VAR") console.log(result) // 输出示例: // { exitCode: 0, error: undefined, stdout: 'my_value\n', stderr: '' }
import { Sandbox } from '@e2b/code-interpreter' const sandbox = await Sandbox.create() const result = await sandbox.runCode('import os; print(os.environ.get("MY_VAR"))', { envs: { MY_VAR: 'my_value', }, })
import { Sandbox } from '@e2b/code-interpreter' const sandbox = await Sandbox.create() const result = await sandbox.commands.run('echo $MY_VAR', { envs: { MY_VAR: '123', }, }) console.log(result) // 输出示例: // { exitCode: 0, error: undefined, stdout: '123\n', stderr: '' }