Supported Languages
E2B Code Interpreter runs Python by default. Agent Sandbox Flash Edition currently supports JavaScript, TypeScript, and Bash through the language parameter. Java and R are not supported.
Python
Python is the default language, so it is not necessary to pass language explicitly:
execution = sandbox.run_code('print("Hello, world!")')
print("".join(execution.logs.stdout or []).strip())
TypeScript SDK example:
const execution = await sandbox.runCode('print("Hello, world!")');
console.log(execution.logs.stdout.join("").trim());
JavaScript and TypeScript
Use javascript or js for JavaScript, and typescript or ts for TypeScript:
context = sandbox.create_code_context(
cwd="/home/user",
language="typescript",
request_timeout=60_000,
)
execution = sandbox.run_code(
"""
const value = await Promise.resolve(42)
console.log(value)
""",
context=context,
)
In the TypeScript SDK, use the same language option:
const execution = await sandbox.runCode(
`
const value = await Promise.resolve(42)
console.log(value)
`,
{ language: "typescript" },
);
The official E2B documentation states that TypeScript supports top-level await, ECMAScript module (ESM) imports, and automatic Promise resolution. When you integrate with Agent Sandbox Flash Edition, verify the Node.js version and the dependency installation capability inside the template first.
Bash
Use the corresponding language value for other languages, such as Bash:
sandbox.run_code('echo "Hello from Bash"', language="bash")
TypeScript SDK example:
await sandbox.runCode('echo "Hello from Bash"', { language: "bash" });
Selection guidance
-
Prefer Python for data analysis and chart generation.
-
Use JavaScript or TypeScript when you need npm packages, ESM imports, or TypeScript syntax, and install dependencies first.
-
Prefer the Commands API for simple system commands. Use
language="bash"only when you need to preserve execution state inside the Code Interpreter context. -
For Java code, use the Commands API to run
javacandjavainside the template, or use a custom template with the Java runtime pre-installed. -
For R code, use the Commands API to run
Rscriptinside the template, or use a custom template with the R runtime pre-installed. -
Before production rollout, prepare a minimal validation script for each language and confirm that stdout, stderr,
execution.results, and error returns behave as expected.