# Code Execution

You can use E2B SDK to safely execute code generated by LLM inside the sandbox. {{ className: 'lead' }}
There are 2 ways to run code with E2B SDK. {{ className: 'lead' }}

### 1. Use the `runCode`/`run_code` methods in JS and Python SDK to run the LLM-generated code {{ className: 'lead' }}

This approach is very straightforward and you don't need to worry about managing the sandbox lifecycle or the process lifecycle.

<CodeGroupAutoload
  path="code_exec/run_code"
  isRunnable={true}
/>

### 2. Run the LLM-generated code using the low-level [sandbox.process](/sandbox/process) module {{ className: 'lead' }}

This approach gives you more control over the underlying sandbox and the running process. You can for example stream stdout and stderr, or kill the process that's running the code.

<CodeGroupAutoload
  path="code_exec/process"
  isRunnable={true}
/>
