Appearance
Run Your First Sandbox
This quickstart guide demonstrates how to launch a sandbox environment, execute code within it, and manage files.
Step 1: Account Setup
If you don't already have a Sufy account, create one at the Sufy signup page.
Step 2: API Configuration
Obtain your authentication key from the Sufy API key management page and add it to your .env file:
env
E2B_API_KEY=sk_***
E2B_API_URL=https://us-south-1-sandbox.sufyapi.comNote: The Sufy sandbox service is fully compatible with the E2B API, so you can use the E2B SDK directly. When using the Sufy service, configure both the E2B_API_KEY and E2B_API_URL environment variables.
Service Endpoint
| Region | Region ID | API Endpoint |
|---|---|---|
| US (Dallas 1) | us-south-1 | https://us-south-1-sandbox.sufyapi.com |
Set the API endpoint as E2B_API_URL:
env
E2B_API_KEY=sk_***
E2B_API_URL=https://us-south-1-sandbox.sufyapi.comStep 3: SDK Installation
Install the appropriate package for your programming language:
JavaScript/TypeScript:
bash
npm i @e2b/code-interpreter dotenvPython:
bash
pip install e2b-code-interpreter python-dotenvStep 4: Implement the Code
JavaScript/TypeScript (index.ts):
javascript
// index.ts
import 'dotenv/config'
import { Sandbox } from '@e2b/code-interpreter'
async function main() {
const sbx = await Sandbox.create() // By default the sandbox is alive for 5 minutes
const execution = await sbx.runCode('print("hello world")') // Execute Python inside the sandbox
console.log(execution.logs)
const files = await sbx.files.list('/')
console.log(files)
await sbx.kill()
}
main()Python (main.py):
python
# main.py
from dotenv import load_dotenv
load_dotenv()
from e2b_code_interpreter import Sandbox
sbx = Sandbox() # By default the sandbox is alive for 5 minutes
execution = sbx.run_code("print('hello world')") # Execute Python inside the sandbox
print(execution.logs)
files = sbx.files.list("/")
print(files)
sbx.kill()Step 5: Run the Command
JavaScript/TypeScript:
bash
npx tsx ./index.tsPython:
bash
python main.pyNotes
By default, the sandbox remains alive for 5 minutes.